diff options
author | Alan Modra <amodra@gmail.com> | 2018-03-14 22:09:33 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2018-03-14 22:20:11 +1030 |
commit | 7dda8d3cf3b089bb7e03c4cdbec827fc6a188c88 (patch) | |
tree | bb8a493a0728547a8f7707933106dca3f1c3debb | |
parent | 9e223787a474c672c5f1cfd4574857241ae4eafa (diff) | |
download | gdb-7dda8d3cf3b089bb7e03c4cdbec827fc6a188c88.zip gdb-7dda8d3cf3b089bb7e03c4cdbec827fc6a188c88.tar.gz gdb-7dda8d3cf3b089bb7e03c4cdbec827fc6a188c88.tar.bz2 |
PowerPC64 debian bug 886264, out-of-line save/restore functions
This calculation in relocate_section
if (stub_entry->stub_type == ppc_stub_save_res)
relocation += (stub_sec->output_offset
+ stub_sec->output_section->vma
+ stub_sec->size - htab->sfpr->size
- htab->sfpr->output_offset
- htab->sfpr->output_section->vma);
to adjust from the original out-of-line save/restore function address
in sfpr to a copy at the end of stub_sec goes wrong when stub_sec is
padded, because the copy is no longer at the end of stub_sec. The
solution is to pad before copying sfpr, so the copy is always at the
end of stub_sec.
* elf64-ppc.c (sfpr_define): Adjust for stub_sec size having
sfpr size added before defining alias symbols.
(ppc64_elf_build_stubs): Add stub section padding before
copying sfpr contents and defining save/restore alias symbols.
-rw-r--r-- | bfd/ChangeLog | 7 | ||||
-rw-r--r-- | bfd/elf64-ppc.c | 33 |
2 files changed, 25 insertions, 15 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index ad971fc..fac9b62 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2018-03-14 Alan Modra <amodra@gmail.com> + + * elf64-ppc.c (sfpr_define): Adjust for stub_sec size having + sfpr size added before defining alias symbols. + (ppc64_elf_build_stubs): Add stub section padding before + copying sfpr contents and defining save/restore alias symbols. + 2018-03-14 H.J. Lu <hongjiu.lu@intel.com> PR ld/20882 diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 44237bc..889bdb0 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -6660,7 +6660,7 @@ sfpr_define (struct bfd_link_info *info, { s->root.type = bfd_link_hash_defined; s->root.u.def.section = stub_sec; - s->root.u.def.value = (stub_sec->size + s->root.u.def.value = (stub_sec->size - htab->sfpr->size + h->elf.root.u.def.value); s->ref_regular = 1; s->def_regular = 1; @@ -13247,20 +13247,7 @@ ppc64_elf_build_stubs (struct bfd_link_info *info, for (group = htab->group; group != NULL; group = group->next) if (group->needs_save_res) - { - stub_sec = group->stub_sec; - memcpy (stub_sec->contents + stub_sec->size, htab->sfpr->contents, - htab->sfpr->size); - if (htab->params->emit_stub_syms) - { - unsigned int i; - - for (i = 0; i < ARRAY_SIZE (save_res_funcs); i++) - if (!sfpr_define (info, &save_res_funcs[i], stub_sec)) - return FALSE; - } - stub_sec->size += htab->sfpr->size; - } + group->stub_sec->size += htab->sfpr->size; if (htab->relbrlt != NULL) htab->relbrlt->reloc_count = 0; @@ -13274,6 +13261,22 @@ ppc64_elf_build_stubs (struct bfd_link_info *info, } for (group = htab->group; group != NULL; group = group->next) + if (group->needs_save_res) + { + stub_sec = group->stub_sec; + memcpy (stub_sec->contents + stub_sec->size - htab->sfpr->size, + htab->sfpr->contents, htab->sfpr->size); + if (htab->params->emit_stub_syms) + { + unsigned int i; + + for (i = 0; i < ARRAY_SIZE (save_res_funcs); i++) + if (!sfpr_define (info, &save_res_funcs[i], stub_sec)) + return FALSE; + } + } + + for (group = htab->group; group != NULL; group = group->next) if ((stub_sec = group->stub_sec) != NULL) { stub_sec_count += 1; |