diff options
author | Jan Beulich <jbeulich@suse.com> | 2025-08-26 10:43:06 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2025-08-26 10:43:06 +0200 |
commit | 71897894a941967f50764a7e65ba44f28c137091 (patch) | |
tree | 3285b79bac421e4866689ec2cf3d5c20ba6e1aa3 | |
parent | 6f9157ad377e8ff61a0f96f0e7b47babbc2b014e (diff) | |
download | binutils-71897894a941967f50764a7e65ba44f28c137091.zip binutils-71897894a941967f50764a7e65ba44f28c137091.tar.gz binutils-71897894a941967f50764a7e65ba44f28c137091.tar.bz2 |
ld/PE: don't emit relocations for weak absolute symbols
First we should check the flag alone, not the entire flags value
matching BSF_WEAK. And then using "else if()" is inappropriate here: A
weak symbol can very well also be absolute, and hence wouldn't want a
relocation emitted despite being defined.
-rw-r--r-- | ld/pe-dll.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/ld/pe-dll.c b/ld/pe-dll.c index 210b77e..c730b54 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -1630,9 +1630,8 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info) const struct bfd_link_hash_entry *blhe = bfd_wrapped_link_hash_lookup (abfd, info, sym->name, false, false, false); - /* Don't create relocs for undefined weak symbols. */ - if (sym->flags == BSF_WEAK) + if (sym->flags & BSF_WEAK) { if (blhe && blhe->type == bfd_link_hash_undefweak) { @@ -1657,7 +1656,7 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info) continue; } /* Nor for Dwarf FDE references to discarded sections. */ - else if (bfd_is_abs_section (sym->section->output_section)) + if (bfd_is_abs_section (sym->section->output_section)) { /* We only ignore relocs from .eh_frame sections, as they are discarded by the final link rather than @@ -1666,10 +1665,10 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info) continue; } /* Nor for absolute symbols. */ - else if (blhe && ldexp_is_final_sym_absolute (blhe) - && (!blhe->linker_def - || (strcmp (sym->name, "__image_base__") - && strcmp (sym->name, U ("__ImageBase"))))) + if (blhe && ldexp_is_final_sym_absolute (blhe) + && (!blhe->linker_def + || (strcmp (sym->name, "__image_base__") + && strcmp (sym->name, U ("__ImageBase"))))) continue; reloc_data[total_relocs].vma = sec_vma + relocs[i]->address; |