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: ld errors -- wrong output section for SDAREL target


> Date: 21 Mar 2000 18:42:40 -0800
> From: Ian Lance Taylor <ian@zembu.com>
> CC: velco@fadata.bg, binutils@sourceware.cygnus.com
> 
>    From: Michael Meissner <meissner@cygnus.com>
>    Date: Tue, 21 Mar 2000 19:16:23 -0500
> 
>    On Mon, Mar 20, 2000 at 07:37:19PM -0800, Ian Lance Taylor wrote:
>    > I don't know.  Michael, I think you wrote this code.  The code in
>    > question is in ppc_elf_relocate_section and a couple of other places.
>    > It explicitly checks whether the output section of a R_PPC_SDAREL16
>    > relocation is in the .sdata or .sbss section.  Do you remember why it
>    > does this?
> 
>    At this stage I no longer remember.  I suspect I was just cloning code from the
>    sparc or i386 ports.
> 
> The code in question is unique to the PowerPC, actually.

I believe that it is trying to be error-checking code.  

Last I looked at it, it was technically not conformant with the ABI,
but useful for catching problems (like gcc not putting stuff in the
right sections) so I left it in.


The original change was marked:

Sun Jan 14 21:36:08 1996  Michael Meissner  <meissner@tiktok.cygnus.com>

	* elf32-ppc.c (ppc_elf_{unsupported,std}_reloc): Remove functions.
	(ppc_elf_howto_raw): Remove ppc_elf_{unsupported,std}_reloc
	references.
	(ppc_elf_relocate_section):  No longer allow .sdata/.sbss sections
	to satisfy a TOC16 relocation. 	Rewrite unsupported relocation
	support.  Begin support for R_PPC_SDA{2,}REL.

and I note that the relocation did not actually work at this point;
the change was

@@ -2337,6 +2252,37 @@ ppc_elf_relocate_section (output_bfd, in
 	  addend += ((relocation + addend) & 0x8000) << 1;
 	  break;
 
+	case R_PPC_SDAREL16:			/* relocate against _SDA_BASE_ */
+	  BFD_ASSERT (sec != (asection *)0);
+	  if (strcmp (bfd_get_section_name (abfd, sec), ".sdata") != 0
+	      && strcmp (bfd_get_section_name (abfd, sec), ".sbss") != 0)
+	    {
+	      (*_bfd_error_handler) ("%s: The target of R_PPC_SDAREL16 relocations must be in section .sdata or .sbss not %s",
+				     bfd_get_filename (input_bfd),
+				     bfd_get_section_name (abfd, sec));
+
+	      bfd_set_error (bfd_error_bad_value);
+	      ret = false;
+	      continue;
+	    }
+	  goto unsupported;
+
+	case R_PPC_EMB_SDA2REL:
+	  BFD_ASSERT (sec != (asection *)0);
+	  if (strcmp (bfd_get_section_name (abfd, sec), ".sdata2") != 0
+	      && strcmp (bfd_get_section_name (abfd, sec), ".sbss2") != 0)
+	    {
+	      (*_bfd_error_handler) ("%s: The target of R_PPC_SDA2REL16 relocations must be in section .sdata2 or .sbss2 not %s",
+				     bfd_get_filename (input_bfd),
+				     bfd_get_section_name (abfd, sec));
+
+	      bfd_set_error (bfd_error_bad_value);
+	      ret = false;
+	      continue;
+	    }
+	  goto unsupported;
+
+
 	case R_PPC_PLTREL24:
 	case R_PPC_COPY:
 	case R_PPC_GLOB_DAT:

-- 
- Geoffrey Keating <geoffk@cygnus.com>

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