mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-25 21:41:47 +08:00
Discard space for relocs against symbols with copy relocs
This patch reverts the change in elf_x86_64_check_relocs and the partial change in elf_x86_64_adjust_dynamic_symbol. Instead, we discard space in PIE for relocs against symbols which turn out to need copy relocs. * elf64-x86-64.c (elf_x86_64_check_relocs): Revert the last change. (elf_x86_64_adjust_dynamic_symbol): Don't check !info->shared with ELIMINATE_COPY_RELOCS. (elf_x86_64_allocate_dynrelocs): For PIE, discard space for relocs against symbols which turn out to need copy relocs.
This commit is contained in:
@ -1,3 +1,12 @@
|
|||||||
|
2014-12-02 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
* elf64-x86-64.c (elf_x86_64_check_relocs): Revert the last
|
||||||
|
change.
|
||||||
|
(elf_x86_64_adjust_dynamic_symbol): Don't check !info->shared
|
||||||
|
with ELIMINATE_COPY_RELOCS.
|
||||||
|
(elf_x86_64_allocate_dynrelocs): For PIE, discard space for
|
||||||
|
relocs against symbols which turn out to need copy relocs.
|
||||||
|
|
||||||
2014-12-02 H.J. Lu <hongjiu.lu@intel.com>
|
2014-12-02 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Always
|
* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Always
|
||||||
|
@ -1955,8 +1955,7 @@ do_size:
|
|||||||
storing information in the relocs_copied field of the hash
|
storing information in the relocs_copied field of the hash
|
||||||
table entry. A similar situation occurs when creating
|
table entry. A similar situation occurs when creating
|
||||||
shared libraries and symbol visibility changes render the
|
shared libraries and symbol visibility changes render the
|
||||||
symbol local. We allow copy relocs for non-GOT pc-relative
|
symbol local.
|
||||||
relocation.
|
|
||||||
|
|
||||||
If on the other hand, we are creating an executable, we
|
If on the other hand, we are creating an executable, we
|
||||||
may need to keep relocations for symbols satisfied by a
|
may need to keep relocations for symbols satisfied by a
|
||||||
@ -1966,7 +1965,6 @@ do_size:
|
|||||||
&& (sec->flags & SEC_ALLOC) != 0
|
&& (sec->flags & SEC_ALLOC) != 0
|
||||||
&& (! IS_X86_64_PCREL_TYPE (r_type)
|
&& (! IS_X86_64_PCREL_TYPE (r_type)
|
||||||
|| (h != NULL
|
|| (h != NULL
|
||||||
&& !h->non_got_ref
|
|
||||||
&& (! SYMBOLIC_BIND (info, h)
|
&& (! SYMBOLIC_BIND (info, h)
|
||||||
|| h->root.type == bfd_link_hash_defweak
|
|| h->root.type == bfd_link_hash_defweak
|
||||||
|| !h->def_regular))))
|
|| !h->def_regular))))
|
||||||
@ -2402,7 +2400,7 @@ elf_x86_64_adjust_dynamic_symbol (struct bfd_link_info *info,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ELIMINATE_COPY_RELOCS && !info->shared)
|
if (ELIMINATE_COPY_RELOCS)
|
||||||
{
|
{
|
||||||
eh = (struct elf_x86_64_link_hash_entry *) h;
|
eh = (struct elf_x86_64_link_hash_entry *) h;
|
||||||
for (p = eh->dyn_relocs; p != NULL; p = p->next)
|
for (p = eh->dyn_relocs; p != NULL; p = p->next)
|
||||||
@ -2719,8 +2717,9 @@ elf_x86_64_allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
|
|||||||
|
|
||||||
/* Also discard relocs on undefined weak syms with non-default
|
/* Also discard relocs on undefined weak syms with non-default
|
||||||
visibility. */
|
visibility. */
|
||||||
if (eh->dyn_relocs != NULL
|
if (eh->dyn_relocs != NULL)
|
||||||
&& h->root.type == bfd_link_hash_undefweak)
|
{
|
||||||
|
if (h->root.type == bfd_link_hash_undefweak)
|
||||||
{
|
{
|
||||||
if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
|
if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
|
||||||
eh->dyn_relocs = NULL;
|
eh->dyn_relocs = NULL;
|
||||||
@ -2732,7 +2731,14 @@ elf_x86_64_allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
|
|||||||
&& ! bfd_elf_link_record_dynamic_symbol (info, h))
|
&& ! bfd_elf_link_record_dynamic_symbol (info, h))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
/* For PIE, discard space for relocs against symbols which
|
||||||
|
turn out to need copy relocs. */
|
||||||
|
else if (info->executable
|
||||||
|
&& h->needs_copy
|
||||||
|
&& h->def_dynamic
|
||||||
|
&& !h->def_regular)
|
||||||
|
eh->dyn_relocs = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (ELIMINATE_COPY_RELOCS)
|
else if (ELIMINATE_COPY_RELOCS)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user