mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-30 12:44:10 +08:00
x86: Add DT_PLTRELSZ/DT_PLTREL/DT_JMPREL for PLT relocation
x86, PLT relocation may contain R_386_TLS_DESC or R_X86_64_TLSDESC even though there is no real PLT. We need to add DT_PLTRELSZ, DT_PLTREL and DT_JMPREL if there is a .rel.plt/.rela.plt section. bfd/ * elf32-i386.c (elf_i386_size_dynamic_sections): Alwasys add DT_PLTRELSZ, DT_PLTREL and DT_JMPREL for .rel.plt section. * elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Alwasys add DT_PLTRELSZ, DT_PLTREL and DT_JMPREL for .rela.plt section. ld/ * testsuite/ld-i386/tlsdesc2.d: New test. * testsuite/ld-x86-64/tlsdesc2.d: Likewise.
This commit is contained in:
parent
04b31182bf
commit
97d343d400
@ -1,3 +1,10 @@
|
||||
2017-04-26 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* elf32-i386.c (elf_i386_size_dynamic_sections): Alwasys add
|
||||
DT_PLTRELSZ, DT_PLTREL and DT_JMPREL for .rel.plt section.
|
||||
* elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Alwasys
|
||||
add DT_PLTRELSZ, DT_PLTREL and DT_JMPREL for .rela.plt section.
|
||||
|
||||
2017-04-26 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
PR binutils/21434
|
||||
|
@ -3577,14 +3577,14 @@ elf_i386_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
|
||||
relocation. */
|
||||
if (!add_dynamic_entry (DT_PLTGOT, 0))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (htab->elf.srelplt->size != 0)
|
||||
{
|
||||
if (!add_dynamic_entry (DT_PLTRELSZ, 0)
|
||||
|| !add_dynamic_entry (DT_PLTREL, DT_REL)
|
||||
|| !add_dynamic_entry (DT_JMPREL, 0))
|
||||
return FALSE;
|
||||
}
|
||||
if (htab->elf.srelplt->size != 0)
|
||||
{
|
||||
if (!add_dynamic_entry (DT_PLTRELSZ, 0)
|
||||
|| !add_dynamic_entry (DT_PLTREL, DT_REL)
|
||||
|| !add_dynamic_entry (DT_JMPREL, 0))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (relocs)
|
||||
|
@ -4052,21 +4052,21 @@ elf_x86_64_size_dynamic_sections (bfd *output_bfd,
|
||||
relocation. */
|
||||
if (!add_dynamic_entry (DT_PLTGOT, 0))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (htab->elf.srelplt->size != 0)
|
||||
{
|
||||
if (!add_dynamic_entry (DT_PLTRELSZ, 0)
|
||||
|| !add_dynamic_entry (DT_PLTREL, DT_RELA)
|
||||
|| !add_dynamic_entry (DT_JMPREL, 0))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (htab->tlsdesc_plt
|
||||
&& (!add_dynamic_entry (DT_TLSDESC_PLT, 0)
|
||||
|| !add_dynamic_entry (DT_TLSDESC_GOT, 0)))
|
||||
if (htab->elf.srelplt->size != 0)
|
||||
{
|
||||
if (!add_dynamic_entry (DT_PLTRELSZ, 0)
|
||||
|| !add_dynamic_entry (DT_PLTREL, DT_RELA)
|
||||
|| !add_dynamic_entry (DT_JMPREL, 0))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (htab->tlsdesc_plt
|
||||
&& (!add_dynamic_entry (DT_TLSDESC_PLT, 0)
|
||||
|| !add_dynamic_entry (DT_TLSDESC_GOT, 0)))
|
||||
return FALSE;
|
||||
|
||||
if (relocs)
|
||||
{
|
||||
if (!add_dynamic_entry (DT_RELA, 0)
|
||||
|
@ -1,3 +1,8 @@
|
||||
2017-04-26 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* testsuite/ld-i386/tlsdesc2.d: New test.
|
||||
* testsuite/ld-x86-64/tlsdesc2.d: Likewise.
|
||||
|
||||
2017-04-26 Maciej W. Rozycki <macro@imgtec.com>
|
||||
|
||||
PR ld/21334
|
||||
|
@ -437,6 +437,7 @@ run_dump_test "pr18801"
|
||||
run_dump_test "pr18815"
|
||||
run_dump_test "pr19939a"
|
||||
run_dump_test "pr19939b"
|
||||
run_dump_test "tlsdesc2"
|
||||
|
||||
proc undefined_weak {cflags ldflags} {
|
||||
set testname "Undefined weak symbol"
|
||||
|
10
ld/testsuite/ld-i386/tlsdesc2.d
Normal file
10
ld/testsuite/ld-i386/tlsdesc2.d
Normal file
@ -0,0 +1,10 @@
|
||||
#source: tlsdesc.s
|
||||
#as: --32
|
||||
#ld: -melf_i386 -shared -z now
|
||||
#readelf: -d --wide
|
||||
|
||||
#...
|
||||
.*\(PLTRELSZ\).*
|
||||
.*\(PLTREL\).*
|
||||
.*\(JMPREL\).*
|
||||
#pass
|
10
ld/testsuite/ld-x86-64/tlsdesc2.d
Normal file
10
ld/testsuite/ld-x86-64/tlsdesc2.d
Normal file
@ -0,0 +1,10 @@
|
||||
#source: tlsdesc.s
|
||||
#as: --64
|
||||
#ld: -melf_x86_64 -shared -z now
|
||||
#readelf: -d --wide
|
||||
|
||||
#...
|
||||
.*\(PLTRELSZ\).*
|
||||
.*\(PLTREL\).*
|
||||
.*\(JMPREL\).*
|
||||
#pass
|
@ -530,6 +530,7 @@ run_dump_test "pr20253-4e"
|
||||
run_dump_test "pr20253-4f"
|
||||
run_dump_test "pr20253-5a"
|
||||
run_dump_test "pr20253-5b"
|
||||
run_dump_test "tlsdesc2"
|
||||
|
||||
proc undefined_weak {cflags ldflags} {
|
||||
set testname "Undefined weak symbol"
|
||||
|
Loading…
Reference in New Issue
Block a user