[RFC PATCH 08/17] hppa: give the field size of relocations
Harshit Kumar
harshit7kr@gmail.com
Mon Nov 16 18:43:24 GMT 2026
The hppa howtos have no dst_mask, as elf_hppa_final_link_relocate
applies each field itself, so a relocation offset check that took a
howto with no dst_mask for a marker would skip every hppa relocation.
Give the field size through elf_backend_reloc_field_size instead: the
howto size, or 0 for a relocation with no bitsize. The linker passes
the ELF64 type for hppa64, so its types do not alias.
bfd/
* elf-hppa.h (elf_hppa_reloc_field_size): New function.
* elf32-hppa.c (elf_backend_reloc_field_size): Define.
* elf64-hppa.c (elf_backend_reloc_field_size): Define.
Signed-off-by: Harshit Kumar <harshit7kr@gmail.com>
---
bfd/elf-hppa.h | 25 +++++++++++++++++++++++++
bfd/elf32-hppa.c | 1 +
bfd/elf64-hppa.c | 1 +
3 files changed, 27 insertions(+)
diff --git a/bfd/elf-hppa.h b/bfd/elf-hppa.h
index d6e71b1e91..c1bba8dc1e 100644
--- a/bfd/elf-hppa.h
+++ b/bfd/elf-hppa.h
@@ -832,6 +832,31 @@ elf_hppa_info_to_howto_rel (bfd *abfd,
return true;
}
+/* Give the field size of every relocation, for the linker's relocation
+ offset check. The hppa howtos have no dst_mask, as
+ elf_hppa_final_link_relocate applies each field itself, so the
+ generic check would take them all for markers. Their size is right;
+ a relocation with no field has no bitsize. */
+
+static bool
+elf_hppa_reloc_field_size (const bfd *abfd ATTRIBUTE_UNUSED,
+ unsigned int r_type,
+ bool rel_p ATTRIBUTE_UNUSED,
+ unsigned int *size)
+{
+ reloc_howto_type *howto = NULL;
+
+ if (r_type < (unsigned int) R_PARISC_UNIMPLEMENTED)
+ howto = &elf_hppa_howto_table[r_type];
+ if (howto == NULL
+ || howto->type >= (unsigned int) R_PARISC_UNIMPLEMENTED
+ || howto->bitsize == 0)
+ *size = 0;
+ else
+ *size = bfd_get_reloc_size (howto);
+ return true;
+}
+
/* Return the address of the howto table entry to perform the CODE
relocation for an ARCH machine. */
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 8083dc8aae..fa846a735d 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -4528,6 +4528,7 @@ elf32_hppa_elf_get_symbol_type (Elf_Internal_Sym *elf_sym, int type)
#define bfd_elf32_bfd_reloc_name_lookup elf_hppa_reloc_name_lookup
#define elf_info_to_howto elf_hppa_info_to_howto
#define elf_info_to_howto_rel elf_hppa_info_to_howto_rel
+#define elf_backend_reloc_field_size elf_hppa_reloc_field_size
/* Stuff for the BFD linker. */
#define bfd_elf32_bfd_final_link elf32_hppa_final_link
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index f5c02ee843..6896335812 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -4524,6 +4524,7 @@ static const struct elf_size_info hppa64_elf_size_info =
#define bfd_elf64_bfd_is_local_label_name elf_hppa_is_local_label_name
#define elf_info_to_howto elf_hppa_info_to_howto
#define elf_info_to_howto_rel elf_hppa_info_to_howto_rel
+#define elf_backend_reloc_field_size elf_hppa_reloc_field_size
#define elf_backend_section_from_shdr elf64_hppa_section_from_shdr
#define elf_backend_object_p elf64_hppa_object_p
--
2.55.0
More information about the Binutils
mailing list