mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-24 04:00:07 +08:00
Correct elf64-ppc.c handling of protected symbols
Some places in elf64-ppc.c carelessly used SYMBOL_CALLS_LOCAL when the proper test is SYMBOL_REFERENCES_LOCAL for cases where we take the address of a protected symbol. This works OK for function descriptors but not for ELFv2. Setting symbols to their global entry stub a little earlier is to ensure _bfd_elf_hash_symbol allows such symbols in .gnu.hash. * elf64-ppc.c (ppc64_elf_edit_toc): Use SYMBOL_REFERENCES_LOCAL here, not SYMBOL_CALLS_LOCAL. (ppc64_elf_relocate_section): Likewise. (size_global_entry_stubs): Set undefined symbols on their global entry stubs here.. (build_global_entry_stubs): ..rather than here. (ppc64_elf_build_stubs): Don't reset glink->size before calling build_global_entry_stubs.
This commit is contained in:
@ -1,3 +1,14 @@
|
|||||||
|
2013-11-11 Ulrich Weigand <uweigand@de.ibm.com>
|
||||||
|
|
||||||
|
* elf64-ppc.c (ppc64_elf_edit_toc): Use SYMBOL_REFERENCES_LOCAL
|
||||||
|
here, not SYMBOL_CALLS_LOCAL.
|
||||||
|
(ppc64_elf_relocate_section): Likewise.
|
||||||
|
(size_global_entry_stubs): Set undefined symbols on their global
|
||||||
|
entry stubs here..
|
||||||
|
(build_global_entry_stubs): ..rather than here.
|
||||||
|
(ppc64_elf_build_stubs): Don't reset glink->size before calling
|
||||||
|
build_global_entry_stubs.
|
||||||
|
|
||||||
2013-11-07 Roland McGrath <mcgrathr@google.com>
|
2013-11-07 Roland McGrath <mcgrathr@google.com>
|
||||||
|
|
||||||
* archures.c (bfd_mach_i386_nacl): Fix definition so it doesn't
|
* archures.c (bfd_mach_i386_nacl): Fix definition so it doesn't
|
||||||
|
@ -8698,7 +8698,7 @@ ppc64_elf_edit_toc (struct bfd_link_info *info)
|
|||||||
|| discarded_section (sym_sec))
|
|| discarded_section (sym_sec))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!SYMBOL_CALLS_LOCAL (info, h))
|
if (!SYMBOL_REFERENCES_LOCAL (info, h))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (h != NULL)
|
if (h != NULL)
|
||||||
@ -9545,7 +9545,13 @@ size_global_entry_stubs (struct elf_link_hash_entry *h, void *inf)
|
|||||||
if (pent->plt.offset != (bfd_vma) -1
|
if (pent->plt.offset != (bfd_vma) -1
|
||||||
&& pent->addend == 0)
|
&& pent->addend == 0)
|
||||||
{
|
{
|
||||||
|
/* For ELFv2, if this symbol is not defined in a regular file
|
||||||
|
and we are not generating a shared library or pie, then we
|
||||||
|
need to define the symbol in the executable on a call stub.
|
||||||
|
This is to avoid text relocations. */
|
||||||
s->size = (s->size + 15) & -16;
|
s->size = (s->size + 15) & -16;
|
||||||
|
h->root.u.def.section = s;
|
||||||
|
h->root.u.def.value = s->size;
|
||||||
s->size += 16;
|
s->size += 16;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -12381,13 +12387,6 @@ build_global_entry_stubs (struct elf_link_hash_entry *h, void *inf)
|
|||||||
asection *plt;
|
asection *plt;
|
||||||
bfd_vma off;
|
bfd_vma off;
|
||||||
|
|
||||||
/* For ELFv2, if this symbol is not defined in a regular file
|
|
||||||
and we are not generating a shared library or pie, then we
|
|
||||||
need to define the symbol in the executable on a call stub.
|
|
||||||
This is to avoid text relocations. */
|
|
||||||
h->root.u.def.section = s;
|
|
||||||
h->root.u.def.value = s->size;
|
|
||||||
s->size += 16;
|
|
||||||
p = s->contents + h->root.u.def.value;
|
p = s->contents + h->root.u.def.value;
|
||||||
plt = htab->elf.splt;
|
plt = htab->elf.splt;
|
||||||
if (!htab->elf.dynamic_sections_created
|
if (!htab->elf.dynamic_sections_created
|
||||||
@ -12583,10 +12582,7 @@ ppc64_elf_build_stubs (bfd_boolean emit_stub_syms,
|
|||||||
|
|
||||||
/* Build .glink global entry stubs. */
|
/* Build .glink global entry stubs. */
|
||||||
if (htab->glink->size > htab->glink->rawsize)
|
if (htab->glink->size > htab->glink->rawsize)
|
||||||
{
|
elf_link_hash_traverse (&htab->elf, build_global_entry_stubs, info);
|
||||||
htab->glink->size = (htab->glink->rawsize + 15) & -16;
|
|
||||||
elf_link_hash_traverse (&htab->elf, build_global_entry_stubs, info);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (htab->brlt->size != 0)
|
if (htab->brlt->size != 0)
|
||||||
@ -13856,7 +13852,7 @@ ppc64_elf_relocate_section (bfd *output_bfd,
|
|||||||
if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared,
|
if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared,
|
||||||
&h->elf)
|
&h->elf)
|
||||||
|| (info->shared
|
|| (info->shared
|
||||||
&& SYMBOL_CALLS_LOCAL (info, &h->elf)))
|
&& SYMBOL_REFERENCES_LOCAL (info, &h->elf)))
|
||||||
/* This is actually a static link, or it is a
|
/* This is actually a static link, or it is a
|
||||||
-Bsymbolic link and the symbol is defined
|
-Bsymbolic link and the symbol is defined
|
||||||
locally, or the symbol was forced to be local
|
locally, or the symbol was forced to be local
|
||||||
@ -14241,7 +14237,7 @@ ppc64_elf_relocate_section (bfd *output_bfd,
|
|||||||
|
|
||||||
if (skip)
|
if (skip)
|
||||||
memset (&outrel, 0, sizeof outrel);
|
memset (&outrel, 0, sizeof outrel);
|
||||||
else if (!SYMBOL_CALLS_LOCAL (info, &h->elf)
|
else if (!SYMBOL_REFERENCES_LOCAL (info, &h->elf)
|
||||||
&& !is_opd
|
&& !is_opd
|
||||||
&& r_type != R_PPC64_TOC)
|
&& r_type != R_PPC64_TOC)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user