From 33c1fbd68f77f0fa60283c0f42f1c820a8d1f11c Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Wed, 25 Jan 2006 06:35:19 +0000 Subject: Check the export lists against the newly built shared library to make sure all the symbols we want to export are actually defined. GNU/Linux only, for the moment, but it ought to work on any system using the GNU version of nm, and not too hard to modify for other ways of extracting the exported symbols of a library. * util/export-check.pl: New file. * config/shlib.conf (*-*-linux*): Run export-check.pl after building a shared library. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17609 dc483132-0cff-0310-8789-dd5450dbe970 --- src/config/ChangeLog | 3 +++ src/config/shlib.conf | 2 +- src/util/ChangeLog | 4 ++++ src/util/export-check.pl | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100755 src/util/export-check.pl diff --git a/src/config/ChangeLog b/src/config/ChangeLog index 6296210ad..5bfca9ee6 100644 --- a/src/config/ChangeLog +++ b/src/config/ChangeLog @@ -1,5 +1,8 @@ 2006-01-25 Ken Raeburn + * shlib.conf (*-*-linux*): Run export-check.pl after building a + shared library. + * lib.in (binutils.versions): Put hidden symbol list after exported list, because libkrb4 has a symbol starting with "__" in its export list. diff --git a/src/config/shlib.conf b/src/config/shlib.conf index 9d9a2066b..a7ec085c3 100644 --- a/src/config/shlib.conf +++ b/src/config/shlib.conf @@ -354,7 +354,7 @@ mips-*-netbsd*) # Use objdump -x to examine the fields of the library LDCOMBINE='$(CC) -shared -fPIC -Wl,-h,$(LIBPREFIX)$(LIBBASE)$(SHLIBSEXT)' # - LDCOMBINE_TAIL='-Wl,--version-script binutils.versions' + LDCOMBINE_TAIL='-Wl,--version-script binutils.versions && $(PERL) -w $(SRCTOP)/util/export-check.pl $(SHLIB_EXPORT_FILE) $@' SHLIB_EXPORT_FILE_DEP=binutils.versions # For cases where we do have dependencies on other libraries # built in this tree... diff --git a/src/util/ChangeLog b/src/util/ChangeLog index a306f5d92..b7c87caa5 100644 --- a/src/util/ChangeLog +++ b/src/util/ChangeLog @@ -1,3 +1,7 @@ +2006-01-25 Ken Raeburn + + * export-check.pl: New file. + 2005-12-22 Ken Raeburn * depfix.pl (uniquify): New subroutine. diff --git a/src/util/export-check.pl b/src/util/export-check.pl new file mode 100755 index 000000000..67c8e853d --- /dev/null +++ b/src/util/export-check.pl @@ -0,0 +1,55 @@ +# +$0 =~ s/^.*?([\w.-]+)$/$1/; + +# The real stuff. + +# Args: exportlist libfoo.so + +# This code assumes the GNU version of nm. +# For now, we'll only run it on GNU/Linux systems, so that's okay. + +if ($#ARGV != 1) { + die "usage: $0 exportfile libfoo.so\n"; +} +my($exfile, $libfile) = @ARGV; + +@missing = (); +open NM, "nm -Dg --defined-only $libfile |" || die "can't run nm on $libfile: $!"; +open EXPORT, "< $exfile" || die "can't read $exfile: $!"; + +@export = ; +map chop, @export; +@export = sort @export; + +@found = (); +while () { + chop; + s/^[0-9a-fA-F]+ +//; + next if /^A /; + if (!/^[TDRB] /) { + unlink $libfile; + die "not sure what to do with '$_'"; + } + s/^[TDRB] +//; + push @found, $_; +} +@found = sort @found; +while ($#export >= 0 && $#found >= 0) { + if ($export[0] eq $found[0]) { +# print "ok $export[0]\n"; + shift @export; + shift @found; + } elsif ($export[0] lt $found[0]) { + push @missing, shift @export; + } else { + # Ignore added symbols, for now. + shift @found; + } +} +if ($#export >= 0) { @missing = (@missing, @export); } +if ($#missing >= 0) { + print STDERR "Missing symbols:\n\t", join("\n\t", @missing), "\n"; +# unlink $libfile; + exit(1); +} +exit 0; -- cgit