diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2004-03-12 18:56:42 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2004-03-12 18:56:42 +0000 |
commit | bb9d76469ed0446dc5ee5ae4f03718ad09970b91 (patch) | |
tree | 85e02a26cd4ec9b4210f34a34a65a49e04cfb33e /Util | |
parent | 63d82fcbd27fb54b757e9ce2ae9830485446e227 (diff) | |
download | zsh-bb9d76469ed0446dc5ee5ae4f03718ad09970b91.tar.gz zsh-bb9d76469ed0446dc5ee5ae4f03718ad09970b91.tar.xz zsh-bb9d76469ed0446dc5ee5ae4f03718ad09970b91.zip |
zsh-users/7160: Check and fix mod_export entries.
Diffstat (limited to 'Util')
-rwxr-xr-x | Util/check_exports | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/Util/check_exports b/Util/check_exports new file mode 100755 index 000000000..7b56d3015 --- /dev/null +++ b/Util/check_exports @@ -0,0 +1,64 @@ +#!/usr/local/bin/perl -w + +# Attempt to scan executable, libraries, and .export files after +# a zsh build to see if all necessary symbols appear in the .export file +# (and hence with `mod_export' in the source file). This keeps AIX happy. +# Probably severely system dependent, but known to run on Fedora Core 1, +# at least. Not needed on AIX itself... you can tell if doesn't link. + +if (! -f "zsh") { + die "Can't file zsh, are we in the Src directory of the build?\n"; +} + +my (%defined, %undefined, %exported); + +foreach my $file ("zsh", glob("*.so */*.so")) { + next unless -f $file; + + my $exports = $file; + $exports =~ s/\.so//; + $exports .= ".export"; + if (-f $exports) { + open EXPORT, $exports or die "Can't read $exports: $!\n"; + my $href = $exported{$file} = { }; + while (<EXPORT>) { + next if /^#/; + chomp; + $href->{$_} = 1; + } + close EXPORT; + } else { + warn "Hmmm... no .exports file for $file\n"; + } + + open PIPE, "nm $file |" or die "Can't popen nm"; + while (<PIPE>) { + s/^[0-9a-f]*\s+//; + my ($type, $sym) = split; + # ignore local symbols (lower case) + if ($type =~ /^[TBAD]/) { + if (!defined $defined{$sym}) { + $defined{$sym} = $file; + } + } elsif ($type eq 'U') { + # could skip undefined from zsh and zsh.so, but what the heck + my $ref = \$undefined{$sym}; + if (defined $$ref) { + push @$$ref, $file; + } else { + $$ref = [ $file ]; + } + } + } + close PIPE or die "nm failed"; +} + +foreach $sym (keys %undefined) { + my $deffile = $defined{$sym}; + if (defined $deffile) { + if (!$exported{$deffile}{$sym}) { + printf "%-20s: %-20s: %s\n", $sym, $defined{$sym}, + join(" ", @{$undefined{$sym}}); + } + } +} |