This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Linker is broken
On Wed, May 26, 2004 at 04:22:14PM +0930, Alan Modra wrote:
> Probably my SEC_EXCLUDE linker patch. Looking..
This fixes the ld -r problem with SEC_GROUP and SEC_EXCLUDE. I'm not
committing it just yet because I'm worried that there might be other
ld -r situations that are broken too. I intend to do some digging
into why lang_add_section ignores SEC_EXCLUDE in some cases for
relocatable links. It would be nicer if SEC_EXCLUDE always meant
drop this section..
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.228
diff -u -p -r1.228 elf.c
--- bfd/elf.c 25 May 2004 06:33:46 -0000 1.228
+++ bfd/elf.c 26 May 2004 07:26:33 -0000
@@ -677,7 +677,7 @@ _bfd_elf_make_section_from_shdr (bfd *ab
if (hdr->sh_type != SHT_NOBITS)
flags |= SEC_HAS_CONTENTS;
if (hdr->sh_type == SHT_GROUP)
- flags |= SEC_GROUP | SEC_EXCLUDE;
+ flags |= SEC_GROUP;
if ((hdr->sh_flags & SHF_ALLOC) != 0)
{
flags |= SEC_ALLOC;
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.148
diff -u -p -r1.148 ldlang.c
--- ld/ldlang.c 25 May 2004 06:33:50 -0000 1.148
+++ ld/ldlang.c 26 May 2004 07:26:36 -0000
@@ -1096,11 +1096,12 @@ lang_add_section (lang_statement_list_ty
discard = FALSE;
- /* Discard sections marked with SEC_EXCLUDE if we are doing a final
- link. Discard debugging sections marked with SEC_EXCLUDE on a
- relocatable link too. */
- if ((flags & SEC_EXCLUDE) != 0
- && ((flags & SEC_DEBUGGING) != 0 || !link_info.relocatable))
+ /* Discard sections marked with SEC_EXCLUDE or SEC_GROUP if we are
+ doing a final link. Discard debugging sections marked with
+ SEC_EXCLUDE on a relocatable link too. */
+ if (((flags & (SEC_EXCLUDE | SEC_GROUP)) != 0 && !link_info.relocatable)
+ || ((flags & (SEC_EXCLUDE | SEC_DEBUGGING))
+ == (SEC_EXCLUDE | SEC_DEBUGGING)))
discard = TRUE;
/* Discard input sections which are assigned to a section named
--
Alan Modra
IBM OzLabs - Linux Technology Centre