summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2009-03-28 04:55:36 +0000
committerChristopher Faylor <me@cgf.cx>2009-03-28 04:55:36 +0000
commit03905921408556757f61119cfc4464fd74488f60 (patch)
treeaee027323613b41e1654a888410d066b29a3a4cc
parent6f0c3cc88a2818a14b222c7e0abdfb1f944ef863 (diff)
downloadcygnal-03905921408556757f61119cfc4464fd74488f60.tar.gz
cygnal-03905921408556757f61119cfc4464fd74488f60.tar.bz2
cygnal-03905921408556757f61119cfc4464fd74488f60.zip
* Makefile.in: Perform some minor cleanup. Revamp speclib handling.
* speclib: Rewrite to create libraries with dlltool rather than attempting surgery on libcygwin.a.
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/Makefile.in40
-rwxr-xr-xwinsup/cygwin/speclib111
3 files changed, 60 insertions, 97 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 47525aea8..74d6fd353 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,9 @@
+2009-03-28 Christopher Faylor <me+cygwin@cgf.cx>
+
+ * Makefile.in: Perform some minor cleanup. Revamp speclib handling.
+ * speclib: Rewrite to create libraries with dlltool rather than
+ attempting surgery on libcygwin.a.
+
2009-03-27 Corinna Vinschen <corinna@vinschen.de>
* net.cc (inet_ntop6): Convert to lowercase hex digits on the fly.
diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index f10cbc624..f5e1784e0 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -15,7 +15,7 @@ srcdir:=@srcdir@
objdir:=.
CONFIG_DIR:=$(srcdir)/config/@CONFIG_DIR@
-VPATH:=$(srcdir):$(CONFIG_DIR):$(srcdir)/regex:$(srcdir)/regexp:$(srcdir)/lib:$(srcdir)/libc
+VPATH:=$(srcdir):$(CONFIG_DIR):$(srcdir)/regex:$(srcdir)/lib:$(srcdir)/libc
target_alias:=@target_alias@
build_alias:=@build_alias@
@@ -72,7 +72,6 @@ OBJDUMP:=@OBJDUMP@
STRIP:=@STRIP@
LDSCRIPT:=cygwin.sc
MKDIRP:=$(INSTALL) -m 755 -d
-
#
# Include common definitions for winsup directory
#
@@ -106,6 +105,8 @@ LIBGMON_A:=libgmon.a
CYGWIN_START:=crt0.o
GMON_START:=gcrt0.o
+speclib=${word 1, $^} "${NM}" "$(DLLTOOL)" $(wordlist 2, $(words $^), $^)
+
# 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
# include them directly into the library.
@@ -225,10 +226,9 @@ NEW_FUNCTIONS:=open _open64 \
API_VER:=$(srcdir)/include/cygwin/version.h
-PWD:=${shell pwd}
-LIB_NAME:=$(PWD)/libcygwin.a
+LIB_NAME:=libcygwin.a
LIBSERVER:=@LIBSERVER@
-SUBLIBS:=$(PWD)/libpthread.a $(PWD)/libutil.a $(PWD)/libm.a $(PWD)/libc.a $(PWD)/libdl.a $(PWD)/libresolv.a
+SUBLIBS:=libpthread.a libutil.a ${CURDIR}/libm.a ${CURDIR}/libc.a libdl.a libresolv.a
EXTRALIBS:=libautomode.a libbinmode.a libtextmode.a libtextreadmode.a
INSTOBJS:=automode.o binmode.o textmode.o textreadmode.o
TARGET_LIBS:=$(LIB_NAME) $(CYGWIN_START) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $(INSTOBJS) $(EXTRALIBS)
@@ -407,7 +407,6 @@ ${STATIC_LIB_NAME}: mkstatic ${TEST_DLL_NAME}
# Rule to make stub library used by testsuite
# dependency set to $(LIB_NAME) to accommodate make -j2.
-# Otherwise dlltool gets confused. cgf (11-16-2000)
$(TEST_LIB_NAME): $(LIB_NAME)
perl -p -e 'BEGIN{binmode(STDIN); binmode(STDOUT);}; s/cygwin1/cygwin0/g' < $? > $@
@@ -440,31 +439,28 @@ dcrt0.o sigproc.o: child_info_magic.h
shared.o: shared_info_magic.h
-$(srcdir)/qevices.cc: cygwin-gperf devices.gperf devices.h
- $^ > $@
-
$(srcdir)/devices.cc: gendevices devices.in devices.h
${wordlist 1,2,$^} $@
-$(PWD)/libpthread.a: speclib $(LIB_NAME) pthread.o thread.o
- ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
+${CURDIR}/libc.a: speclib ${DEF_FILE} ./libm.a libpthread.a libutil.a
+ ${speclib} -v ${@F}
-$(PWD)/libutil.a: speclib $(LIB_NAME) bsdlib.o
- ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
+${CURDIR}/libm.a: speclib ${DEF_FILE} $(LIBM)
+ ${speclib} ${@F}
-$(PWD)/libm.a: speclib $(LIB_NAME) $(LIBM)
- ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
+libpthread.a: speclib ${DEF_FILE} pthread.o thread.o
+ ${speclib} ${@F}
-$(PWD)/libc.a: speclib $(LIB_NAME) $(PWD)/libm.a libpthread.a libutil.a
- ${word 1, $^} -v $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
+libutil.a: speclib ${DEF_FILE} bsdlib.o
+ ${speclib} ${@F}
-$(PWD)/libdl.a: speclib $(LIB_NAME) dlfcn.o
- ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
+libdl.a: speclib ${DEF_FILE} dlfcn.o
+ ${speclib} ${@F}
-$(PWD)/libresolv.a: speclib $(LIB_NAME) minires.o
- ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
+libresolv.a: speclib ${DEF_FILE} minires.o
+ ${speclib} ${@F}
-lib%.a: %.o
+${EXTRALIBS}: lib%.a: %.o
$(AR) cru $@ $?
winver_stamp: mkvers.sh include/cygwin/version.h winver.rc $(DLL_OFILES)
diff --git a/winsup/cygwin/speclib b/winsup/cygwin/speclib
index 5f73fed75..bea9cbc4a 100755
--- a/winsup/cygwin/speclib
+++ b/winsup/cygwin/speclib
@@ -4,88 +4,49 @@ use File::Temp qw'tempdir';
use File::Basename;
use strict;
-sub dllname($;$);
-
-my $verbose;
-my $static;
-my $exclude;
-
-GetOptions('static!'=>\$static, 'v|exclude!'=>\$exclude);
-
-my $lib = shift;
my $nm = shift;
-my $ar = shift;
-my $libdll = shift;
+my $dlltool = shift;
+my $def = shift;
+my $lib = pop;
+
+my $inverse;
+if ($ARGV[$#ARGV] ne '-v') {
+ $inverse = 0;
+} else {
+ $inverse = 1;
+ $#ARGV--;
+}
-open my $nm_fd, '-|', $nm, '-Ap', '--defined-only', @ARGV, $libdll or
+open my $def_fd, '<', $def or die "$0: couldn't open \"$def\" - $!\n";
+my %defsyms = ();
+my $newdef = '';
+while (<$def_fd>) {
+ if (/^\s*(?:EXPORTS\b|LIBRARY\b|\s*$)/o) {
+ $newdef .= $_;
+ } else {
+ my $sym = (split ' ')[0];
+ $defsyms{$sym} = $_;
+ }
+}
+close $def_fd;
+
+open my $nm_fd, '-|', $nm, '-pg', '--defined-only', @ARGV or
die "$0: execution of $nm for object files failed - $!\n";
-my %match_syms = ();
-my $symfiles = ();
-my $lastfn;
-my @headtail = ();
-my %extract = ();
-my $libdllname;
while (<$nm_fd>) {
- study;
- m%^\Q$libdll\E:([^:]*):\d+ i \.idata\$([56])% and do {
- if ($2 eq 5) {
- push @headtail, $1;
- } else {
- pop @headtail;
- }
- next;
- };
- m%^\Q$libdll\E:[^:]*:\d+ I (__head_.*)$% and do {
- $libdllname = $1;
- next;
- };
- next unless m%^([^:]*):([^:]*(?=:))?.* [DTI] (.*)%o;
- if ($1 ne $libdll) {
- $match_syms{$3} = 1;
- } elsif ($match_syms{$3} ? !$exclude : $exclude) {
- $extract{$2} = 1;
- }
+ next unless /\S+\s+[A-Z]+\s+_(.*)$/o;
+ if ($inverse) {
+ delete $defsyms{$1};
+ } else {
+ $newdef .= $defsyms{$1} if exists $defsyms{$1};
+ }
}
close $nm_fd;
-%extract or die "$0: couldn't find symbols for $lib\n";
-defined($libdllname) or die "$0: couldn't determine __head_<NAME> - malformed import archive?\n";
-for (@headtail) {
- $extract{$_} = 1;
-}
-
-my $dir = tempdir(CLEANUP => 1);
+$newdef .= join '', sort values %defsyms if $inverse;
-chdir $dir;
-# print join(' ', '+', $ar, 'x', sort keys %extract), "\n";
-my $res = system $ar, 'x', $libdll, sort keys %extract;
-die "$0: $ar extraction exited with non-zero status\n" if $res;
-unlink $lib;
-$res = system $ar, 'crus', $lib, sort keys %extract;
-die "$0: $ar creation exited with non-zero status\n" if $res;
-
-open my $lib_fd, '<', $lib or die "$0: couldn't open $lib for input - $!\n";
-binmode $lib_fd;
-
-my $libname = dllname($lib, 'lib');
-my $pad = length($libdllname) - length($libname);
-die "$0: library name too long (" . length($libname) . ")\n" if $pad < 0;
-$libname .= "\0" x $pad;
-
-$res = sysread($lib_fd, $_, -s $lib);
-close $lib_fd;
-
-die "$0: couldn't read $lib - $!\n" if $res != -s _;
-0 while s/$libdllname/$libname/sog;
-
-open $lib_fd, '>', $lib or die "$0: couldn't open $lib for output - $!\n";
-syswrite($lib_fd, $_) == length($_) or die "$0: write to $lib failed - $!\n";
-close $lib_fd;
+open my $dlltool_fd, '|-', $dlltool, '-d', '/proc/self/fd/0', '-D', 'cygwin1.dll', '-l', $lib or
+ die "$0: couldn't start dlltool - $dlltool - $!\n";
+print $dlltool_fd $newdef;
+close $dlltool_fd or exit 1;
exit 0;
-
-sub dllname($;$) {
- my $x = basename($_[0], '.a');
- $x =~ s/^lib//o;
- return '__head_' . $_[1] . $x;
-}