This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
--gc-sections removes too many sections
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sources dot redhat dot com
- Date: Tue, 17 Aug 2004 17:57:04 +0930
- Subject: --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