This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

--gc-sections removes too many sections


Sections like .comment and .note.GNU-stack shouldn't be removed by
--gc-sections.  Noticed when looking at the ppc64 --gc-sections
problem.

	* elflink.h (elf_gc_sweep): Keep non-alloc, non-load sections.

Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.95
diff -u -p -r1.95 elflink.c
--- bfd/elflink.c	16 Aug 2004 01:17:58 -0000	1.95
+++ bfd/elflink.c	17 Aug 2004 08:22:39 -0000
@@ -8504,9 +8504,9 @@ elf_gc_sweep (struct bfd_link_info *info
 
       for (o = sub->sections; o != NULL; o = o->next)
 	{
-	  /* Keep special sections.  Keep .debug sections.  */
-	  if ((o->flags & SEC_LINKER_CREATED)
-	      || (o->flags & SEC_DEBUGGING))
+	  /* Keep debug and special sections.  */
+	  if ((o->flags & (SEC_DEBUGGING | SEC_LINKER_CREATED)) != 0
+	      || (o->flags & (SEC_ALLOC | SEC_LOAD)) == 0)
 	    o->gc_mark = 1;
 
 	  if (o->gc_mark)

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]