[RFC PATCH 04/17] rx: give operand relocations no field
Harshit Kumar
harshit7kr@gmail.com
Mon Nov 16 18:43:20 GMT 2026
RX describes a symbol difference as several relocations at one offset.
R_RX_SYM and the R_RX_OP* relocations push or combine values on the
relocation stack and write nothing; only the relocation that pops the
stack writes the field, which may be 1 or 2 octets. Their howto size
is 4, so a relocation offset check that took it would reject a
difference such as ".byte foo - bar" in the last octets of a section.
Give these relocations a field size of 0.
bfd/
* elf32-rx.c (rx_elf_reloc_field_size): New function.
(elf_backend_reloc_field_size): Define.
Signed-off-by: Harshit Kumar <harshit7kr@gmail.com>
---
bfd/elf32-rx.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c
index c3c4bd90cf..4e4a88f034 100644
--- a/bfd/elf32-rx.c
+++ b/bfd/elf32-rx.c
@@ -4093,6 +4093,24 @@ rx_additional_link_map_text (bfd *obfd, struct bfd_link_info *info, FILE *mapfil
#define ELF_MACHINE_CODE EM_RX
#define ELF_MAXPAGESIZE 0x1000
+/* R_RX_SYM and the R_RX_OP* relocations push or combine values on the
+ relocation stack and write nothing; only the relocation that pops the
+ stack writes a field. Their howto size is 4, and the assembler puts
+ them at the offset of that field, which may be smaller and end the
+ section. */
+
+static bool
+rx_elf_reloc_field_size (const bfd *abfd ATTRIBUTE_UNUSED,
+ unsigned int r_type,
+ bool rel_p ATTRIBUTE_UNUSED,
+ unsigned int *size)
+{
+ if (r_type < R_RX_SYM || r_type > R_RX_OPramtop)
+ return false;
+ *size = 0;
+ return true;
+}
+
#define TARGET_BIG_SYM rx_elf32_be_vec
#define TARGET_BIG_NAME "elf32-rx-be"
@@ -4101,6 +4119,7 @@ rx_additional_link_map_text (bfd *obfd, struct bfd_link_info *info, FILE *mapfil
#define elf_info_to_howto_rel NULL
#define elf_info_to_howto rx_info_to_howto_rela
+#define elf_backend_reloc_field_size rx_elf_reloc_field_size
#define elf_backend_object_p rx_elf_object_p
#define elf_backend_relocate_section rx_elf_relocate_section
#define elf_symbol_leading_char ('_')
--
2.55.0
More information about the Binutils
mailing list