[committed] MIPS/BFD: Make `_bfd_mips_elf_sign_extend' static inline
Maciej W. Rozycki
macro@orcam.me.uk
Wed Mar 11 16:32:23 GMT 2026
Let the function be inlined from outside elfxx-mips.c as well, avoiding
the call overhead for a simple arithmetic calculation, though we have no
such user at the moment.
---
bfd/elfxx-mips.c | 9 ---------
bfd/elfxx-mips.h | 11 +++++++++--
2 files changed, 9 insertions(+), 11 deletions(-)
binutils-bfd-mips-elf-sign-extend-inline.diff
Index: binutils-gdb/bfd/elfxx-mips.c
===================================================================
--- binutils-gdb.orig/bfd/elfxx-mips.c
+++ binutils-gdb/bfd/elfxx-mips.c
@@ -5234,15 +5234,6 @@ mips_elf_local_relocation_p (bfd *input_
return false;
}
-/* Sign-extend VALUE, which has the indicated number of BITS. */
-
-bfd_vma
-_bfd_mips_elf_sign_extend (bfd_vma value, int bits)
-{
- bfd_vma sign = (bfd_vma) 1 << (bits - 1);
- return (value ^ sign) - sign;
-}
-
/* Return non-zero if the indicated VALUE has overflowed the maximum
range expressible by a signed number with the indicated number of
BITS. */
Index: binutils-gdb/bfd/elfxx-mips.h
===================================================================
--- binutils-gdb.orig/bfd/elfxx-mips.h
+++ binutils-gdb/bfd/elfxx-mips.h
@@ -168,8 +168,6 @@ extern bfd_reloc_status_type _bfd_mips_e
ATTRIBUTE_HIDDEN;
extern unsigned long _bfd_elf_mips_mach
(flagword);
-extern bfd_vma _bfd_mips_elf_sign_extend
- (bfd_vma, int) ATTRIBUTE_HIDDEN;
extern void _bfd_mips_elf_merge_symbol_attribute
(struct elf_link_hash_entry *, unsigned int, bool, bool) ATTRIBUTE_HIDDEN;
extern char *_bfd_mips_elf_get_target_dtag
@@ -226,6 +224,15 @@ literal_reloc_p (int r_type)
return r_type == R_MIPS_LITERAL || r_type == R_MICROMIPS_LITERAL;
}
+/* Sign-extend VALUE, which has the indicated number of BITS. */
+
+static inline bfd_vma
+_bfd_mips_elf_sign_extend (bfd_vma value, int bits)
+{
+ bfd_vma sign = (bfd_vma) 1 << (bits - 1);
+ return (value ^ sign) - sign;
+}
+
#define elf_backend_common_definition _bfd_mips_elf_common_definition
#define elf_backend_name_local_section_symbols \
_bfd_mips_elf_name_local_section_symbols
More information about the Binutils
mailing list