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 /ld | |
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 'ld')
-rw-r--r-- | ld/testsuite/ld-i386/i386.exp | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/pr30787.d | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/pr30787.s | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/pr30787.t | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/pr30787.d | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/pr30787.s | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/pr30787.t | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/x86-64.exp | 1 |
8 files changed, 36 insertions, 0 deletions
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp index 5f53bcf..e8ad973 100644 --- a/ld/testsuite/ld-i386/i386.exp +++ b/ld/testsuite/ld-i386/i386.exp @@ -511,6 +511,7 @@ run_dump_test "dt-relr-1a" run_dump_test "dt-relr-1b" run_dump_test "pr28870" run_dump_test "pr28894" +run_dump_test "pr30787" if { !([istarget "i?86-*-linux*"] || [istarget "i?86-*-gnu*"] diff --git a/ld/testsuite/ld-i386/pr30787.d b/ld/testsuite/ld-i386/pr30787.d new file mode 100644 index 0000000..f82411d --- /dev/null +++ b/ld/testsuite/ld-i386/pr30787.d @@ -0,0 +1,7 @@ +#as: --32 +#ld: -melf_i386 -shared --no-warn-rwx-segments -T pr30787.t +#readelf: -d --wide + +#... + 0x0+2 \(PLTRELSZ\) +8 \(bytes\) +#pass diff --git a/ld/testsuite/ld-i386/pr30787.s b/ld/testsuite/ld-i386/pr30787.s new file mode 100644 index 0000000..71594d2 --- /dev/null +++ b/ld/testsuite/ld-i386/pr30787.s @@ -0,0 +1,6 @@ + .text + .globl foo +foo: + jmp bar@PLT + leal func@GOT(%ebx), %eax + .section .note.GNU-stack,"",@progbits diff --git a/ld/testsuite/ld-i386/pr30787.t b/ld/testsuite/ld-i386/pr30787.t new file mode 100644 index 0000000..8c47620 --- /dev/null +++ b/ld/testsuite/ld-i386/pr30787.t @@ -0,0 +1,4 @@ +SECTIONS +{ + .rel.dyn : { *(.rel.*) } +} diff --git a/ld/testsuite/ld-x86-64/pr30787.d b/ld/testsuite/ld-x86-64/pr30787.d new file mode 100644 index 0000000..29102d4 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr30787.d @@ -0,0 +1,7 @@ +#as: --64 +#ld: -melf_x86_64 -shared --no-warn-rwx-segments -T pr30787.t +#readelf: -d --wide + +#... + 0x0+2 \(PLTRELSZ\) +24 \(bytes\) +#pass diff --git a/ld/testsuite/ld-x86-64/pr30787.s b/ld/testsuite/ld-x86-64/pr30787.s new file mode 100644 index 0000000..8bc774f --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr30787.s @@ -0,0 +1,6 @@ + .text + .globl foo +foo: + jmp bar@PLT + movq func@GOTPCREL(%rip), %rax + .section .note.GNU-stack,"",@progbits diff --git a/ld/testsuite/ld-x86-64/pr30787.t b/ld/testsuite/ld-x86-64/pr30787.t new file mode 100644 index 0000000..66759cb --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr30787.t @@ -0,0 +1,4 @@ +SECTIONS +{ + .rela.dyn : { *(.rela.*) } +} diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 1a10c39..f94284b 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -505,6 +505,7 @@ run_dump_test "dt-relr-1a" run_dump_test "dt-relr-1a-x32" run_dump_test "dt-relr-1b" run_dump_test "dt-relr-1b-x32" +run_dump_test "pr30787" if { ![skip_sframe_tests] } { run_dump_test "sframe-simple-1" |