* mkimport: New script to perform all operations necessary to create
libcygwin.a. * rmsym: Delete. * newsym: Delete. * Makefile.in (toolopts): New variable which holds options relating to binutils/gcc tools. (speclib): Use toolopts. Add symbols to avoid copying to special libraries. (OBSOLETE_FUNCTIONS): Delete. (NEW_FUNCTIONS): Change to represent an argument to new mkimport script. (libcygwin.a): Use only new mkimport script to create libcygwin.a. Only rely on ${LIBCOS}. (*/lib*.a): Simplify speclib dependencies. (speclib): Accept toolchain options. Convert every argument to absolute path. Simplify parsing of nm output. Accommodate new exclude option.
This commit is contained in:
parent
370a1171d8
commit
edd090a270
|
@ -1,3 +1,23 @@
|
||||||
|
2009-04-11 Christopher Faylor <me+cygwin@cgf.cx>
|
||||||
|
|
||||||
|
* mkimport: New script to perform all operations necessary to create
|
||||||
|
libcygwin.a.
|
||||||
|
* rmsym: Delete.
|
||||||
|
* newsym: Delete.
|
||||||
|
* Makefile.in (toolopts): New variable which holds options relating to
|
||||||
|
binutils/gcc tools.
|
||||||
|
(speclib): Use toolopts. Add symbols to avoid copying to special
|
||||||
|
libraries.
|
||||||
|
(OBSOLETE_FUNCTIONS): Delete.
|
||||||
|
(NEW_FUNCTIONS): Change to represent an argument to new mkimport
|
||||||
|
script.
|
||||||
|
(libcygwin.a): Use only new mkimport script to create libcygwin.a.
|
||||||
|
Only rely on ${LIBCOS}.
|
||||||
|
(*/lib*.a): Simplify speclib dependencies.
|
||||||
|
(speclib): Accept toolchain options. Convert every argument to
|
||||||
|
absolute path. Simplify parsing of nm output. Accommodate new
|
||||||
|
exclude option.
|
||||||
|
|
||||||
2009-04-11 Dave Korn <dave.korn.cygwin@googlemail.com>
|
2009-04-11 Dave Korn <dave.korn.cygwin@googlemail.com>
|
||||||
|
|
||||||
* include/stdint.h (INTPTR_MIN, INTPTR_MAX): Add 'L' suffix.
|
* include/stdint.h (INTPTR_MIN, INTPTR_MAX): Add 'L' suffix.
|
||||||
|
|
|
@ -105,7 +105,14 @@ LIBGMON_A:=libgmon.a
|
||||||
CYGWIN_START:=crt0.o
|
CYGWIN_START:=crt0.o
|
||||||
GMON_START:=gcrt0.o
|
GMON_START:=gcrt0.o
|
||||||
|
|
||||||
speclib=${word 1, $^} "${NM}" "${AR}" $(wordlist 2, $(words $^), $^)
|
toolopts:=--ar=${AR} --as=${AS} --nm=${NM} --objcopy=${OBJCOPY}
|
||||||
|
speclib=\
|
||||||
|
${srcdir}/speclib ${toolopts} \
|
||||||
|
--exclude='cygwin' \
|
||||||
|
--exclude='(?i:dll)' \
|
||||||
|
--exclude='reloc' \
|
||||||
|
--exclude='^_main$$' \
|
||||||
|
$^
|
||||||
|
|
||||||
# Some things want these from libc, but they have their own static
|
# Some things want these from libc, but they have their own static
|
||||||
# data which apps can get to, which is a pain in the dll, so we
|
# data which apps can get to, which is a pain in the dll, so we
|
||||||
|
@ -162,67 +169,60 @@ EXCLUDE_STATIC_OFILES:=$(addprefix --exclude=,\
|
||||||
|
|
||||||
GMON_OFILES:=gmon.o mcount.o profil.o
|
GMON_OFILES:=gmon.o mcount.o profil.o
|
||||||
|
|
||||||
OBSOLETE_FUNCTIONS:=open acl aclcheck aclfrommode aclfrompbits \
|
NEW_FUNCTIONS:=$(addprefix --replace=,\
|
||||||
aclfromtext aclsort acltomode acltopbits \
|
acl=_acl32 \
|
||||||
acltotext chown facl fchown fcntl fdopen fgetpos fopen \
|
aclcheck=_aclcheck32 \
|
||||||
freopen fseeko fsetpos fstat ftello ftruncate \
|
aclfrommode=_aclfrommode32 \
|
||||||
getegid geteuid getgid getgrent getgrgid getgrnam \
|
aclfrompbits=_aclfrompbits32 \
|
||||||
getgroups getpwuid getpwuid_r getuid initgroups \
|
aclfromtext=_aclfromtext32 \
|
||||||
lchown lseek lstat mknod mmap seekdir setegid seteuid \
|
aclsort=_aclsort32 \
|
||||||
setgid setgroups setregid setreuid setuid stat \
|
acltomode=_acltomode32 \
|
||||||
telldir tmpfile truncate timezone
|
acltopbits=_acltopbits32 \
|
||||||
|
acltotext=_acltotext32 \
|
||||||
NEW_FUNCTIONS:=open _open64 \
|
chown=_chown32 \
|
||||||
acl _acl32 \
|
facl=_facl32 \
|
||||||
aclcheck _aclcheck32 \
|
fchown=_fchown32 \
|
||||||
aclfrommode _aclfrommode32 \
|
fcntl=_fcntl64 \
|
||||||
aclfrompbits _aclfrompbits32 \
|
fdopen=_fdopen64 \
|
||||||
aclfromtext _aclfromtext32 \
|
fgetpos=_fgetpos64 \
|
||||||
aclsort _aclsort32 \
|
fopen=_fopen64 \
|
||||||
acltomode _acltomode32 \
|
freopen=_freopen64 \
|
||||||
acltopbits _acltopbits32 \
|
fseeko=_fseeko64 \
|
||||||
acltotext _acltotext32 \
|
fsetpos=_fsetpos64 \
|
||||||
chown _chown32 \
|
fstat=_fstat64 \
|
||||||
facl _facl32 \
|
ftello=_ftello64 \
|
||||||
fchown _fchown32 \
|
ftruncate=_ftruncate64 \
|
||||||
fcntl _fcntl64 \
|
getegid=_getegid32 \
|
||||||
fdopen _fdopen64 \
|
geteuid=_geteuid32 \
|
||||||
fgetpos _fgetpos64 \
|
getgid=_getgid32 \
|
||||||
fopen _fopen64 \
|
getgrent=_getgrent32 \
|
||||||
freopen _freopen64 \
|
getgrgid=_getgrgid32 \
|
||||||
fseeko _fseeko64 \
|
getgrnam=_getgrnam32 \
|
||||||
fsetpos _fsetpos64 \
|
getgroups=_getgroups32 \
|
||||||
fstat _fstat64 \
|
getpwuid=_getpwuid32 \
|
||||||
ftello _ftello64 \
|
getpwuid_r=_getpwuid_r32 \
|
||||||
ftruncate _ftruncate64 \
|
getuid=_getuid32 \
|
||||||
getegid _getegid32 \
|
initgroups=_initgroups32 \
|
||||||
geteuid _geteuid32 \
|
lchown=_lchown32 \
|
||||||
getgid _getgid32 \
|
lseek=_lseek64 \
|
||||||
getgrent _getgrent32 \
|
lstat=_lstat64 \
|
||||||
getgrgid _getgrgid32 \
|
mknod=_mknod32 \
|
||||||
getgrnam _getgrnam32 \
|
mmap=_mmap64 \
|
||||||
getgroups _getgroups32 \
|
open=_open64 \
|
||||||
getpwuid _getpwuid32 \
|
seekdir=_seekdir64 \
|
||||||
getpwuid_r _getpwuid_r32 \
|
setegid=_setegid32 \
|
||||||
getuid _getuid32 \
|
seteuid=_seteuid32 \
|
||||||
initgroups _initgroups32 \
|
setgid=_setgid32 \
|
||||||
lchown _lchown32 \
|
setgroups=_setgroups32 \
|
||||||
lseek _lseek64 \
|
setregid=_setregid32 \
|
||||||
lstat _lstat64 \
|
setreuid=_setreuid32 \
|
||||||
mknod _mknod32 \
|
setuid=_setuid32 \
|
||||||
mmap _mmap64 \
|
stat=_stat64 \
|
||||||
seekdir _seekdir64 \
|
telldir=_telldir64 \
|
||||||
setegid _setegid32 \
|
timezone= \
|
||||||
seteuid _seteuid32 \
|
tmpfile=_tmpfile64 \
|
||||||
setgid _setgid32 \
|
truncate=_truncate64 \
|
||||||
setgroups _setgroups32 \
|
)
|
||||||
setregid _setregid32 \
|
|
||||||
setreuid _setreuid32 \
|
|
||||||
setuid _setuid32 \
|
|
||||||
stat _stat64 \
|
|
||||||
telldir _telldir64 \
|
|
||||||
tmpfile _tmpfile64 \
|
|
||||||
truncate _truncate64
|
|
||||||
|
|
||||||
API_VER:=$(srcdir)/include/cygwin/version.h
|
API_VER:=$(srcdir)/include/cygwin/version.h
|
||||||
|
|
||||||
|
@ -396,11 +396,8 @@ $(TEST_DLL_NAME): $(LDSCRIPT) dllfixdbg $(DLL_OFILES) $(DLL_IMPORTS) $(LIBSERVER
|
||||||
@ln -f $@ new-$(DLL_NAME)
|
@ln -f $@ new-$(DLL_NAME)
|
||||||
|
|
||||||
# Rule to build libcygwin.a
|
# Rule to build libcygwin.a
|
||||||
$(LIB_NAME): rmsym newsym $(TEST_DLL_NAME) $(LIBCOS)
|
$(LIB_NAME): $(LIBCOS) | $(TEST_DLL_NAME)
|
||||||
/bin/sh ${word 1,$^} ./cygdll.a "$(NM)" "$(AR)" $(OBSOLETE_FUNCTIONS) || exit 0
|
${srcdir}/mkimport ${toolopts} ${NEW_FUNCTIONS} $@ cygdll.a $^
|
||||||
/bin/sh ${word 2,$^} ./cygdll.a "$(AS)" "$(AR)" $(NEW_FUNCTIONS) || exit 0
|
|
||||||
(echo create $(LIB_NAME); echo addmod $(LIBCOS); echo addlib cygdll.a; echo save) | $(AR) -M
|
|
||||||
$(RANLIB) $@
|
|
||||||
|
|
||||||
${STATIC_LIB_NAME}: mkstatic ${TEST_DLL_NAME}
|
${STATIC_LIB_NAME}: mkstatic ${TEST_DLL_NAME}
|
||||||
perl -d $< -x ${EXCLUDE_STATIC_OFILES} --library=${LIBC} --library=${LIBM} --ar=${AR} $@ cygwin.map
|
perl -d $< -x ${EXCLUDE_STATIC_OFILES} --library=${LIBC} --library=${LIBM} --ar=${AR} $@ cygwin.map
|
||||||
|
@ -442,22 +439,22 @@ shared.o: shared_info_magic.h
|
||||||
$(srcdir)/devices.cc: gendevices devices.in devices.h
|
$(srcdir)/devices.cc: gendevices devices.in devices.h
|
||||||
${wordlist 1,2,$^} $@
|
${wordlist 1,2,$^} $@
|
||||||
|
|
||||||
${CURDIR}/libc.a: speclib ${LIB_NAME} ./libm.a libpthread.a libutil.a
|
${CURDIR}/libc.a: ${LIB_NAME} ./libm.a libpthread.a libutil.a
|
||||||
${speclib} -v ${@F}
|
${speclib} -v ${@F}
|
||||||
|
|
||||||
${CURDIR}/libm.a: speclib ${LIB_NAME} $(LIBM)
|
${CURDIR}/libm.a: ${LIB_NAME} $(LIBM)
|
||||||
${speclib} ${@F}
|
${speclib} ${@F}
|
||||||
|
|
||||||
libpthread.a: speclib ${LIB_NAME} pthread.o thread.o
|
libpthread.a: ${LIB_NAME} pthread.o thread.o
|
||||||
${speclib} ${@F}
|
${speclib} ${@F}
|
||||||
|
|
||||||
libutil.a: speclib ${LIB_NAME} bsdlib.o
|
libutil.a: ${LIB_NAME} bsdlib.o
|
||||||
${speclib} ${@F}
|
${speclib} ${@F}
|
||||||
|
|
||||||
libdl.a: speclib ${LIB_NAME} dlfcn.o
|
libdl.a: ${LIB_NAME} dlfcn.o
|
||||||
${speclib} ${@F}
|
${speclib} ${@F}
|
||||||
|
|
||||||
libresolv.a: speclib ${LIB_NAME} minires.o
|
libresolv.a: ${LIB_NAME} minires.o
|
||||||
${speclib} ${@F}
|
${speclib} ${@F}
|
||||||
|
|
||||||
${EXTRALIBS}: lib%.a: %.o
|
${EXTRALIBS}: lib%.a: %.o
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
use strict;
|
||||||
|
use File::Temp qw'tempdir';
|
||||||
|
use File::Spec;
|
||||||
|
use Getopt::Long;
|
||||||
|
my $dir = tempdir(CLEANUP => 1);
|
||||||
|
|
||||||
|
my ($ar, $as, $nm, $objcopy, %replace);
|
||||||
|
GetOptions('ar=s'=>\$ar, 'as=s'=>\$as,'nm=s'=>\$nm, 'objcopy=s'=>\$objcopy, 'replace=s'=>\%replace);
|
||||||
|
|
||||||
|
# Args::
|
||||||
|
# 1) import lib to create
|
||||||
|
# 2) input dll
|
||||||
|
# 3...) extra objects to add
|
||||||
|
|
||||||
|
$_ = File::Spec->rel2abs($_) for @ARGV;
|
||||||
|
|
||||||
|
my $libdll = shift;
|
||||||
|
my $inpdll = shift;
|
||||||
|
|
||||||
|
open my $nm_fd, '-|', $nm, '-Apg', '--defined-only', $inpdll;
|
||||||
|
my %text = ();
|
||||||
|
my %import = ();
|
||||||
|
my %symfile = ();
|
||||||
|
while (<$nm_fd>) {
|
||||||
|
chomp;
|
||||||
|
my ($fn, $type, $sym) = /^$inpdll:(.*?):\S+\s+(\S)\s+(\S+)$/o;
|
||||||
|
next unless $fn;
|
||||||
|
$text{$fn} = $sym if $type eq 'T';
|
||||||
|
$import{$fn} = $sym if $type eq 'I';
|
||||||
|
$symfile{$sym} = $fn;
|
||||||
|
}
|
||||||
|
close $nm_fd or exit 1;
|
||||||
|
|
||||||
|
for my $sym (keys %replace) {
|
||||||
|
my $fn;
|
||||||
|
my $_sym = '_' . $sym;
|
||||||
|
if (!defined($fn = $symfile{$_sym})) {
|
||||||
|
$fn = "$sym.o";
|
||||||
|
$text{$fn} = $_sym;
|
||||||
|
}
|
||||||
|
my $imp_sym = '__imp__' . $replace{$sym};
|
||||||
|
$import{$fn} = $imp_sym;
|
||||||
|
}
|
||||||
|
|
||||||
|
for my $f (keys %text) {
|
||||||
|
my $imp_sym = delete $import{$f};
|
||||||
|
my $glob_sym = $text{$f};
|
||||||
|
if (!defined $imp_sym) {
|
||||||
|
delete $text{$f};
|
||||||
|
} elsif ($imp_sym eq '__imp__') {
|
||||||
|
$text{$f} = 0;
|
||||||
|
} else {
|
||||||
|
$text{$f} = 1;
|
||||||
|
open my $as_fd, '|-', $as, '-o', "$dir/t-$f", "-";
|
||||||
|
print $as_fd <<EOF;
|
||||||
|
.extern $imp_sym
|
||||||
|
.global $glob_sym
|
||||||
|
$glob_sym:
|
||||||
|
jmp *$imp_sym
|
||||||
|
EOF
|
||||||
|
close $as_fd or exit 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir $dir or die "$0: couldn't cd to $dir - $!\n";
|
||||||
|
system $ar, 'x', $inpdll;
|
||||||
|
exit 1 if $?;
|
||||||
|
|
||||||
|
for my $f (keys %text) {
|
||||||
|
if (!$text{$f}) {
|
||||||
|
unlink $f;
|
||||||
|
} else {
|
||||||
|
system $objcopy, '-R', '.text', $f and exit 1;
|
||||||
|
system $objcopy, '-R', '.bss', '-R', '.data', "t-$f" and exit 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unlink $libdll;
|
||||||
|
exec $ar, 'crus', $libdll, glob('*.o'), @ARGV;
|
|
@ -1,39 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
lib=$1; shift
|
|
||||||
as=$1; shift
|
|
||||||
ar=$1; shift
|
|
||||||
rm -rf newsym.dir
|
|
||||||
trap "rm -rf newsym.dir" 0 1 2 15
|
|
||||||
mkdir newsym.dir
|
|
||||||
while [ -n "$1" ]; do
|
|
||||||
newsym=$1; shift
|
|
||||||
oldsym=$1; shift
|
|
||||||
if [[ "$newsym" = *:d ]]; then
|
|
||||||
newsym=${newsym%:d}
|
|
||||||
else
|
|
||||||
cat <<EOF
|
|
||||||
.text
|
|
||||||
.global _$newsym
|
|
||||||
_$newsym:
|
|
||||||
jmp *__imp__$oldsym
|
|
||||||
EOF
|
|
||||||
fi > newsym.dir/$newsym.s
|
|
||||||
|
|
||||||
cat <<EOF >> newsym.dir/$newsym.s
|
|
||||||
.section .idata\$7
|
|
||||||
.long __head_cygwin1_dll
|
|
||||||
|
|
||||||
.section .idata\$5
|
|
||||||
.global __imp__$newsym
|
|
||||||
__imp__$newsym: .rva 1f
|
|
||||||
|
|
||||||
.section .idata\$4
|
|
||||||
.rva 1f
|
|
||||||
|
|
||||||
.section .idata\$6
|
|
||||||
1: .short 2
|
|
||||||
.asciz "$oldsym"
|
|
||||||
EOF
|
|
||||||
$as -o newsym.dir/$newsym.o newsym.dir/$newsym.s
|
|
||||||
done
|
|
||||||
$ar crus $lib newsym.dir/*.o
|
|
|
@ -1,9 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
lib=$1; shift
|
|
||||||
nm=$1; shift
|
|
||||||
ar=$1; shift
|
|
||||||
grepit=`echo $* | sed 's/ /\$|__imp__/g'`
|
|
||||||
[ -n "$grepit" ] && grepit="__imp__$grepit\$"
|
|
||||||
objs=`$nm $lib | awk -F: '/^d*[0-9][0-9]*.o:/ {obj=$1} '"/$grepit/"'{print obj}'`
|
|
||||||
[ -n "$objs" ] || exit 1
|
|
||||||
$ar ds $lib $objs
|
|
|
@ -8,35 +8,35 @@ use strict;
|
||||||
sub dllname($;$);
|
sub dllname($;$);
|
||||||
|
|
||||||
my $static;
|
my $static;
|
||||||
my $exclude;
|
my $inverse;
|
||||||
|
my @exclude;
|
||||||
|
|
||||||
GetOptions('static!'=>\$static, 'v|exclude!'=>\$exclude);
|
my ($ar, $as, $nm, $objcopy);
|
||||||
|
GetOptions('exclude=s'=>\@exclude, 'static!'=>\$static, 'v!'=>\$inverse,
|
||||||
|
'ar=s'=>\$ar, 'as=s'=>\$as,'nm=s'=>\$nm, 'objcopy=s'=>\$objcopy);
|
||||||
|
|
||||||
my $nm = shift;
|
$_ = File::Spec->rel2abs($_) for @ARGV;
|
||||||
my $ar = shift;
|
|
||||||
my $libdll = File::Spec->rel2abs(shift @ARGV);
|
|
||||||
my $lib = File::Spec->rel2abs(pop @ARGV);
|
|
||||||
|
|
||||||
open my $nm_fd, '-|', $nm, '-Ap', '--defined-only', @ARGV, $libdll or
|
my $libdll = shift;
|
||||||
|
my $lib = pop;
|
||||||
|
|
||||||
|
open my $nm_fd, '-|', $nm, '-Apg', '--defined-only', @ARGV, $libdll or
|
||||||
die "$0: execution of $nm for object files failed - $!\n";
|
die "$0: execution of $nm for object files failed - $!\n";
|
||||||
|
|
||||||
my %match_syms = ();
|
my %match_syms = ();
|
||||||
my $symfiles = ();
|
my $symfiles = ();
|
||||||
my $lastfn;
|
my $lastfn;
|
||||||
my %extract = ();
|
my %extract = ();
|
||||||
|
my $exclude_regex = @exclude ? join('|', @exclude) : '\\UnLiKeLy//';
|
||||||
|
$exclude_regex = qr/$exclude_regex/;
|
||||||
while (<$nm_fd>) {
|
while (<$nm_fd>) {
|
||||||
study;
|
study;
|
||||||
m%^\Q$libdll\E:([^:]*):\d+ i \.idata\$([56])% and do {
|
my ($file, $member, $symbol) = m%^([^:]*):([^:]*(?=:))?.* T (.*)%o;
|
||||||
next;
|
next if !defined($symbol) || $symbol =~ $exclude_regex;
|
||||||
};
|
if ($file ne $libdll) {
|
||||||
m%^\Q$libdll\E:[^:]*:\d+ I (__head_.*)$% and do {
|
$match_syms{$symbol} = 1;
|
||||||
next;
|
} elsif ($match_syms{$symbol} ? !$inverse : $inverse) {
|
||||||
};
|
$extract{$member} = 1;
|
||||||
next unless m%^([^:]*):([^:]*(?=:))?.* [DTI] (.*)%o;
|
|
||||||
if ($1 ne $libdll) {
|
|
||||||
$match_syms{$3} = 1;
|
|
||||||
} elsif ($match_syms{$3} ? !$exclude : $exclude) {
|
|
||||||
$extract{$2} = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close $nm_fd;
|
close $nm_fd;
|
||||||
|
|
Loading…
Reference in New Issue