This is the mail archive of the binutils@sourceware.cygnus.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]

Re: [patch] Linker section contents not allocated (was: Re: Patch for ppc _SDA_BASE_ value)


Momchil Velikov wrote:
> 
> Hi,
> 
> The linker gets a fatal signal in finish_pointer_linker_section, because
> the section contents is not allocated. This patch creates the
> linker sections with the SEC_LINKER_CREATED flags set, so their contents
> is allocated in `ppc_elf_size_dynamic_sections'.
> 
> Demo:
> 
> $ cat > xx.s
>         .data
>         .global var
> var:
>         .long 0
> 
>         .text
>         .global foo
> foo:
>         lwz     %r3, var@sdai16(%r13)
> $ powerpc-svr4-gcc -c xx.s
> $ powerpc-svr4-ld -o xx -entry=foo xx.o
> Segmentation fault
> $

Oops, wrong files, here are the correct ones.

-velco
2000-04-01  Momchil Velikov  <velco@fadata.bg>

	* elf32-ppc.c (ppc_elf_create_linker_section): Create the linker
	sections with `SEC_LINKER_CREATED' flag set, so their contents
	is allocated in `ppc_elf_size_dynamic_sections'. 

--- elf32-ppc.c.orig.2	Sat Apr  1 15:15:50 2000
+++ elf32-ppc.c	Sat Apr  1 15:16:07 2000
@@ -1561,16 +1561,17 @@
       defaults.hole_written_p = false;
       defaults.alignment = 2;
 
-      /* Both of these sections are (technically) created by the user
-	 putting data in them, so they shouldn't be marked
-	 SEC_LINKER_CREATED.
+      /* Both of these sections should be marked SEC_LINKER_CREATED
+	 so their contents is allocated in ppc_elf_size_dynamic_sections.  
 
 	 The linker creates them so it has somewhere to attach their
 	 respective symbols. In fact, if they were empty it would
 	 be OK to leave the symbol set to 0 (or any random number), because
-	 the appropriate register should never be used.  */
+	 the appropriate register should never be used.  
+	 Also, the implicit symbol pointer entries for R_PPC_EMB_SDAI16
+	 and R_PPC_EMB_SDA2I16 relocations are put there.  */
       defaults.flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-			| SEC_IN_MEMORY);
+			| SEC_IN_MEMORY | SEC_LINKER_CREATED);
 
       switch (which)
 	{

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