[binutils-gdb] MIPS/BFD: Use helper function for LO relocation sign-extension
Maciej W. Rozycki
macro@sourceware.org
Sat Jul 12 00:34:18 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=509dbc2bf167f9afb42d8b20200b529acc0d1ee9
commit 509dbc2bf167f9afb42d8b20200b529acc0d1ee9
Author: Maciej W. Rozycki <macro@orcam.me.uk>
Date: Sat Jul 12 01:25:53 2025 +0100
MIPS/BFD: Use helper function for LO relocation sign-extension
A calculation for LO relocations has been recently fixed with commit
ce08b3bb19b3 ("MIPS/BFD: Fix RELA handling of borrow in the generic
linker"), however it was missed that for the updated arithmetic we
already have a helper function available, `_bfd_mips_elf_sign_extend'.
Replace the open-coded statement then with an equivalent call to said
function. No functional change.
Diff:
---
bfd/elfxx-mips.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 530e8d63ddc..6f323289ad6 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -2605,7 +2605,7 @@ _bfd_mips_elf_lo16_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
and we want to apply (symbol + addend + 0x8000) >> 16 to the
high insn (the +0x8000 adjusting for when the applied low part is
negative). */
- vallo = ((bfd_get_32 (abfd, location) & 0xffff) ^ 0x8000) - 0x8000;
+ vallo = _bfd_mips_elf_sign_extend (bfd_get_32 (abfd, location) & 0xffff, 16);
_bfd_mips_elf_reloc_shuffle (abfd, reloc_entry->howto->type, false,
location);
More information about the Binutils-cvs
mailing list