aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfxx-mips.c
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2016-08-10 12:43:18 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2016-08-10 22:19:33 +0100
commitc7318def0cbfc6f0e1bab5fb54306efaf9ed3a5c (patch)
treec6c1e1c3000b41171a86ec20d9ea3134e591d81b /bfd/elfxx-mips.c
parent24cdb46e9f0a694b4fbc11085e094857f08c0419 (diff)
MIPS/BFD: Set the ISA bit in microMIPS LA25 stub references
Fix a linker regression introduced with commit 9d862524f6ae ("MIPS: Verify the ISA mode and alignment of branch and jump targets") causing a build failure in microMIPS glibc where the `zdump' tool fails to link: .../timezone/zdump.o: In function `yeartot': .../timezone/zdump.c:758:(.text+0x62): Jump to a non-instruction-aligned address .../timezone/zdump.c:758:(.text+0x76): Jump to a non-instruction-aligned address .../timezone/zdump.c:768:(.text+0x112): Jump to a non-instruction-aligned address .../timezone/zdump.c:774:(.text+0x1b8): Jump to a non-instruction-aligned address .../timezone/zdump.c:774:(.text+0x1cc): Jump to a non-instruction-aligned address collect2: error: ld returned 1 exit status make[2]: *** [.../timezone/zdump] Error 1 The cause of the failure is the stricter check introduced with the said change for jump and branch targets tripping on the address of microMIPS LA25 stubs. Despite being microMIPS code these stubs do not have the ISA bit set throughout the relocation calculation process, because they have their address set to the memory offset into the stub section they are placed in. The `mips_elf_la25_stub' structure does not carry ISA mode information, but there is no need to extend it, because the ISA mode can be inferred from the original symbol, which will have STO_MICROMIPS annotation, so use that instead to set the ISA bit appropriately. Also only LA25 stubs associated with microMIPS symbols need to have the ISA bit set, because other LA25 stubs are made with regular MIPS code, even if associated with a MIPS16 symbol (in which case they are needed by a call thunk only rather than the MIPS16 function proper). bfd/ * elfxx-mips.c (mips_elf_calculate_relocation): Set the ISA bit in microMIPS LA25 stub references.
Diffstat (limited to 'bfd/elfxx-mips.c')
-rw-r--r--bfd/elfxx-mips.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index cdc5d96289..cfb9a52af0 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -5577,9 +5577,13 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
else if (h != NULL && h->la25_stub
&& mips_elf_relocation_needs_la25_stub (input_bfd, r_type,
target_is_16_bit_code_p))
- symbol = (h->la25_stub->stub_section->output_section->vma
- + h->la25_stub->stub_section->output_offset
- + h->la25_stub->offset);
+ {
+ symbol = (h->la25_stub->stub_section->output_section->vma
+ + h->la25_stub->stub_section->output_offset
+ + h->la25_stub->offset);
+ if (ELF_ST_IS_MICROMIPS (h->root.other))
+ symbol |= 1;
+ }
/* For direct MIPS16 and microMIPS calls make sure the compressed PLT
entry is used if a standard PLT entry has also been made. In this
case the symbol will have been set by mips_elf_set_plt_sym_value