[PATCH v2 3/3] Support relocation for weak references
Evgeny Karpov
Evgeny.Karpov@microsoft.com
Mon Nov 18 11:16:24 GMT 2024
This patch adds handling weak referencies in similar way how it is
done in _bfd_coff_generic_relocate_section.
bfd/ChangeLog:
* coff-aarch64.c (coff_pe_aarch64_relocate_section): Support
weak references.
---
bfd/coff-aarch64.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/bfd/coff-aarch64.c b/bfd/coff-aarch64.c
index 84af335b3a0..23b1e7da37f 100644
--- a/bfd/coff-aarch64.c
+++ b/bfd/coff-aarch64.c
@@ -522,11 +522,30 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd,
h = obj_coff_sym_hashes (input_bfd)[symndx];
- if (h && h->root.type == bfd_link_hash_defined)
+ if (h && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak))
{
sec = h->root.u.def.section;
sym_value = h->root.u.def.value;
}
+ else if (h && h->root.type == bfd_link_hash_undefweak
+ && h->symbol_class == C_NT_WEAK && h->numaux == 1)
+ {
+ struct coff_link_hash_entry *h2;
+ h2 = h->auxbfd->tdata.coff_obj_data->sym_hashes
+ [h->aux->x_sym.x_tagndx.u32];
+
+ if (!h2 || h2->root.type == bfd_link_hash_undefined)
+ {
+ sec = bfd_abs_section_ptr;
+ sym_value = 0;
+ }
+ else
+ {
+ sec = h2->root.u.def.section;
+ sym_value = h2->root.u.def.value;
+ }
+ }
else
{
sec = sections[symndx];
--
2.34.1
More information about the Binutils
mailing list