mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-24 20:28:28 +08:00
nios2: 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-nios2.c (nios2_elf32_relocate_section): Don't generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true. (allocate_dynrelocs): Discard dynamic relocations 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-nios2.c (nios2_elf32_relocate_section): Don't generate
|
||||||
|
dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
|
||||||
|
(allocate_dynrelocs): Discard dynamic relocations 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
|
||||||
|
@ -3772,6 +3772,10 @@ nios2_elf32_relocate_section (bfd *output_bfd,
|
|||||||
|
|
||||||
if (howto)
|
if (howto)
|
||||||
{
|
{
|
||||||
|
bfd_boolean resolved_to_zero;
|
||||||
|
|
||||||
|
resolved_to_zero = (h != NULL
|
||||||
|
&& UNDEFWEAK_NO_DYNAMIC_RELOC (info, h));
|
||||||
switch (howto->type)
|
switch (howto->type)
|
||||||
{
|
{
|
||||||
case R_NIOS2_HI16:
|
case R_NIOS2_HI16:
|
||||||
@ -4004,7 +4008,8 @@ nios2_elf32_relocate_section (bfd *output_bfd,
|
|||||||
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 -Bsymbolic
|
/* This is actually a static link, or it is a -Bsymbolic
|
||||||
@ -4258,7 +4263,8 @@ nios2_elf32_relocate_section (bfd *output_bfd,
|
|||||||
|
|
||||||
if ((bfd_link_pic (info) || indx != 0)
|
if ((bfd_link_pic (info) || indx != 0)
|
||||||
&& (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))
|
||||||
{
|
{
|
||||||
need_relocs = TRUE;
|
need_relocs = TRUE;
|
||||||
@ -4387,7 +4393,8 @@ nios2_elf32_relocate_section (bfd *output_bfd,
|
|||||||
if (bfd_link_pic (info)
|
if (bfd_link_pic (info)
|
||||||
&& (input_section->flags & SEC_ALLOC) != 0
|
&& (input_section->flags & SEC_ALLOC) != 0
|
||||||
&& (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))
|
||||||
{
|
{
|
||||||
Elf_Internal_Rela outrel;
|
Elf_Internal_Rela outrel;
|
||||||
@ -5752,7 +5759,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, PTR 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
|
||||||
|
Reference in New Issue
Block a user