mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-26 13:56:22 +08:00
sh: Check UNDEFWEAK_NO_DYNAMIC_RELOC
Don't generate dynamic relocation against weak undefined symbol if it is resolved to zero. FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be checked in more places. PR ld/22269 * elf32-sh.c (allocate_dynrelocs): Discard dynamic relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true. (sh_elf_relocate_section): Don't generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
This commit is contained in:
@ -1,3 +1,11 @@
|
|||||||
|
2017-10-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
PR ld/22269
|
||||||
|
* elf32-sh.c (allocate_dynrelocs): Discard dynamic relocations
|
||||||
|
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
|
||||||
|
(sh_elf_relocate_section): Don't generate dynamic relocation if
|
||||||
|
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
|
||||||
|
|
||||||
2017-10-14 H.J. Lu <hongjiu.lu@intel.com>
|
2017-10-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
PR ld/22269
|
PR ld/22269
|
||||||
|
@ -3221,7 +3221,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
|
|||||||
if (eh->dyn_relocs != NULL
|
if (eh->dyn_relocs != NULL
|
||||||
&& h->root.type == bfd_link_hash_undefweak)
|
&& h->root.type == bfd_link_hash_undefweak)
|
||||||
{
|
{
|
||||||
if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
|
if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
|
||||||
|
|| UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
|
||||||
eh->dyn_relocs = NULL;
|
eh->dyn_relocs = NULL;
|
||||||
|
|
||||||
/* Make sure undefined weak symbols are output as a dynamic
|
/* Make sure undefined weak symbols are output as a dynamic
|
||||||
@ -3894,6 +3895,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
|
|||||||
bfd_vma off;
|
bfd_vma off;
|
||||||
enum got_type got_type;
|
enum got_type got_type;
|
||||||
const char *symname = NULL;
|
const char *symname = NULL;
|
||||||
|
bfd_boolean resolved_to_zero;
|
||||||
|
|
||||||
r_symndx = ELF32_R_SYM (rel->r_info);
|
r_symndx = ELF32_R_SYM (rel->r_info);
|
||||||
|
|
||||||
@ -3933,6 +3935,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
|
|||||||
if (! howto->partial_inplace)
|
if (! howto->partial_inplace)
|
||||||
addend = rel->r_addend;
|
addend = rel->r_addend;
|
||||||
|
|
||||||
|
resolved_to_zero = FALSE;
|
||||||
h = NULL;
|
h = NULL;
|
||||||
sym = NULL;
|
sym = NULL;
|
||||||
sec = NULL;
|
sec = NULL;
|
||||||
@ -4141,7 +4144,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (h->root.type == bfd_link_hash_undefweak)
|
else if (h->root.type == bfd_link_hash_undefweak)
|
||||||
;
|
resolved_to_zero = UNDEFWEAK_NO_DYNAMIC_RELOC (info, h);
|
||||||
else if (info->unresolved_syms_in_objects == RM_IGNORE
|
else if (info->unresolved_syms_in_objects == RM_IGNORE
|
||||||
&& ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
|
&& ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
|
||||||
;
|
;
|
||||||
@ -4309,7 +4312,8 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
|
|||||||
#endif
|
#endif
|
||||||
if (bfd_link_pic (info)
|
if (bfd_link_pic (info)
|
||||||
&& (h == NULL
|
&& (h == NULL
|
||||||
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|
|| (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|
||||||
|
&& !resolved_to_zero)
|
||||||
|| h->root.type != bfd_link_hash_undefweak)
|
|| h->root.type != bfd_link_hash_undefweak)
|
||||||
&& r_symndx != STN_UNDEF
|
&& r_symndx != STN_UNDEF
|
||||||
&& (input_section->flags & SEC_ALLOC) != 0
|
&& (input_section->flags & SEC_ALLOC) != 0
|
||||||
@ -4537,7 +4541,8 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
|
|||||||
h)
|
h)
|
||||||
|| (bfd_link_pic (info)
|
|| (bfd_link_pic (info)
|
||||||
&& SYMBOL_REFERENCES_LOCAL (info, h))
|
&& SYMBOL_REFERENCES_LOCAL (info, h))
|
||||||
|| (ELF_ST_VISIBILITY (h->other)
|
|| ((ELF_ST_VISIBILITY (h->other)
|
||||||
|
|| resolved_to_zero)
|
||||||
&& h->root.type == bfd_link_hash_undefweak))
|
&& h->root.type == bfd_link_hash_undefweak))
|
||||||
{
|
{
|
||||||
/* This is actually a static link, or it is a
|
/* This is actually a static link, or it is a
|
||||||
|
Reference in New Issue
Block a user