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]

Re: ld bug?


On Tue, Aug 05, 2003 at 10:59:09AM -0400, Michal Ostrowski wrote:
> Hi,
> 
> I have a bunch of object files that when linked together (to build
> "troff") result in certain symbols being assigned the same location in
> memory.
> 
> This was achieved with gcc-3.2.3 (c++) and,
> 
> powerpc64-linux-ld -v
> GNU ld version 2.14.90 20030805
> 
> The problem is that we have a couple of symbols as follow:
> 
>   84: 0000000020015c10     8 NOTYPE  LOCAL  DEFAULT   26 soft_hyphen_char
> 2986: 0000000020015c18     8 NOTYPE  GLOBAL DEFAULT   26 global_special_fonts
> 
> 
> However, we also have (from .rela.dyn):
> 000020015c10  004700000013 R_PPC_COPY        0000000020015c10 _ZTVN10__cxxabiv117__c + 0
> 
> This causes ld.so to copy 88 bytes of data to the location of
> soft_hyphen_char (and the symbols that follow it).
[snip]

Hmm, yes.  A ld map shows

.bss            0x0000000010085b30     0x4248
 *(.dynbss)
 *fill*         0x0000000010085b30        0x0 00
 *(.bss .bss.* .gnu.linkonce.b.*)
 .bss           0x0000000010085b30        0x1 ./crtbegin.o
 *fill*         0x0000000010085b31        0x7 00
 .bss           0x0000000010085b38       0xc8 ./env.o

Note the zero .dynbss allocation.  It should be 312 bytes in this case.

The problem was uncoverd by this patch:

2003-07-10  Alan Modra  <amodra@bigpond.net.au>
	(ppc64_elf_build_stubs): Check for stub sections in stub bfd by
	testing section flags.

Fixed like this.

	* elflink.c (_bfd_elf_create_dynamic_sections): Mark .dynbss with
	SEC_LINKER_CREATED.

Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.42
diff -u -p -r1.42 elflink.c
--- bfd/elflink.c	4 Aug 2003 09:39:46 -0000	1.42
+++ bfd/elflink.c	6 Aug 2003 01:22:35 -0000
@@ -309,7 +309,7 @@ _bfd_elf_create_dynamic_sections (bfd *a
 	 section into the .bss section of the final image.  */
       s = bfd_make_section (abfd, ".dynbss");
       if (s == NULL
-	  || ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
+	  || ! bfd_set_section_flags (abfd, s, SEC_ALLOC | SEC_LINKER_CREATED))
 	return FALSE;
 
       /* The .rel[a].bss section holds copy relocs.  This section is not

-- 
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]