aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2016-05-27 20:43:05 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2016-05-27 22:31:29 +0100
commitbc27bb0573a5e1ce1a6365fc06aeab9bd891fc3a (patch)
treed45ba6d41359e4ec8d91194d036213be825330cd /bfd
parentceab86af75e9870ecf2da772a0d867ca12521a24 (diff)
downloadgdb-bc27bb0573a5e1ce1a6365fc06aeab9bd891fc3a.zip
gdb-bc27bb0573a5e1ce1a6365fc06aeab9bd891fc3a.tar.gz
gdb-bc27bb0573a5e1ce1a6365fc06aeab9bd891fc3a.tar.bz2
MIPS/BFD: Include the addend in JALX's target alignment verification
On RELA targets the addend can affect JALX target's alignment, so only verify it once the whole relocation calculation has completed. bfd/ * elfxx-mips.c (mips_elf_calculate_relocation) <R_MIPS16_26> <R_MIPS_26, R_MICROMIPS_26_S1>: Include the addend in JALX's target alignment verification. ld/ * testsuite/ld-mips-elf/unaligned-jalx-addend-0.d: New test. * testsuite/ld-mips-elf/unaligned-jalx-addend-1.d: New test. * testsuite/ld-mips-elf/unaligned-jalx-addend-mips16-0.d: New test. * testsuite/ld-mips-elf/unaligned-jalx-addend-mips16-1.d: New test. * testsuite/ld-mips-elf/unaligned-jalx-addend-micromips-0.d: New test. * testsuite/ld-mips-elf/unaligned-jalx-addend-micromips-1.d: New test. * testsuite/ld-mips-elf/unaligned-jalx-addend-0.s: New test source. * testsuite/ld-mips-elf/unaligned-jalx-addend-1.s: New test source. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elfxx-mips.c14
2 files changed, 14 insertions, 6 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 5bace1e..cefe44a 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
2016-05-27 Maciej W. Rozycki <macro@imgtec.com>
+ * elfxx-mips.c (mips_elf_calculate_relocation) <R_MIPS16_26>
+ <R_MIPS_26, R_MICROMIPS_26_S1>: Include the addend in JALX's
+ target alignment verification.
+
+2016-05-27 Maciej W. Rozycki <macro@imgtec.com>
+
* elfxx-mips.c (mips_elf_calculate_relocation): Also use the
section name if `bfd_elf_string_from_elf_section' returns an
empty string.
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 2fff306..c2c1290 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -5773,11 +5773,6 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
{
unsigned int shift;
- /* Make sure the target of JALX is word-aligned. Bit 0 must be
- the correct ISA mode selector and bit 1 must be 0. */
- if (*cross_mode_jump_p && (symbol & 3) != (r_type == R_MIPS_26))
- return bfd_reloc_outofrange;
-
/* Shift is 2, unusually, for microMIPS JALX. */
shift = (!*cross_mode_jump_p && r_type == R_MICROMIPS_26_S1) ? 1 : 2;
@@ -5787,7 +5782,14 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
value = _bfd_mips_elf_sign_extend (addend, 26 + shift);
else
value = addend;
- value = (value + symbol) >> shift;
+ value += symbol;
+
+ /* Make sure the target of JALX is word-aligned. Bit 0 must be
+ the correct ISA mode selector and bit 1 must be 0. */
+ if (*cross_mode_jump_p && (value & 3) != (r_type == R_MIPS_26))
+ return bfd_reloc_outofrange;
+
+ value >>= shift;
if (!was_local_p && h->root.root.type != bfd_link_hash_undefweak)
overflowed_p = (value >> 26) != ((p + 4) >> (26 + shift));
value &= howto->dst_mask;