diff options
author | Peter Edwards <peadar@arista.com> | 2023-08-22 19:57:28 +0100 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2023-08-23 09:10:16 -0700 |
commit | fa4f2d46f95a1c673b025fab7f292cb864a99020 (patch) | |
tree | 5088fff05a1d5527433ee61f9bba052bf9bd1afa /bfd/elfxx-x86.c | |
parent | c99853f48cd9132c5a745ad7452d1b0d856f32b8 (diff) | |
download | gdb-fa4f2d46f95a1c673b025fab7f292cb864a99020.zip gdb-fa4f2d46f95a1c673b025fab7f292cb864a99020.tar.gz gdb-fa4f2d46f95a1c673b025fab7f292cb864a99020.tar.bz2 |
x86: Fix DT_JMPREL/DT_PLTRELSZ when relocs share a section
If a linker script does not place the PLT relocations and "normal"
relocations in separate ELF sections, `ld` will currently output incorrect
values for DT_JMPREL and DT_PLTRELSZ - they cover the entire ELF section,
rather than just the PLT relocations
Don't ignore the extent of the BFD section - use the size of the srelplt
BFD section and its offset from the output_secttion
bfd/
PR ld/30787
* elfxx-x86.c (_bfd_x86_elf_finish_dynamic_sections): Use input
section for DT_JMPREL and DT_PLTRELSZ.
ld/
PR ld/30787
* testsuite/ld-i386/i386.exp: Run pr30787.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr30787.d: New file.
* testsuite/ld-i386/pr30787.s: Likewise.
* testsuite/ld-i386/pr30787.t: Likewise.
* testsuite/ld-x86-64/pr30787.d: Likewise.
* testsuite/ld-x86-64/pr30787.s: Likewise.
* testsuite/ld-x86-64/pr30787.t: Likewise.
Diffstat (limited to 'bfd/elfxx-x86.c')
-rw-r--r-- | bfd/elfxx-x86.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index f224e8f..103559d 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -2771,11 +2771,12 @@ _bfd_x86_elf_finish_dynamic_sections (bfd *output_bfd, break; case DT_JMPREL: - dyn.d_un.d_ptr = htab->elf.srelplt->output_section->vma; + s = htab->elf.srelplt; + dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; break; case DT_PLTRELSZ: - s = htab->elf.srelplt->output_section; + s = htab->elf.srelplt; dyn.d_un.d_val = s->size; break; |