diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2016-06-13 11:06:10 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2016-06-13 11:11:23 -0700 |
commit | 712ec27916b5604d29d928dec060fd1ba0fd9edb (patch) | |
tree | 221a14aa497e282aad40ccacf3bd8abbe30a9de8 /bfd/elf32-i386.c | |
parent | ca8c86efe7765262e25ebb08004012ba2fdadf52 (diff) | |
download | gdb-712ec27916b5604d29d928dec060fd1ba0fd9edb.zip gdb-712ec27916b5604d29d928dec060fd1ba0fd9edb.tar.gz gdb-712ec27916b5604d29d928dec060fd1ba0fd9edb.tar.bz2 |
Add the GOT base for GOT32 relocs against IFUNC
Add the GOT base for R_386_GOT32/R_386_GOT32X relocations against IFUNC
symbols if there is no base register and disallow them for PIC.
bfd/
PR ld/20244
* elf32-i386.c (elf_i386_relocate_section): Add the .got.plt
section address for R_386_GOT32/R_386_GOT32X relocations against
IFUNC symbols if there is no base register and return error for
PIC.
ld/
PR ld/20244
* testsuite/ld-i386/i386.exp: Run pr20244-2a, pr20244-2b,
pr20244-2c and pr20244-2d.
* testsuite/ld-i386/no-plt.exp: Run pr20244-3a and pr20244-3b.
* testsuite/ld-i386/pr20244-2.s: New file.
* testsuite/ld-i386/pr20244-2a.d: Likewise.
* testsuite/ld-i386/pr20244-2b.d: Likewise.
* testsuite/ld-i386/pr20244-2c.d: Likewise.
* testsuite/ld-i386/pr20244-2d.d: Likewise.
* testsuite/ld-i386/pr20244-3a.c: Likewise.
* testsuite/ld-i386/pr20244-3b.S: Likewise.
* testsuite/ld-i386/pr20244-3c.S: Likewise.
* testsuite/ld-i386/pr20244-3d.S: Likewise.
Diffstat (limited to 'bfd/elf32-i386.c')
-rw-r--r-- | bfd/elf32-i386.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index fbbf4ab..a68ce1f 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -4039,9 +4039,20 @@ elf_i386_relocate_section (bfd *output_bfd, - gotplt->output_section->vma - gotplt->output_offset); - /* Adjust for static executables. */ - if (htab->elf.splt == NULL) - relocation += gotplt->output_offset; + if ((*(contents + rel->r_offset - 1) & 0xc7) == 0x5) + { + if (bfd_link_pic (info)) + goto disallow_got32; + + /* Add the GOT base if there is no base register. */ + relocation += (gotplt->output_section->vma + + gotplt->output_offset); + } + else if (htab->elf.splt == NULL) + { + /* Adjust for static executables. */ + relocation += gotplt->output_offset; + } goto do_relocation; @@ -4214,6 +4225,7 @@ r_386_got32: is. */ const char *name; +disallow_got32: if (h == NULL) name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym, NULL); @@ -4221,8 +4233,8 @@ r_386_got32: name = h->root.root.string; (*_bfd_error_handler) - (_("%B: direct GOT relocation R_386_GOT32 against `%s' without base register can not be used when making a shared object"), - input_bfd, name); + (_("%B: direct GOT relocation %s against `%s' without base register can not be used when making a shared object"), + input_bfd, howto->name, name); bfd_set_error (bfd_error_bad_value); return FALSE; } |