]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
MIPS/BFD: Fix RELA handling of borrow in the generic linker
authorMaciej W. Rozycki <macro@orcam.me.uk>
Sun, 6 Jul 2025 18:22:49 +0000 (19:22 +0100)
committerMaciej W. Rozycki <macro@orcam.me.uk>
Sun, 6 Jul 2025 18:22:49 +0000 (19:22 +0100)
commitce08b3bb19b372877128ae9d935c1fe52afc33ae
treedf6763798ed3573fd62b8287c40ffa4f4f8ca6fa
parentae236b71ea7b951f25d84ba1098478458c4e34c9
MIPS/BFD: Fix RELA handling of borrow in the generic linker

Fix an issue with `_bfd_mips_elf_generic_reloc' not taking into account
any borrow from the lower part in the handling of relocations of the
HI/LO kind and resulting in incorrect calculations made for RELA targets
in the generic used for non-ELF output such as S-records.  This doesn't
trigger for REL targets because they call `_bfd_mips_elf_generic_reloc'
indirectly from `_bfd_mips_elf_lo16_reloc' so as to obtain a complete
32-bit addend from relocation pairs and in calculating the addend the
latter function uses a hack to work around the lack of borrow handling
in the former function.

The MIPS/ELF linker is unaffected as it uses its own calculations.

Correct the calculation of the relevant partial relocations made in
`_bfd_mips_elf_generic_reloc' then to take the borrow into account and
remove the hack from `_bfd_mips_elf_lo16_reloc' as no longer needed.

Add generic linker test cases accordingly expecting the same disassembly
from srec output produced as from ELF output produced by the MIPS/ELF
linker.
18 files changed:
bfd/elfxx-mips.c
ld/testsuite/ld-mips-elf/micromips-hilo-n64.d
ld/testsuite/ld-mips-elf/micromips-hilo-srec-n32.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/micromips-hilo-srec-n64.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/micromips-hilo-srec.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/micromips-hilo.d
ld/testsuite/ld-mips-elf/mips-elf.exp
ld/testsuite/ld-mips-elf/mips-hilo-n64.d
ld/testsuite/ld-mips-elf/mips-hilo-srec-n32.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips-hilo-srec-n64.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips-hilo-srec.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips-hilo.d
ld/testsuite/ld-mips-elf/mips16-hilo-srec-n32.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16-hilo-srec.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16-hilo.d
ld/testsuite/ld-mips-elf/mips16e2-hilo-srec-n32.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16e2-hilo-srec.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16e2-hilo.d