aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-mips-elf/branch-absolute-n32.d
AgeCommit message (Collapse)AuthorFilesLines
2018-07-12MIPS/LD/testsuite: Correct mips-elf.exp test ABI/emul/endian arrangementMaciej W. Rozycki1-2/+1
Similarly to commit 86b24e15c45b ("MIPS/LD/testsuite: Correct comm-data.exp test ABI/emul/endian arrangement") update the mips-elf.exp test script to: - correctly select emulations for targets using non-traditional MIPS emulations, - correctly select ABIs for targets that do not support all of them, - use the default endianness selection where possible to benefit targets that support only one, - simplify test invocation by providing ABI-specific `run_dump_test' wrappers, specifically `run_dump_test_o32', `run_dump_test_n32', `run_dump_test_n64' and `run_dump_test_eabi', which remove the need to use conditionals across the Expect script or to repeat ABI-specific GAS and LD flags with each invocation, removing numerous test failures for `mips-sgi-irix6', `mips64-openbsd', `mips64el-openbsd' and `mips64el-ps2-elf' targets and broadening coverage for several MIPS targets. There are some new failures for the `mips64el-ps2-elf' target with tests that were not previously run for that target: FAIL: MIPS16 link branch to absolute expression (n32) FAIL: MIPS16 link branch to absolute expression 1 (n32) FAIL: MIPS16 link branch to absolute expression 2 (n32) FAIL: microMIPS link branch to absolute expression (n32) FAIL: MIPS ELF got reloc n32 FAIL: MIPS ELF xgot reloc n32 FAIL: undefined weak symbol overflow (n32) FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs n32 FAIL: ld-mips-elf/attr-gnu-4-0-n32-ph FAIL: ld-mips-elf/attr-gnu-4-1-n32-ph FAIL: ld-mips-elf/attr-gnu-4-2-n32-ph FAIL: ld-mips-elf/attr-gnu-4-3-n32-ph FAIL: MIPSr6 JALR reloc unaligned/cross-mode link test (n32) which are mostly due to dump discrepancies caused by mapping differences coming from the default linker scripts used by these test cases, or sometimes because of the specific MIPS processor architecture recorded in the ELF file taking precedence over the general MIPS ISA level also recorded. Finally, the R_MIPS16_HI16/R_MIPS16_LO16 relocation test failure is a preexisting issue with the IRIX style emulation. These failures will have to be addressed separately. ld/ * testsuite/ld-mips-elf/mips-elf.exp (run_dump_test_abi) (run_dump_test_o32, run_dump_test_n32, run_dump_test_n64) (run_dump_test_eabi): New procedures. (has_newabi, has_elf32): Remove variables. (has_abi): New associative array variable. (abi_asflags, abi_ldflags): Update settings across targets. (irixemul): New variable. Replace `run_dump_test' calls where applicable throughout with `run_dump_test_o32', `run_dump_test_n32', `run_dump_test_n64' and `run_dump_test_eabi' as appropriate. Remove explicit passing of `abi_asflags' and `abi_ldflags'. Use `noarch' for tests that require their own architecture setting. Force the big endianness for tests that require it. Select the endianness required for `objdump invocation with the `reloc-2' test. Conditionalize tests run via `run_ld_link_tests' on the ABI required and use the ABI list from the `has_abi' array where appropriate. * testsuite/ld-mips-elf/attr-gnu-4-0-n32-ph.d: Remove ABI and endianness selection options from `ld' and `source' tags. Relax output format matching. * testsuite/ld-mips-elf/attr-gnu-4-0-n64-ph.d: Likewise. * testsuite/ld-mips-elf/attr-gnu-4-1-n32-ph.d: Likewise. * testsuite/ld-mips-elf/attr-gnu-4-1-n64-ph.d: Likewise. * testsuite/ld-mips-elf/attr-gnu-4-2-n32-ph.d: Likewise. * testsuite/ld-mips-elf/attr-gnu-4-2-n64-ph.d: Likewise. * testsuite/ld-mips-elf/attr-gnu-4-3-n32-ph.d: Likewise. * testsuite/ld-mips-elf/attr-gnu-4-3-n64-ph.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-addend-micromips-n32.d: Remove ABI and endianness selection options from `as', `ld', `source' tags, and also the `-march=from-abi' option. Remove the `as' tag where it would become empty. * testsuite/ld-mips-elf/bal-jalx-addend-micromips-n64.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-addend-micromips.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-addend-n32.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-addend-n64.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-addend.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-local-micromips-n32.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-local-micromips-n64.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-local-micromips.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-local-n32.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-local-n64.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-local.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n32.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n64.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-pic-ignore-n32.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-pic-ignore-n64.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-pic-ignore.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-pic-micromips-n32.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-pic-micromips-n64.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-pic-micromips.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-pic-n32.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-pic-n64.d: Likewise. * testsuite/ld-mips-elf/bal-jalx-pic.d: Likewise. * testsuite/ld-mips-elf/branch-absolute-addend-n32.d: Likewise. * testsuite/ld-mips-elf/branch-absolute-addend-n64.d: Likewise. * testsuite/ld-mips-elf/branch-absolute-addend.d: Likewise. * testsuite/ld-mips-elf/branch-absolute-n32.d: Likewise. * testsuite/ld-mips-elf/branch-absolute-n64.d: Likewise. * testsuite/ld-mips-elf/branch-absolute.d: Likewise. * testsuite/ld-mips-elf/dyn-sec64.d: Likewise. * testsuite/ld-mips-elf/eh-frame1-n32.d: Likewise. * testsuite/ld-mips-elf/eh-frame1-n64.d: Likewise. * testsuite/ld-mips-elf/eh-frame2-n32.d: Likewise. * testsuite/ld-mips-elf/eh-frame2-n64.d: Likewise. * testsuite/ld-mips-elf/elf-rel-got-n32-embed.d: Likewise. * testsuite/ld-mips-elf/elf-rel-got-n32.d: Likewise. * testsuite/ld-mips-elf/elf-rel-got-n64-embed.d: Likewise. * testsuite/ld-mips-elf/elf-rel-got-n64-irix.d: Likewise. * testsuite/ld-mips-elf/elf-rel-got-n64.d: Likewise. * testsuite/ld-mips-elf/elf-rel-xgot-n32-embed.d: Likewise. * testsuite/ld-mips-elf/elf-rel-xgot-n32.d: Likewise. * testsuite/ld-mips-elf/elf-rel-xgot-n64-embed.d: Likewise. * testsuite/ld-mips-elf/elf-rel-xgot-n64-irix.d: Likewise. * testsuite/ld-mips-elf/elf-rel-xgot-n64.d: Likewise. * testsuite/ld-mips-elf/emit-relocs-1.d: Likewise. * testsuite/ld-mips-elf/got-dump-2.d: Likewise. * testsuite/ld-mips-elf/got-page-2.d: Likewise. * testsuite/ld-mips-elf/jal-global-overflow-0.d: Likewise. * testsuite/ld-mips-elf/jal-global-overflow-1.d: Likewise. * testsuite/ld-mips-elf/jal-local-overflow-0.d: Likewise. * testsuite/ld-mips-elf/jal-local-overflow-1.d: Likewise. * testsuite/ld-mips-elf/jalbal.d: Likewise. * testsuite/ld-mips-elf/jalx-addend-n32.d: Likewise. * testsuite/ld-mips-elf/jalx-addend-n64.d: Likewise. * testsuite/ld-mips-elf/jalx-addend.d: Likewise. * testsuite/ld-mips-elf/jalx-local-n32.d: Likewise. * testsuite/ld-mips-elf/jalx-local-n64.d: Likewise. * testsuite/ld-mips-elf/jalx-local.d: Likewise. * testsuite/ld-mips-elf/jr-to-b-1.d: Likewise. * testsuite/ld-mips-elf/jr-to-b-2.d: Likewise. * testsuite/ld-mips-elf/lsi-4010-isa.d: Likewise. * testsuite/ld-mips-elf/micromips-branch-absolute-addend-n32.d: Likewise. * testsuite/ld-mips-elf/micromips-branch-absolute-addend-n64.d: Likewise. * testsuite/ld-mips-elf/micromips-branch-absolute-addend.d: Likewise. * testsuite/ld-mips-elf/micromips-branch-absolute-n32.d: Likewise. * testsuite/ld-mips-elf/micromips-branch-absolute-n64.d: Likewise. * testsuite/ld-mips-elf/micromips-branch-absolute.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-2.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-3.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-absolute-1.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-absolute-2.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-absolute-addend-1.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-absolute-addend-n32-1.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-absolute-addend-n32.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-absolute-addend-n64-1.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-absolute-addend-n64.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-absolute-addend.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-absolute-n32-1.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-absolute-n32-2.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-absolute-n32.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-absolute-n64-1.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-absolute-n64-2.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-absolute-n64.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-absolute.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-addend-2.d: Likewise. * testsuite/ld-mips-elf/mips16-branch-addend-3.d: Likewise. * testsuite/ld-mips-elf/mips16-hilo-n32.d: Likewise. * testsuite/ld-mips-elf/mips16-pcrel-0.d: Likewise. * testsuite/ld-mips-elf/mips16-pcrel-1.d: Likewise. * testsuite/ld-mips-elf/mips16-pcrel-addend-2.d: Likewise. * testsuite/ld-mips-elf/mips16-pcrel-addend-6.d: Likewise. * testsuite/ld-mips-elf/mips16-pcrel-n32-0.d: Likewise. * testsuite/ld-mips-elf/mips16-pcrel-n32-1.d: Likewise. * testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-0.d: Likewise. * testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-1.d: Likewise. * testsuite/ld-mips-elf/mips16e2-pcrel-0.d: Likewise. * testsuite/ld-mips-elf/mips16e2-pcrel-1.d: Likewise. * testsuite/ld-mips-elf/mips16e2-pcrel-addend-2.d: Likewise. * testsuite/ld-mips-elf/mips16e2-pcrel-addend-6.d: Likewise. * testsuite/ld-mips-elf/mips16e2-pcrel-n32-0.d: Likewise. * testsuite/ld-mips-elf/mips16e2-pcrel-n32-1.d: Likewise. * testsuite/ld-mips-elf/mips16e2-pcrel-n64-sym32-0.d: Likewise. * testsuite/ld-mips-elf/mips16e2-pcrel-n64-sym32-1.d: Likewise. * testsuite/ld-mips-elf/multi-got-1.d: Likewise. * testsuite/ld-mips-elf/multi-got-hidden-1.d: Likewise. * testsuite/ld-mips-elf/multi-got-hidden-2.d: Likewise. * testsuite/ld-mips-elf/multi-got-no-shared.d: Likewise. * testsuite/ld-mips-elf/no-shared-1-n32.d: Likewise. * testsuite/ld-mips-elf/no-shared-1-n64.d: Likewise. * testsuite/ld-mips-elf/no-shared-1-o32.d: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-2.d: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-3-error.d: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-4-error.d: Likewise. * testsuite/ld-mips-elf/pie-n32.d: Likewise. * testsuite/ld-mips-elf/pie-n64.d: Likewise. * testsuite/ld-mips-elf/pie-o32.d: Likewise. * testsuite/ld-mips-elf/rel32-n32.d: Likewise. * testsuite/ld-mips-elf/rel32-o32.d: Likewise. * testsuite/ld-mips-elf/rel64.d: Likewise. * testsuite/ld-mips-elf/relax-jalr-n32.d: Likewise. * testsuite/ld-mips-elf/reloc-1-n32.d: Likewise. * testsuite/ld-mips-elf/reloc-1-n64.d: Likewise. * testsuite/ld-mips-elf/reloc-2.d: Likewise. * testsuite/ld-mips-elf/reloc-3-n32.d: Likewise. * testsuite/ld-mips-elf/reloc-local-overflow.d: Likewise. * testsuite/ld-mips-elf/textrel-1.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-2.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-ignore-2.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-ignore-micromips.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-ignore-mips16.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-ignore-r6-1.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-micromips.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-mips16.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-r6-1.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-r6-2.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-addend-0.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-addend-1.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-addend-2.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-addend-3.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-addend-micromips-0.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-addend-micromips-1.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-addend-mips16-0.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-addend-mips16-1.d: Likewise. * testsuite/ld-mips-elf/unaligned-jump-micromips.d: Likewise. * testsuite/ld-mips-elf/unaligned-jump-mips16.d: Likewise. * testsuite/ld-mips-elf/unaligned-jump.d: Likewise. * testsuite/ld-mips-elf/unaligned-ldpc-0.d: Likewise. * testsuite/ld-mips-elf/unaligned-ldpc-1.d: Likewise. * testsuite/ld-mips-elf/unaligned-lwpc-0.d: Likewise. * testsuite/ld-mips-elf/unaligned-lwpc-1.d: Likewise.
2016-07-14BFD: Let targets handle relocations against absolute symbolsMaciej W. Rozycki1-0/+6
Fix a generic BFD issue with relocations against absolute symbols, which are installed without using any individual relocation handler provided by the backend. This causes any absolute section's addend to be lost on REL targets such as o32 MIPS, and also relocation-specific calculation adjustments are not made. As an example assembling this program: $ cat test.s .text foo: b bar b baz .set bar, 0x1234 $ as -EB -32 -o test-o32.o test.s $ as -EB -n32 -o test-n32.o test.s produces this binary code: $ objdump -dr test-o32.o test-n32.o test-o32.o: file format elf32-tradbigmips Disassembly of section .text: 00000000 <foo>: 0: 10000000 b 4 <foo+0x4> 0: R_MIPS_PC16 *ABS* 4: 00000000 nop 8: 1000ffff b 8 <foo+0x8> 8: R_MIPS_PC16 baz c: 00000000 nop test-n32.o: file format elf32-ntradbigmips Disassembly of section .text: 00000000 <foo>: 0: 10000000 b 4 <foo+0x4> 0: R_MIPS_PC16 *ABS*+0x1230 4: 00000000 nop 8: 10000000 b c <foo+0xc> 8: R_MIPS_PC16 baz-0x4 c: 00000000 nop $ where it is clearly visible in `test-o32.o', which uses REL relocations, that the absolute section's addend equivalent to the value of `bar' -- a reference to which cannot be fully resolved at the assembly time, because the reference is PC-relative -- has been lost, as has been the relocation-specific adjustment of -4, required to take into account the PC+4-relative calculation made by hardware with branches and seen in the external symbol reference to `baz' as the `ffff' addend encoded in the instruction word. In `test-n32.o', which uses RELA relocations, the absolute section's addend has been correctly retained. Give precedence then in `bfd_perform_relocation' and `bfd_install_relocation' to any individual relocation handler the backend selected may have provided, while still resorting to the generic calculation otherwise. This retains the semantics which we've had since forever or before the beginning of our repository history, and is at the very least compatible with `bfd_elf_generic_reloc' being used as the handler. Retain the `bfd_is_und_section' check unchanged at the beginning of `bfd_perform_relocation' since this does not affect the semantics of the function. The check returns the same `bfd_reloc_undefined' code the check for a null `howto' does, so swapping the two does not matter. Also the check is is mutually exclusive with the `bfd_is_abs_section' check, since a section cannot be absolute and undefined both at once, so swapping the two does not matter either. With this change applied the program quoted above now has the in-place addend correctly calculated and installed in the field being relocated: $ objdump -dr fixed-o32.o fixed-o32.o: file format elf32-tradbigmips Disassembly of section .text: 00000000 <foo>: 0: 1000048c b 1234 <bar> 0: R_MIPS_PC16 *ABS* 4: 00000000 nop 8: 1000ffff b 8 <foo+0x8> 8: R_MIPS_PC16 baz c: 00000000 nop $ Add a set of MIPS tests to cover the relevant cases, including absolute symbols with addends, and verifying that PC-relative relocations against symbols concerned resolve to the same value in the final link regardless of whether the REL or the RELA relocation form is used. Exclude linker tests though which would overflow the in-place addend on REL targets and use them as dump patterns for RELA targets only. bfd/ * reloc.c (bfd_perform_relocation): Try the `howto' handler first with relocations against absolute symbols. (bfd_install_relocation): Likewise. gas/ * testsuite/gas/mips/mips16-branch-absolute.d: Update patterns. * testsuite/gas/mips/branch-absolute.d: New test. * testsuite/gas/mips/branch-absolute-n32.d: New test. * testsuite/gas/mips/branch-absolute-n64.d: New test. * testsuite/gas/mips/branch-absolute-addend-n32.d: New test. * testsuite/gas/mips/branch-absolute-addend-n64.d: New test. * testsuite/gas/mips/mips16-branch-absolute-n32.d: New test. * testsuite/gas/mips/mips16-branch-absolute-n64.d: New test. * testsuite/gas/mips/mips16-branch-absolute-addend-n32.d: New test. * testsuite/gas/mips/mips16-branch-absolute-addend-n64.d: New test. * testsuite/gas/mips/micromips-branch-absolute.d: New test. * testsuite/gas/mips/micromips-branch-absolute-n32.d: New test. * testsuite/gas/mips/micromips-branch-absolute-n64.d: New test. * testsuite/gas/mips/micromips-branch-absolute-addend-n32.d: New test. * testsuite/gas/mips/micromips-branch-absolute-addend-n64.d: New test. * testsuite/gas/mips/branch-absolute.s: New test source. * testsuite/gas/mips/branch-absolute-addend.s: New test source. * testsuite/gas/mips/mips16-branch-absolute-addend.s: New test source. * testsuite/gas/mips/micromips-branch-absolute.s: New test source. * testsuite/gas/mips/micromips-branch-absolute-addend.s: New test source. * testsuite/gas/mips/mips.exp: Run the new tests. ld/ * testsuite/ld-mips-elf/branch-absolute.d: New test. * testsuite/ld-mips-elf/branch-absolute-n32.d: New test. * testsuite/ld-mips-elf/branch-absolute-n64.d: New test. * testsuite/ld-mips-elf/branch-absolute-addend.d: New test. * testsuite/ld-mips-elf/branch-absolute-addend-n32.d: New test. * testsuite/ld-mips-elf/branch-absolute-addend-n64.d: New test. * testsuite/ld-mips-elf/micromips-branch-absolute.d: New test. * testsuite/ld-mips-elf/micromips-branch-absolute-n32.d: New test. * testsuite/ld-mips-elf/micromips-branch-absolute-n64.d: New test. * testsuite/ld-mips-elf/micromips-branch-absolute-addend.d: New test. * testsuite/ld-mips-elf/micromips-branch-absolute-addend-n32.d: New test. * testsuite/ld-mips-elf/micromips-branch-absolute-addend-n64.d: New test. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests, except from `branch-absolute-addend' and `micromips-branch-absolute-addend', referred indirectly only.