mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-23 03:29:47 +08:00
tile: 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-tilepro.c (allocate_dynrelocs): Discard dynamic relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true. (tilepro_elf_relocate_section): Don't generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true. * elfxx-tilegx.c (allocate_dynrelocs): Discard dynamic relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true. (tilegx_elf_relocate_section): Don't generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
This commit is contained in:
@ -1,3 +1,15 @@
|
|||||||
|
2017-10-14 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
PR ld/22269
|
||||||
|
* elf32-tilepro.c (allocate_dynrelocs): Discard dynamic
|
||||||
|
relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
|
||||||
|
(tilepro_elf_relocate_section): Don't generate dynamic
|
||||||
|
relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
|
||||||
|
* elfxx-tilegx.c (allocate_dynrelocs): Discard dynamic
|
||||||
|
relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
|
||||||
|
(tilegx_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
|
||||||
|
@ -2332,7 +2332,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
|
||||||
@ -2860,7 +2861,7 @@ tilepro_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
|
|||||||
const char *name;
|
const char *name;
|
||||||
bfd_vma off;
|
bfd_vma off;
|
||||||
bfd_boolean is_plt = FALSE;
|
bfd_boolean is_plt = FALSE;
|
||||||
|
bfd_boolean resolved_to_zero;
|
||||||
bfd_boolean unresolved_reloc;
|
bfd_boolean unresolved_reloc;
|
||||||
|
|
||||||
r_type = ELF32_R_TYPE (rel->r_info);
|
r_type = ELF32_R_TYPE (rel->r_info);
|
||||||
@ -3035,6 +3036,9 @@ tilepro_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolved_to_zero = (h != NULL
|
||||||
|
&& UNDEFWEAK_NO_DYNAMIC_RELOC (info, h));
|
||||||
|
|
||||||
switch (r_type)
|
switch (r_type)
|
||||||
{
|
{
|
||||||
case R_TILEPRO_IMM16_X0_GOT:
|
case R_TILEPRO_IMM16_X0_GOT:
|
||||||
@ -3203,7 +3207,8 @@ tilepro_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
|
|||||||
|
|
||||||
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)
|
||||||
&& (! howto->pc_relative
|
&& (! howto->pc_relative
|
||||||
|| !SYMBOL_CALLS_LOCAL (info, h)))
|
|| !SYMBOL_CALLS_LOCAL (info, h)))
|
||||||
|
@ -2599,7 +2599,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
|
||||||
@ -3159,7 +3160,7 @@ tilegx_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
|
|||||||
const char *name;
|
const char *name;
|
||||||
bfd_vma off;
|
bfd_vma off;
|
||||||
bfd_boolean is_plt = FALSE;
|
bfd_boolean is_plt = FALSE;
|
||||||
|
bfd_boolean resolved_to_zero;
|
||||||
bfd_boolean unresolved_reloc;
|
bfd_boolean unresolved_reloc;
|
||||||
|
|
||||||
r_type = TILEGX_ELF_R_TYPE (rel->r_info);
|
r_type = TILEGX_ELF_R_TYPE (rel->r_info);
|
||||||
@ -3413,6 +3414,9 @@ tilegx_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolved_to_zero = (h != NULL
|
||||||
|
&& UNDEFWEAK_NO_DYNAMIC_RELOC (info, h));
|
||||||
|
|
||||||
switch (r_type)
|
switch (r_type)
|
||||||
{
|
{
|
||||||
case R_TILEGX_IMM16_X0_HW0_GOT:
|
case R_TILEGX_IMM16_X0_HW0_GOT:
|
||||||
@ -3610,7 +3614,8 @@ tilegx_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
|
|||||||
|
|
||||||
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)
|
||||||
&& (! howto->pc_relative
|
&& (! howto->pc_relative
|
||||||
|| !SYMBOL_CALLS_LOCAL (info, h)))
|
|| !SYMBOL_CALLS_LOCAL (info, h)))
|
||||||
|
Reference in New Issue
Block a user