diff options
Diffstat (limited to 'conform/linknamespace.pl')
-rw-r--r-- | conform/linknamespace.pl | 51 |
1 files changed, 22 insertions, 29 deletions
diff --git a/conform/linknamespace.pl b/conform/linknamespace.pl index 15fa6134ab..4b7b288165 100644 --- a/conform/linknamespace.pl +++ b/conform/linknamespace.pl @@ -1,10 +1,10 @@ -#! /usr/bin/perl +#!/usr/bin/perl # Check that use of symbols declared in a given header does not result # in any symbols being brought in that are not reserved with external # linkage for the given standard. -# Copyright (C) 2014-2015 Free Software Foundation, Inc. +# Copyright (C) 2014-2016 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -40,8 +40,6 @@ close (STDSYMS) || die ("close $stdsyms_file: $!\n"); # The following whitelisted symbols are also allowed for now. # -# * Bug 15421: lgamma wrongly sets signgam for ISO C. -# # * Bug 17576: stdin, stdout, stderr only reserved with external # linkage when stdio.h included (and possibly not then), not # generally. @@ -52,7 +50,7 @@ close (STDSYMS) || die ("close $stdsyms_file: $!\n"); # * False positive: matherr only used conditionally. matherrf/matherrl are used # by IA64 too for the same reason. # -@whitelist = qw(signgam stdin stdout stderr re_syntax_options matherr matherrf +@whitelist = qw(stdin stdout stderr re_syntax_options matherr matherrf matherrl); foreach my $sym (@whitelist) { $stdsyms{$sym} = 1; @@ -97,8 +95,8 @@ sub list_syms { # Load information about GLOBAL and WEAK symbols defined or used in # the standard libraries. -# Strong symbols (defined or undefined) from a given object. -%strong_syms = (); +# Symbols from a given object, except for weak defined symbols. +%seen_syms = (); # Strong undefined symbols from a given object. %strong_undef_syms = (); # Objects defining a given symbol (strongly or weakly). @@ -112,17 +110,17 @@ foreach my $sym (@sym_data) { } push (@{$sym_objs{$name}}, $file); } - if ($bind eq "GLOBAL") { - if (!defined ($strong_syms{$file})) { - $strong_syms{$file} = []; + if ($bind eq "GLOBAL" || !$defined) { + if (!defined ($seen_syms{$file})) { + $seen_syms{$file} = []; } - push (@{$strong_syms{$file}}, $name); - if (!$defined) { - if (!defined ($strong_undef_syms{$file})) { - $strong_undef_syms{$file} = []; - } - push (@{$strong_undef_syms{$file}}, $name); + push (@{$seen_syms{$file}}, $name); + } + if ($bind eq "GLOBAL" && !$defined) { + if (!defined ($strong_undef_syms{$file})) { + $strong_undef_syms{$file} = []; } + push (@{$strong_undef_syms{$file}}, $name); } } @@ -132,12 +130,7 @@ foreach my $sym (@sym_data) { # The rules followed are heuristic and so may produce false positives # and false negatives. # -# * Weak undefined symbols are ignored; however, if a code path that -# references one (even just to check if its address is 0) is executed, -# that may conflict with a definition of that symbol in the user's -# program. -# -# * Strong undefined symbols are considered of signficance, but it is +# * All undefined symbols are considered of signficance, but it is # possible that (a) any standard library definition is weak, so can be # overridden by the user's definition, and (b) the symbol is only used # conditionally and not if the program is limited to standard @@ -192,14 +185,14 @@ unlink ($cincfile) || die ("unlink $cincfile: $!\n"); unlink ($cincfile_o) || die ("unlink $cincfile_o: $!\n"); unlink ($cincfile_sym) || die ("unlink $cincfile_sym: $!\n"); -%strong_seen = (); +%seen_where = (); %files_seen = (); %all_undef = (); %current_undef = (); foreach my $sym (@elf_syms) { my ($file, $name, $bind, $defined) = @$sym; if ($bind eq "GLOBAL" && !$defined) { - $strong_seen{$name} = "[initial] $name"; + $seen_where{$name} = "[initial] $name"; $all_undef{$name} = "[initial] $name"; $current_undef{$name} = "[initial] $name"; } @@ -213,9 +206,9 @@ while (%current_undef) { next; } $files_seen{$file} = 1; - foreach my $ssym (@{$strong_syms{$file}}) { - if (!defined ($strong_seen{$ssym})) { - $strong_seen{$ssym} = "$current_undef{$sym} -> [$file] $ssym"; + foreach my $ssym (@{$seen_syms{$file}}) { + if (!defined ($seen_where{$ssym})) { + $seen_where{$ssym} = "$current_undef{$sym} -> [$file] $ssym"; } } foreach my $usym (@{$strong_undef_syms{$file}}) { @@ -230,14 +223,14 @@ while (%current_undef) { } $ret = 0; -foreach my $sym (sort keys %strong_seen) { +foreach my $sym (sort keys %seen_where) { if ($sym =~ /^_/) { next; } if (defined ($stdsyms{$sym})) { next; } - print "$strong_seen{$sym}\n"; + print "$seen_where{$sym}\n"; $ret = 1; } |