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 scripts: overlay of input sections ???


On Wed, Jul 31, 2002 at 12:52:46PM +0200, Felix Shvaiger wrote:
> But for SBSS this does not work, becouse all "small uninitialized variables"
> __must__ be placed in output section named ".sbss".
> Otherwise link fails with "bla-bla in wrong section".

Try the following patch (totally untested, that's your job!)

	* elf32-ppc.c (ppc_elf_relocate_section): Allow ".sbss.*" and
	".sdata.*" for R_PPC_SDAREL16, ".sbss2*" and ".sdata2*" for
	R_PPC_EMB_SDA2REL.  Similarly for R_PPC_EMB_SDA21 and
	R_PPC_EMB_RELSDA.

This should allow you to use .sbss.board1, .sbss.board2.

Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.49
diff -u -p -r1.49 elf32-ppc.c
--- bfd/elf32-ppc.c	23 Jul 2002 12:29:32 -0000	1.49
+++ bfd/elf32-ppc.c	5 Aug 2002 02:33:36 -0000
@@ -3476,8 +3476,10 @@ ppc_elf_relocate_section (output_bfd, in
 
 	    BFD_ASSERT (sec != (asection *) 0);
 	    name = bfd_get_section_name (abfd, sec->output_section);
-	    if (strcmp (name, ".sdata") != 0
-		&& strcmp (name, ".sbss") != 0)
+	    if (! ((strncmp (name, ".sdata", 6) == 0
+		    && (name[6] == 0 || name[6] == '.'))
+		   || (strncmp (name, ".sbss", 5) == 0
+		       && (name[5] == 0 || name[5] == '.'))))
 	      {
 		(*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"),
 				       bfd_archive_filename (input_bfd),
@@ -3498,7 +3500,8 @@ ppc_elf_relocate_section (output_bfd, in
 
 	    BFD_ASSERT (sec != (asection *) 0);
 	    name = bfd_get_section_name (abfd, sec->output_section);
-	    if (strcmp (name, ".sdata2") != 0 && strcmp (name, ".sbss2") != 0)
+	    if (! (strncmp (name, ".sdata2", 7) == 0
+		   || strncmp (name, ".sbss2", 6) == 0))
 	      {
 		(*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"),
 				       bfd_archive_filename (input_bfd),
@@ -3525,7 +3528,10 @@ ppc_elf_relocate_section (output_bfd, in
 
 	    BFD_ASSERT (sec != (asection *) 0);
 	    name = bfd_get_section_name (abfd, sec->output_section);
-	    if (strcmp (name, ".sdata") == 0 || strcmp (name, ".sbss") == 0)
+	    if (((strncmp (name, ".sdata", 6) == 0	
+		  && (name[6] == 0 || name[6] == '.'))
+		 || (strncmp (name, ".sbss", 5) == 0
+		     && (name[5] == 0 || name[5] == '.'))))
 	      {
 		reg = 13;
 		addend -= (sdata->sym_hash->root.u.def.value
@@ -3533,8 +3539,8 @@ ppc_elf_relocate_section (output_bfd, in
 			   + sdata->sym_hash->root.u.def.section->output_offset);
 	      }
 
-	    else if (strcmp (name, ".sdata2") == 0
-		     || strcmp (name, ".sbss2") == 0)
+	    else if (strncmp (name, ".sdata2", 7) == 0
+		     || strncmp (name, ".sbss2", 6) == 0)
 	      {
 		reg = 2;
 		addend -= (sdata2->sym_hash->root.u.def.value

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