This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Only warn when missing MIPS LO16 are encountered
- From: Thiemo Seufer <ths at networkno dot de>
- To: binutils at sourceware dot org
- Date: Mon, 26 Mar 2007 11:36:09 +0100
- Subject: [PATCH] Only warn when missing MIPS LO16 are encountered
Hello All,
I applied the appended patch, it downgrades missing LO16 relocations
from an error to a warning. This unbreaks builds with existing
compilers but still gives gcc developers a better chance to find and
fix the problematic bits in the optimizer.
Thiemo
2007-03-26 Thiemo Seufer <ths@mips.com>
* elfxx-mips.c (mips_elf_next_relocation): Don't signal an error if no
matching relocation is found.
(_bfd_mips_elf_relocate_section): Only warn about missing relocations.
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.197
diff -u -p -r1.197 elfxx-mips.c
--- bfd/elfxx-mips.c 21 Mar 2007 04:03:09 -0000 1.197
+++ bfd/elfxx-mips.c 26 Mar 2007 10:23:02 -0000
@@ -3615,7 +3615,6 @@ mips_elf_next_relocation (bfd *abfd ATTR
}
/* We didn't find it. */
- bfd_set_error (bfd_error_bad_value);
return NULL;
}
@@ -7857,10 +7856,8 @@ _bfd_mips_elf_relocate_section (bfd *out
&& mips_elf_local_relocation_p (input_bfd, rel,
local_sections, FALSE)))
{
- bfd_vma l;
const Elf_Internal_Rela *lo16_relocation;
reloc_howto_type *lo16_howto;
- bfd_byte *lo16_location;
int lo16_type;
if (r_type == R_MIPS16_HI16)
@@ -7883,7 +7880,12 @@ _bfd_mips_elf_relocate_section (bfd *out
several relocations for the same address. In
that case, the R_MIPS_LO16 relocation may occur
as one of these. We permit a similar extension
- in general, as that is useful for GCC. */
+ in general, as that is useful for GCC.
+
+ In some cases GCC dead code elimination removes
+ the LO16 but keeps the corresponding HI16. This
+ is strictly speaking a violation of the ABI but
+ not immediately harmful. */
lo16_relocation = mips_elf_next_relocation (input_bfd,
lo16_type,
rel, relend);
@@ -7901,28 +7903,33 @@ _bfd_mips_elf_relocate_section (bfd *out
(_("%B: Can't find matching LO16 reloc against `%s' for %s at 0x%lx in section `%A'"),
input_bfd, input_section, name, howto->name,
rel->r_offset);
- return FALSE;
}
+ else
+ {
+ bfd_byte *lo16_location;
+ bfd_vma l;
- lo16_location = contents + lo16_relocation->r_offset;
+ lo16_location = contents + lo16_relocation->r_offset;
- /* Obtain the addend kept there. */
- lo16_howto = MIPS_ELF_RTYPE_TO_HOWTO (input_bfd,
- lo16_type, FALSE);
- _bfd_mips16_elf_reloc_unshuffle (input_bfd, lo16_type, FALSE,
- lo16_location);
- l = mips_elf_obtain_contents (lo16_howto, lo16_relocation,
- input_bfd, contents);
- _bfd_mips16_elf_reloc_shuffle (input_bfd, lo16_type, FALSE,
- lo16_location);
- l &= lo16_howto->src_mask;
- l <<= lo16_howto->rightshift;
- l = _bfd_mips_elf_sign_extend (l, 16);
+ /* Obtain the addend kept there. */
+ lo16_howto = MIPS_ELF_RTYPE_TO_HOWTO (input_bfd,
+ lo16_type, FALSE);
+ _bfd_mips16_elf_reloc_unshuffle (input_bfd, lo16_type,
+ FALSE, lo16_location);
+ l = mips_elf_obtain_contents (lo16_howto,
+ lo16_relocation,
+ input_bfd, contents);
+ _bfd_mips16_elf_reloc_shuffle (input_bfd, lo16_type,
+ FALSE, lo16_location);
+ l &= lo16_howto->src_mask;
+ l <<= lo16_howto->rightshift;
+ l = _bfd_mips_elf_sign_extend (l, 16);
- addend <<= 16;
+ addend <<= 16;
- /* Compute the combined addend. */
- addend += l;
+ /* Compute the combined addend. */
+ addend += l;
+ }
}
else
addend <<= howto->rightshift;