diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-06-24 13:37:05 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-06-24 13:47:37 -0700 |
commit | 7c1e8d3ed5e48b3339d60450fdb5b29ae54edebe (patch) | |
tree | ce3e0e7af01292717cbefddead2daf16038c4b74 /bfd/elf64-x86-64.c | |
parent | f91ca6bc00c1e3c70c1d2f4527d4297b76e2eaca (diff) | |
download | gdb-7c1e8d3ed5e48b3339d60450fdb5b29ae54edebe.zip gdb-7c1e8d3ed5e48b3339d60450fdb5b29ae54edebe.tar.gz gdb-7c1e8d3ed5e48b3339d60450fdb5b29ae54edebe.tar.bz2 |
Keep .plt section and DT_PLTGOT for prelink
Since the .plt section and DT_PLTGOT are used by prelink to undo
prelinking for dynamic relocations, we must keep them even if there is
no PLT relocation. This patch reverted commit a3747075a.
bfd/
* elf32-i386.c (elf_i386_allocate_dynrelocs): Always allocate
space for the first .plt entry.
(elf_i386_size_dynamic_sections): Always add DT_PLTGOT for .plt
section. Add DT_PLTRELSZ, DT_PLTREL and DT_JMPREL only if
there are PLT relocations.
* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Always
allocate space for the first .plt entry.
(elf_x86_64_size_dynamic_sections): Always add DT_PLTGOT for
.plt section. Add DT_PLTRELSZ, DT_PLTREL and DT_JMPREL only if
there are PLT relocations.
ld/testsuite/
* ld-i386/i386.exp: Run pltgot-2 for Linux targets.
* ld-x86-64/x86-64.exp: Likewise.
* ld-i386/pltgot-1.d: Updated.
* ld-x86-64/pltgot-1.d: Likewise.
* ld-i386/pltgot-2.d: New file.
* ld-x86-64/pltgot-2.d: Likewise.
Diffstat (limited to 'bfd/elf64-x86-64.c')
-rw-r--r-- | bfd/elf64-x86-64.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index f7aea98..fb22602 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -2571,14 +2571,16 @@ elf_x86_64_allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) asection *bnd_s = htab->plt_bnd; asection *got_s = htab->plt_got; + /* If this is the first .plt entry, make room for the special + first entry. The .plt section is used by prelink to undo + prelinking for dynamic relocations. */ + if (s->size == 0) + s->size = plt_entry_size; + if (use_plt_got) eh->plt_got.offset = got_s->size; else { - /* If this is the first .plt entry, make room for the - special first entry. */ - if (s->size == 0) - s->size = plt_entry_size; h->plt.offset = s->size; if (bnd_s) eh->plt_bnd.offset = bnd_s->size; @@ -3464,12 +3466,19 @@ elf_x86_64_size_dynamic_sections (bfd *output_bfd, if (htab->elf.splt->size != 0) { - if (!add_dynamic_entry (DT_PLTGOT, 0) - || !add_dynamic_entry (DT_PLTRELSZ, 0) - || !add_dynamic_entry (DT_PLTREL, DT_RELA) - || !add_dynamic_entry (DT_JMPREL, 0)) + /* DT_PLTGOT is used by prelink even if there is no PLT + relocation. */ + if (!add_dynamic_entry (DT_PLTGOT, 0)) return FALSE; + if (htab->elf.srelplt->size != 0) + { + if (!add_dynamic_entry (DT_PLTRELSZ, 0) + || !add_dynamic_entry (DT_PLTREL, DT_RELA) + || !add_dynamic_entry (DT_JMPREL, 0)) + return FALSE; + } + if (htab->tlsdesc_plt && (!add_dynamic_entry (DT_TLSDESC_PLT, 0) || !add_dynamic_entry (DT_TLSDESC_GOT, 0))) |