Set SEC_EXCLUDE for .gnu.warning* sections

Alan Modra amodra@bigpond.net.au
Tue Mar 22 16:59:00 GMT 2005


Symbols defined in these sections are useless IMO, and confusing.
glibc tends to define __evoke_linker_warning_* as the array holding the
warning message, and this symbol gets copied to the output.  That would
be OK if the warning section was also copied to the output, but it
isn't.  Which results in object symbols with non-zero size overlapping
other sections.

bfd/
	* elflink.c (elf_link_add_object_symbols): Set SEC_EXCLUDE on
	.gnu.warning.* sections.
ld/
	* emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Set
	SEC_EXCLUDE on .gnu.warning sections.

Applying mainline and branch.

Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.140
diff -u -p -r1.140 elflink.c
--- bfd/elflink.c	18 Mar 2005 23:51:21 -0000	1.140
+++ bfd/elflink.c	22 Mar 2005 10:02:49 -0000
@@ -3240,6 +3240,10 @@ elf_link_add_object_symbols (bfd *abfd, 
 		  /* Clobber the section size so that the warning does
 		     not get copied into the output file.  */
 		  s->size = 0;
+
+		  /* Also set SEC_EXCLUDE, so that symbols defined in
+		     the warning section don't get copied to the output.  */
+		  s->flags |= SEC_EXCLUDE;
 		}
 	    }
 	}
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.133
diff -u -p -r1.133 elf32.em
--- ld/emultempl/elf32.em	18 Mar 2005 15:56:27 -0000	1.133
+++ ld/emultempl/elf32.em	22 Mar 2005 10:03:09 -0000
@@ -1105,6 +1105,10 @@ ${ELF_INTERPRETER_SET_DEFAULT}
 	/* Clobber the section size, so that we don't waste copying the
 	   warning into the output file.  */
 	s->size = 0;
+
+	/* Also set SEC_EXCLUDE, so that symbols defined in the warning
+	   section don't get copied to the output.  */
+	s->flags |= SEC_EXCLUDE;
       }
   }
 }

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list