aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-i386.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-05-12 13:11:48 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-05-12 13:11:48 -0700
commita3747075ae478f27bf3e0643021a85fb6cdad0e3 (patch)
tree1ffd8565b79a36156fc3e391d79d9ecc6a7d4c63 /bfd/elf32-i386.c
parent98624574ea8834b2084eb1f0ca7341feecc7329f (diff)
downloadgdb-a3747075ae478f27bf3e0643021a85fb6cdad0e3.zip
gdb-a3747075ae478f27bf3e0643021a85fb6cdad0e3.tar.gz
gdb-a3747075ae478f27bf3e0643021a85fb6cdad0e3.tar.bz2
Allocate the first .plt entry space only if needed
Commit dd7e64d45b317128f5fe813a8da0b13b4ad046ae may optimize out i386/x86-64 JUMP_SLOT relocation. If there is no JUMP_SLOT relocation left, we don't need to the first .plt entry. This patch allocates space for the first .plt entry only if we also reserve space for a PLT slot for JUMP_SLOT relocation. bfd/ * elf32-i386.c (elf_i386_allocate_dynrelocs): Allocate space for the first .plt entry only if needed. * elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Likewise. ld/testsuite/ * ld-i386/i386.exp: Run pltgot-1 for Linux targets. * ld-x86-64/x86-64.exp: Likewise. * ld-i386/pltgot-1.d: New file. * ld-i386/pltgot-1.s: Likewise. * ld-x86-64/pltgot-1.d: Likewise. * ld-x86-64/pltgot-1.s: Likewise.
Diffstat (limited to 'bfd/elf32-i386.c')
-rw-r--r--bfd/elf32-i386.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index f7a7818..815473d 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -2338,15 +2338,16 @@ elf_i386_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
asection *s = htab->elf.splt;
asection *got_s = htab->plt_got;
- /* If this is the first .plt entry, make room for the special
- first entry. */
- if (s->size == 0)
- s->size = plt_entry_size;
-
if (use_plt_got)
eh->plt_got.offset = got_s->size;
else
- h->plt.offset = s->size;
+ {
+ /* 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 this symbol is not defined in a regular file, and we are
not generating a shared library, then set the symbol to this