diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-09-30 08:32:45 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-09-30 08:45:13 -0700 |
commit | 4b627c18440f51077f8fd4c18adaa3919c3a373e (patch) | |
tree | 1bab6b77eaec81d3909f55ed8ac94b162a884549 /bfd | |
parent | ede5f15146ae45f4c017f5701629a4fa04ef2beb (diff) | |
download | gdb-4b627c18440f51077f8fd4c18adaa3919c3a373e.zip gdb-4b627c18440f51077f8fd4c18adaa3919c3a373e.tar.gz gdb-4b627c18440f51077f8fd4c18adaa3919c3a373e.tar.bz2 |
Create a PLT entry for R_386_PC32 in non-code sections
Since something like ".long foo - ." may be used as pointer, we make
sure that PLT is used if foo is a function defined in a shared library.
bfd/
PR ld/19031
* elf32-i386.c (elf_i386_check_relocs): Set
pointer_equality_needed for R_386_PC32 reloc in non-code
sections.
ld/testsuite/
PR ld/19031
* ld-i386/i386.exp: Run PR ld/19031 test.
* ld/testsuite/ld-i386/pr19031.out: New file.
* ld/testsuite/ld-i386/pr19031a.c: Likewise.
* ld/testsuite/ld-i386/pr19031b.S: Likewise.
* ld/testsuite/ld-i386/pr19031c.c: Likewise.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 7 | ||||
-rw-r--r-- | bfd/elf32-i386.c | 10 |
2 files changed, 16 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index a218d44..3610948 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,12 @@ 2015-09-30 H.J. Lu <hongjiu.lu@intel.com> + PR ld/19031 + * elf32-i386.c (elf_i386_check_relocs): Set + pointer_equality_needed for R_386_PC32 reloc in non-code + sections. + +2015-09-30 H.J. Lu <hongjiu.lu@intel.com> + PR ld/19013 * elflink.c (_bfd_elf_merge_sections): Only merge input bfds that have the compatible ELF machine code with the output bfd. diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 9390450..0a06191 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1772,7 +1772,15 @@ elf_i386_check_relocs (bfd *abfd, /* We may need a .plt entry if the function this reloc refers to is in a shared lib. */ h->plt.refcount += 1; - if (r_type != R_386_PC32) + if (r_type == R_386_PC32) + { + /* Since something like ".long foo - ." may be used + as pointer, make sure that PLT is used if foo is + a function defined in a shared library. */ + if ((sec->flags & SEC_CODE) == 0) + h->pointer_equality_needed = 1; + } + else { h->pointer_equality_needed = 1; /* R_386_32 can be resolved at run-time. */ |