[RFC PATCH 06/17] mn10300: give SYM_DIFF relocations no field
Harshit Kumar
harshit7kr@gmail.com
Mon Nov 16 18:43:22 GMT 2026
MN10300 describes a symbol difference as R_MN10300_SYM_DIFF, which only
computes a value, followed at the same offset by the relocation that
writes the field, which may be 1 or 2 octets. The SYM_DIFF 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 SYM_DIFF a field size of 0.
bfd/
* elf-m10300.c (mn10300_elf_reloc_field_size): New function.
(elf_backend_reloc_field_size): Define.
Signed-off-by: Harshit Kumar <harshit7kr@gmail.com>
---
bfd/elf-m10300.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index 808fd9ac58..8244ffa45a 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -5467,6 +5467,22 @@ mn10300_elf_mkobject (bfd *abfd)
#define bfd_elf32_mkobject mn10300_elf_mkobject
+/* R_MN10300_SYM_DIFF only computes a value for the next relocation at
+ the same offset, which writes the field. Its howto size is 4, but
+ that field may be smaller and end the section. */
+
+static bool
+mn10300_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_MN10300_SYM_DIFF)
+ return false;
+ *size = 0;
+ return true;
+}
+
#ifndef ELF_ARCH
#define TARGET_LITTLE_SYM mn10300_elf32_vec
#define TARGET_LITTLE_NAME "elf32-mn10300"
@@ -5479,6 +5495,7 @@ mn10300_elf_mkobject (bfd *abfd)
#define elf_info_to_howto mn10300_info_to_howto
#define elf_info_to_howto_rel NULL
+#define elf_backend_reloc_field_size mn10300_elf_reloc_field_size
#define elf_backend_can_gc_sections 1
#define elf_backend_rela_normal 1
#define elf_backend_check_relocs mn10300_elf_check_relocs
--
2.55.0
More information about the Binutils
mailing list