2017-09-18 12:35:50 +00:00
|
|
|
#!/usr/bin/env perl
|
2012-07-24 13:37:48 +00:00
|
|
|
|
2013-05-14 23:42:12 +00:00
|
|
|
# Copyright (C) 2012-2013 Red Hat, Inc.
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library. If not, see
|
|
|
|
# <http://www.gnu.org/licenses/>.
|
|
|
|
|
2012-07-24 13:37:48 +00:00
|
|
|
die "syntax: $0 SYMFILE ELFLIB(S)" unless int(@ARGV) >= 2;
|
|
|
|
|
|
|
|
my $symfile = shift @ARGV;
|
|
|
|
my @elflibs = @ARGV;
|
|
|
|
|
2012-09-06 14:45:57 +00:00
|
|
|
my %wantsyms;
|
2012-07-24 13:37:48 +00:00
|
|
|
my %gotsyms;
|
|
|
|
|
2012-09-06 14:45:57 +00:00
|
|
|
my $ret = 0;
|
|
|
|
|
2012-07-24 13:37:48 +00:00
|
|
|
open SYMFILE, $symfile or die "cannot read $symfile: $!";
|
|
|
|
|
|
|
|
while (<SYMFILE>) {
|
|
|
|
next if /{/;
|
|
|
|
next if /}/;
|
|
|
|
next if /global:/;
|
|
|
|
next if /local:/;
|
|
|
|
next if /^\s*$/;
|
|
|
|
next if /^\s*#/;
|
|
|
|
next if /\*/;
|
|
|
|
|
|
|
|
die "malformed line $_" unless /^\s*(\S+);$/;
|
|
|
|
|
2012-09-06 14:45:57 +00:00
|
|
|
if (exists $wantsyms{$1}) {
|
2012-09-06 15:42:35 +00:00
|
|
|
print STDERR "Symbol $1 is listed twice\n";
|
|
|
|
$ret = 1;
|
2012-09-06 14:45:57 +00:00
|
|
|
} else {
|
2012-09-06 15:42:35 +00:00
|
|
|
$wantsyms{$1} = 1;
|
2012-09-06 14:45:57 +00:00
|
|
|
}
|
2012-07-24 13:37:48 +00:00
|
|
|
}
|
|
|
|
close SYMFILE;
|
|
|
|
|
|
|
|
foreach my $elflib (@elflibs) {
|
|
|
|
open NM, "-|", "nm", $elflib or die "cannot run 'nm $elflib': $!";
|
|
|
|
|
|
|
|
while (<NM>) {
|
2017-07-12 10:07:17 +00:00
|
|
|
next unless /^\S+\s(?:[TBD])\s(\S+)\s*$/;
|
2012-07-24 13:37:48 +00:00
|
|
|
|
2012-07-27 12:51:28 +00:00
|
|
|
$gotsyms{$1} = 1;
|
2012-07-24 13:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
close NM;
|
|
|
|
}
|
|
|
|
|
2012-10-05 12:57:36 +00:00
|
|
|
foreach my $sym (keys(%wantsyms)) {
|
2012-07-24 13:37:48 +00:00
|
|
|
next if exists $gotsyms{$sym};
|
|
|
|
|
|
|
|
print STDERR "Expected symbol $sym is not in ELF library\n";
|
|
|
|
$ret = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit($ret);
|