Symbols in SHT_NULL sections

Paul Brook paul@codesourcery.com
Sun Feb 6 07:01:00 GMT 2005


I have some third party elf object files which contain section headers with 
type SHT_NULL, and define symbols within those sections.

It's not clear that these symbols have any meaningful interpretation, however 
they cause ld to crash. The attached patch fixes this by discarding these 
symbols.

Tested on i686-linux --enable-targets=all.
Ok?

Paul

2005-02-03  Paul Brook  <paul@codesourcery.com>

 * elflink.c (elf_link_input_bfd): Ignore symbols from null input
 sections.
Index: elflink.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/bfd/elflink.c,v
retrieving revision 1.126
diff -u -p -r1.126 elflink.c
--- elflink.c	1 Feb 2005 01:11:14 -0000	1.126
+++ elflink.c	3 Feb 2005 19:32:14 -0000
@@ -6757,8 +6757,8 @@ elf_link_input_bfd (struct elf_final_lin
 	 For the benefit of the MIPS ELF linker, we check SEC_EXCLUDE
 	 as well as linker_mark.  */
       if ((isym->st_shndx < SHN_LORESERVE || isym->st_shndx > SHN_HIRESERVE)
-	  && isec != NULL
-	  && ((! isec->linker_mark && (isec->flags & SEC_HAS_CONTENTS) != 0)
+	  && (isec == NULL
+	      || (! isec->linker_mark && (isec->flags & SEC_HAS_CONTENTS) != 0)
 	      || (! finfo->info->relocatable
 		  && (isec->flags & SEC_EXCLUDE) != 0)))
 	continue;


More information about the Binutils mailing list