qemu: Rework qemuDomainDeviceDefValidateAddress()
[libvirt/ericb.git] / src / check-symfile.pl
blob4f88300864b74ab9617779c831e884eedc50c417
1 #!/usr/bin/env perl
3 # Copyright (C) 2012-2013 Red Hat, Inc.
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library. If not, see
17 # <http://www.gnu.org/licenses/>.
19 die "syntax: $0 SYMFILE ELFLIB(S)" unless int(@ARGV) >= 2;
21 my $symfile = shift @ARGV;
22 my @elflibs = @ARGV;
24 my %wantsyms;
25 my %gotsyms;
27 my $ret = 0;
29 open SYMFILE, $symfile or die "cannot read $symfile: $!";
31 while (<SYMFILE>) {
32 next if /{/;
33 next if /}/;
34 next if /global:/;
35 next if /local:/;
36 next if /^\s*$/;
37 next if /^\s*#/;
38 next if /\*/;
40 die "malformed line $_" unless /^\s*(\S+);$/;
42 if (exists $wantsyms{$1}) {
43 print STDERR "Symbol $1 is listed twice\n";
44 $ret = 1;
45 } else {
46 $wantsyms{$1} = 1;
49 close SYMFILE;
51 foreach my $elflib (@elflibs) {
52 open NM, "-|", "nm", $elflib or die "cannot run 'nm $elflib': $!";
54 while (<NM>) {
55 next unless /^\S+\s(?:[TBD])\s(\S+)\s*$/;
57 $gotsyms{$1} = 1;
60 close NM;
63 foreach my $sym (keys(%wantsyms)) {
64 next if exists $gotsyms{$sym};
66 print STDERR "Expected symbol $sym is not in ELF library\n";
67 $ret = 1;
70 exit($ret);