Mark Wielaard e86763b
commit 3bdc16ce98295463c071192eab2ec611a8edc508
Mark Wielaard e86763b
Author: Mark Wielaard <mjw@redhat.com>
Mark Wielaard e86763b
Date:   Wed Feb 6 16:20:17 2013 +0100
Mark Wielaard e86763b
Mark Wielaard e86763b
    elflint: Add two more symbols to gnuld list of allowed bad values.
Mark Wielaard e86763b
    
Mark Wielaard e86763b
    Add __bss_start and __TMC_END__ to the list of symbols allowed to have
Mark Wielaard e86763b
    out of section values because of the following GNU ld bug:
Mark Wielaard e86763b
    http://sourceware.org/bugzilla/show_bug.cgi?id=13621.
Mark Wielaard e86763b
    Allow them to appear in either .symtab or .dynsym, but only when they
Mark Wielaard e86763b
    are zero sized. It is impossible to define a general rule for this bug,
Mark Wielaard e86763b
    but this should catch most common issues that are mostly harmless
Mark Wielaard e86763b
    because the symbols signify the removed section was empty to being with.
Mark Wielaard e86763b
    This catches at least all symbols often flagged in the tests.
Mark Wielaard e86763b
    
Mark Wielaard e86763b
    Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard e86763b
Mark Wielaard e86763b
diff --git a/src/ChangeLog b/src/ChangeLog
Mark Wielaard e86763b
index f3f9b51..7d7b66f 100644
Mark Wielaard e86763b
--- a/src/ChangeLog
Mark Wielaard e86763b
+++ b/src/ChangeLog
Mark Wielaard e86763b
@@ -1,3 +1,10 @@
Mark Wielaard e86763b
+2013-02-06  Mark Wielaard  <mjw@redhat.com>
Mark Wielaard 2a5e99f
+
Mark Wielaard e86763b
+	* elflint.c (check_symtab): Add __bss_start and __TMC_END__ to the
Mark Wielaard e86763b
+	list of symbols allowed to have out of section values because of
Mark Wielaard e86763b
+	GNU ld bugs in either .symtab or .dynsym, but only when they are
Mark Wielaard e86763b
+	zero sized.
Mark Wielaard e86763b
+
Mark Wielaard e86763b
 2012-08-27  Mark Wielaard  <mjw@redhat.com>
Mark Wielaard e86763b
 
Mark Wielaard e86763b
 	* readelf.c (print_debug_macro_section): Print offset as PRIx64.
Mark Wielaard e86763b
diff --git a/src/elflint.c b/src/elflint.c
Mark Wielaard e86763b
index 4084987..bc5ed33 100644
Mark Wielaard e86763b
--- a/src/elflint.c
Mark Wielaard e86763b
+++ b/src/elflint.c
Mark Wielaard e86763b
@@ -767,15 +767,22 @@ section [%2d] '%s': symbol %zu: function in COMMON section is nonsense\n"),
Mark Wielaard e86763b
 			{
Mark Wielaard e86763b
 			  /* GNU ld has severe bugs.  When it decides to remove
Mark Wielaard e86763b
 			     empty sections it leaves symbols referencing them
Mark Wielaard e86763b
-			     behind.  These are symbols in .symtab.  */
Mark Wielaard e86763b
+			     behind.  These are symbols in .symtab or .dynsym
Mark Wielaard e86763b
+			     and for the named symbols have zero size.  See
Mark Wielaard e86763b
+			     sourceware PR13621.  */
Mark Wielaard e86763b
 			  if (!gnuld
Mark Wielaard e86763b
-			      || strcmp (section_name (ebl, idx), ".symtab")
Mark Wielaard e86763b
+			      || (strcmp (section_name (ebl, idx), ".symtab")
Mark Wielaard e86763b
+			          && strcmp (section_name (ebl, idx),
Mark Wielaard e86763b
+					     ".dynsym"))
Mark Wielaard e86763b
+			      || sym->st_size != 0
Mark Wielaard e86763b
 			      || (strcmp (name, "__preinit_array_start") != 0
Mark Wielaard e86763b
 				  && strcmp (name, "__preinit_array_end") != 0
Mark Wielaard e86763b
 				  && strcmp (name, "__init_array_start") != 0
Mark Wielaard e86763b
 				  && strcmp (name, "__init_array_end") != 0
Mark Wielaard e86763b
 				  && strcmp (name, "__fini_array_start") != 0
Mark Wielaard e86763b
-				  && strcmp (name, "__fini_array_end") != 0))
Mark Wielaard e86763b
+				  && strcmp (name, "__fini_array_end") != 0
Mark Wielaard e86763b
+				  && strcmp (name, "__bss_start") != 0
Mark Wielaard e86763b
+				  && strcmp (name, "__TMC_END__") != 0))
Mark Wielaard e86763b
 			    ERROR (gettext ("\
Mark Wielaard e86763b
 section [%2d] '%s': symbol %zu: st_value out of bounds\n"),
Mark Wielaard e86763b
 				   idx, section_name (ebl, idx), cnt);