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: i386 and "R_386_16 relocation against SEC_MERGE section"


On Thu, May 09, 2002 at 09:55:55PM +0200, Etienne Lorrain wrote:
> main.o(.text.menu+0x8f9): relocation truncated to fit: R_386_16
> .rodata.str1.1

I'm just going to remove the overflow checks.  It's tricky to get
right, especially in the SEC_MERGE case where we can have
negative addends relative to original input section.

bfd/ChangeLog
	* elf32-i386.c (elf_i386_relocate_section): Remove overflow checks
	addend in 2002-05-09 commit.

Index: bfd/elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.68
diff -u -p -r1.68 elf32-i386.c
--- bfd/elf32-i386.c	9 May 2002 06:34:43 -0000	1.68
+++ bfd/elf32-i386.c	10 May 2002 07:32:03 -0000
@@ -1724,7 +1724,6 @@ elf_i386_relocate_section (output_bfd, i
       bfd_vma off;
       bfd_vma relocation;
       boolean unresolved_reloc;
-      boolean overflow;
       bfd_reloc_status_type r;
       unsigned int indx;
 
@@ -1747,7 +1746,6 @@ elf_i386_relocate_section (output_bfd, i
       if (info->relocateable)
 	{
 	  bfd_vma val;
-	  bfd_vma addend;
 	  bfd_byte *where;
 
 	  /* This is a relocatable link.  We don't have to change
@@ -1769,36 +1767,14 @@ elf_i386_relocate_section (output_bfd, i
 	  where = contents + rel->r_offset;
 	  switch (howto->size)
 	    {
+	      /* FIXME: overflow checks.  */
 	    case 0:
-	      addend = bfd_get_8 (input_bfd, where);
-	      if (howto->pc_relative)
-		addend = (addend ^ 0x80) - 0x80;
-	      val += addend;
+	      val += bfd_get_8 (input_bfd, where);
 	      bfd_put_8 (input_bfd, val, where);
-	      if (howto->pc_relative)
-		val += 0x80;
-	      if (val > 0xff)
-		{
-		  h = NULL;
-		  r = bfd_reloc_overflow;
-		  goto overflow_error;
-		}
 	      break;
 	    case 1:
-	      addend = bfd_get_16 (input_bfd, where);
-	      if (howto->pc_relative)
-		addend = (addend ^ 0x8000) - 0x8000;
-	      val += addend;
+	      val += bfd_get_16 (input_bfd, where);
 	      bfd_put_16 (input_bfd, val, where);
-	      if (howto->pc_relative)
-		val += 0x8000;
-	      if (output_bfd->arch_info->mach != bfd_mach_i386_i8086
-		  && val > 0xffff)
-		{
-		  h = NULL;
-		  r = bfd_reloc_overflow;
-		  goto overflow_error;
-		}
 	      break;
 	    case 2:
 	      val += bfd_get_32 (input_bfd, where);
@@ -1815,7 +1791,6 @@ elf_i386_relocate_section (output_bfd, i
       sym = NULL;
       sec = NULL;
       unresolved_reloc = false;
-      overflow = false;
       if (r_symndx < symtab_hdr->sh_info)
 	{
 	  sym = local_syms + r_symndx;
@@ -1868,21 +1843,15 @@ elf_i386_relocate_section (output_bfd, i
 	      switch (howto->size)
 		{
 		case 0:
+		  /* FIXME: overflow checks.  */
 		  if (howto->pc_relative)
 		    addend -= 1;
 		  bfd_put_8 (input_bfd, addend, where);
-		  if (howto->pc_relative)
-		    addend += 0x80;
-		  overflow = addend > 0xff;
 		  break;
 		case 1:
 		  if (howto->pc_relative)
 		    addend -= 2;
 		  bfd_put_16 (input_bfd, addend, where);
-		  if (howto->pc_relative)
-		    addend += 0x8000;
-		  if (output_bfd->arch_info->mach != bfd_mach_i386_i8086)
-		    overflow = addend > 0xffff;
 		  break;
 		case 2:
 		  if (howto->pc_relative)
@@ -2172,10 +2141,7 @@ elf_i386_relocate_section (output_bfd, i
       r = _bfd_final_link_relocate (howto, input_bfd, input_section,
 				    contents, rel->r_offset,
 				    relocation, (bfd_vma) 0);
-      if (overflow && r == bfd_reloc_ok)
-	r = bfd_reloc_overflow;
 
-    overflow_error:
       if (r != bfd_reloc_ok)
 	{
 	  const char *name;

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