aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
Diffstat (limited to 'ld')
-rw-r--r--ld/emulparams/elf32_x86_64.sh1
-rw-r--r--ld/emulparams/elf_x86_64.sh1
-rw-r--r--ld/emulparams/x86-64-plt.sh14
-rw-r--r--ld/ld.texi11
-rw-r--r--ld/testsuite/ld-x86-64/mark-plt-1.s7
-rw-r--r--ld/testsuite/ld-x86-64/mark-plt-1a-x32.d12
-rw-r--r--ld/testsuite/ld-x86-64/mark-plt-1a.d12
-rw-r--r--ld/testsuite/ld-x86-64/mark-plt-1b-x32.d16
-rw-r--r--ld/testsuite/ld-x86-64/mark-plt-1b.d16
-rw-r--r--ld/testsuite/ld-x86-64/mark-plt-1c-x32.d12
-rw-r--r--ld/testsuite/ld-x86-64/mark-plt-1c.d12
-rw-r--r--ld/testsuite/ld-x86-64/mark-plt-1d-x32.d16
-rw-r--r--ld/testsuite/ld-x86-64/mark-plt-1d.d16
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp8
14 files changed, 154 insertions, 0 deletions
diff --git a/ld/emulparams/elf32_x86_64.sh b/ld/emulparams/elf32_x86_64.sh
index 4bff412..f6c6de9 100644
--- a/ld/emulparams/elf32_x86_64.sh
+++ b/ld/emulparams/elf32_x86_64.sh
@@ -6,6 +6,7 @@ source_sh ${srcdir}/emulparams/call_nop.sh
source_sh ${srcdir}/emulparams/cet.sh
source_sh ${srcdir}/emulparams/x86-report-relative.sh
source_sh ${srcdir}/emulparams/x86-64-level.sh
+source_sh ${srcdir}/emulparams/x86-64-plt.sh
source_sh ${srcdir}/emulparams/static.sh
source_sh ${srcdir}/emulparams/dt-relr.sh
SCRIPT_NAME=elf
diff --git a/ld/emulparams/elf_x86_64.sh b/ld/emulparams/elf_x86_64.sh
index a689a7b..466da2c 100644
--- a/ld/emulparams/elf_x86_64.sh
+++ b/ld/emulparams/elf_x86_64.sh
@@ -7,6 +7,7 @@ source_sh ${srcdir}/emulparams/cet.sh
source_sh ${srcdir}/emulparams/x86-report-relative.sh
source_sh ${srcdir}/emulparams/x86-64-level.sh
source_sh ${srcdir}/emulparams/x86-64-lam.sh
+source_sh ${srcdir}/emulparams/x86-64-plt.sh
source_sh ${srcdir}/emulparams/static.sh
source_sh ${srcdir}/emulparams/dt-relr.sh
SCRIPT_NAME=elf
diff --git a/ld/emulparams/x86-64-plt.sh b/ld/emulparams/x86-64-plt.sh
new file mode 100644
index 0000000..9273240
--- /dev/null
+++ b/ld/emulparams/x86-64-plt.sh
@@ -0,0 +1,14 @@
+PARSE_AND_LIST_OPTIONS_X86_64_PLT='
+ fprintf (file, _("\
+ -z mark-plt Mark PLT with dynamic tags\n\
+ -z nomark-plt Do not mark PLT with dynamic tags (default)\n"));
+'
+PARSE_AND_LIST_ARGS_CASE_Z_X86_64_PLT='
+ else if (strcmp (optarg, "mark-plt") == 0)
+ params.mark_plt = 1;
+ else if (strcmp (optarg, "nomark-plt") == 0)
+ params.mark_plt = 0;
+'
+
+PARSE_AND_LIST_OPTIONS="$PARSE_AND_LIST_OPTIONS $PARSE_AND_LIST_OPTIONS_X86_64_PLT"
+PARSE_AND_LIST_ARGS_CASE_Z="$PARSE_AND_LIST_ARGS_CASE_Z $PARSE_AND_LIST_ARGS_CASE_Z_X86_64_PLT"
diff --git a/ld/ld.texi b/ld/ld.texi
index 24e9deb..2663f07 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -1475,6 +1475,17 @@ Specify that the object's filters be processed immediately at runtime.
@item max-page-size=@var{value}
Set the maximum memory page size supported to @var{value}.
+@item mark-plt
+@itemx nomark-plt
+Mark PLT entries with dynamic tags, DT_X86_64_PLT, DT_X86_64_PLTSZ and
+DT_X86_64_PLTENT. Since this option stores a non-zero value in the
+r_addend field of R_X86_64_JUMP_SLOT relocations, the resulting
+executables and shared libraries are incompatible with dynamic linkers,
+such as those in older versions of glibc without the change to ignore
+r_addend in R_X86_64_GLOB_DAT and R_X86_64_JUMP_SLOT relocations, which
+don't ignore the r_addend field of R_X86_64_JUMP_SLOT relocations.
+Supported for x86_64.
+
@item muldefs
Allow multiple definitions.
diff --git a/ld/testsuite/ld-x86-64/mark-plt-1.s b/ld/testsuite/ld-x86-64/mark-plt-1.s
new file mode 100644
index 0000000..e3f03c8
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/mark-plt-1.s
@@ -0,0 +1,7 @@
+ .text
+ .globl foo
+ .type foo, @function
+foo:
+ call bar@PLT
+ ret
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-x86-64/mark-plt-1a-x32.d b/ld/testsuite/ld-x86-64/mark-plt-1a-x32.d
new file mode 100644
index 0000000..2051356
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/mark-plt-1a-x32.d
@@ -0,0 +1,12 @@
+#source: mark-plt-1.s
+#as: --x32
+#ld: -melf32_x86_64 -shared -z mark-plt
+#readelf: -drW
+
+#...
+ 0x70000000 \(DT_X86_64_PLT\) 0x1000
+ 0x70000001 \(DT_X86_64_PLTSZ\) 0x20
+ 0x70000003 \(DT_X86_64_PLTENT\) 0x10
+#...
+[0-9a-f ]+R_X86_64_JUMP_SLOT +0+ +bar \+ 1010
+#pass
diff --git a/ld/testsuite/ld-x86-64/mark-plt-1a.d b/ld/testsuite/ld-x86-64/mark-plt-1a.d
new file mode 100644
index 0000000..a252e95
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/mark-plt-1a.d
@@ -0,0 +1,12 @@
+#source: mark-plt-1.s
+#as: --64
+#ld: -melf_x86_64 -shared -z mark-plt
+#readelf: -drW
+
+#...
+ 0x0000000070000000 \(DT_X86_64_PLT\) 0x1000
+ 0x0000000070000001 \(DT_X86_64_PLTSZ\) 0x20
+ 0x0000000070000003 \(DT_X86_64_PLTENT\) 0x10
+#...
+[0-9a-f ]+R_X86_64_JUMP_SLOT +0+ +bar \+ 1010
+#pass
diff --git a/ld/testsuite/ld-x86-64/mark-plt-1b-x32.d b/ld/testsuite/ld-x86-64/mark-plt-1b-x32.d
new file mode 100644
index 0000000..74306a0
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/mark-plt-1b-x32.d
@@ -0,0 +1,16 @@
+#source: mark-plt-1.s
+#as: --x32
+#ld: -melf32_x86_64 -shared -z mark-plt
+#objdump: -dw
+
+#...
+0+1010 <bar@plt>:
+ +1010: ff 25 9a 10 00 00 jmp \*0x109a\(%rip\) # 20b0 <bar>
+ +1016: 68 00 00 00 00 push \$0x0
+ +101b: e9 e0 ff ff ff jmp 1000 <bar@plt-0x10>
+
+Disassembly of section .text:
+
+0+1020 <foo>:
+ +1020: e8 eb ff ff ff call 1010 <bar@plt>
+#pass
diff --git a/ld/testsuite/ld-x86-64/mark-plt-1b.d b/ld/testsuite/ld-x86-64/mark-plt-1b.d
new file mode 100644
index 0000000..dc046c0
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/mark-plt-1b.d
@@ -0,0 +1,16 @@
+#source: mark-plt-1.s
+#as: --64
+#ld: -melf_x86_64 -shared -z mark-plt
+#objdump: -dw
+
+#...
+0+1010 <bar@plt>:
+ +1010: ff 25 32 11 00 00 jmp \*0x1132\(%rip\) # 2148 <bar>
+ +1016: 68 00 00 00 00 push \$0x0
+ +101b: e9 e0 ff ff ff jmp 1000 <bar@plt-0x10>
+
+Disassembly of section .text:
+
+0+1020 <foo>:
+ +1020: e8 eb ff ff ff call 1010 <bar@plt>
+#pass
diff --git a/ld/testsuite/ld-x86-64/mark-plt-1c-x32.d b/ld/testsuite/ld-x86-64/mark-plt-1c-x32.d
new file mode 100644
index 0000000..6354dc3
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/mark-plt-1c-x32.d
@@ -0,0 +1,12 @@
+#source: mark-plt-1.s
+#as: --x32
+#ld: -melf32_x86_64 -shared -z mark-plt -z ibtplt
+#readelf: -drW
+
+#...
+ 0x70000000 \(DT_X86_64_PLT\) 0x1020
+ 0x70000001 \(DT_X86_64_PLTSZ\) 0x10
+ 0x70000003 \(DT_X86_64_PLTENT\) 0x10
+#...
+[0-9a-f ]+R_X86_64_JUMP_SLOT +0+ +bar \+ 1024
+#pass
diff --git a/ld/testsuite/ld-x86-64/mark-plt-1c.d b/ld/testsuite/ld-x86-64/mark-plt-1c.d
new file mode 100644
index 0000000..e11e0b7
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/mark-plt-1c.d
@@ -0,0 +1,12 @@
+#source: mark-plt-1.s
+#as: --64
+#ld: -melf_x86_64 -shared -z mark-plt -z ibtplt
+#readelf: -drW
+
+#...
+ 0x0000000070000000 \(DT_X86_64_PLT\) 0x1020
+ 0x0000000070000001 \(DT_X86_64_PLTSZ\) 0x10
+ 0x0000000070000003 \(DT_X86_64_PLTENT\) 0x10
+#...
+[0-9a-f ]+R_X86_64_JUMP_SLOT +0+ +bar \+ 1024
+#pass
diff --git a/ld/testsuite/ld-x86-64/mark-plt-1d-x32.d b/ld/testsuite/ld-x86-64/mark-plt-1d-x32.d
new file mode 100644
index 0000000..318ca1f
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/mark-plt-1d-x32.d
@@ -0,0 +1,16 @@
+#source: mark-plt-1.s
+#as: --x32
+#ld: -melf32_x86_64 -shared -z mark-plt -z ibtplt
+#objdump: -dw
+
+#...
+0+1020 <bar@plt>:
+ +1020: f3 0f 1e fa endbr64
+ +1024: ff 25 86 10 00 00 jmp \*0x1086\(%rip\) # 20b0 <bar>
+ +102a: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\)
+
+Disassembly of section .text:
+
+0+1030 <foo>:
+ +1030: e8 eb ff ff ff call 1020 <bar@plt>
+#pass
diff --git a/ld/testsuite/ld-x86-64/mark-plt-1d.d b/ld/testsuite/ld-x86-64/mark-plt-1d.d
new file mode 100644
index 0000000..2dd63bc
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/mark-plt-1d.d
@@ -0,0 +1,16 @@
+#source: mark-plt-1.s
+#as: --64
+#ld: -melf_x86_64 -shared -z mark-plt -z ibtplt
+#objdump: -dw
+
+#...
+0+1020 <bar@plt>:
+ +1020: f3 0f 1e fa endbr64
+ +1024: ff 25 1e 11 00 00 jmp \*0x111e\(%rip\) # 2148 <bar>
+ +102a: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\)
+
+Disassembly of section .text:
+
+0+1030 <foo>:
+ +1030: e8 eb ff ff ff call 1020 <bar@plt>
+#pass
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index f94284b..3dc8cb4 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -2228,5 +2228,13 @@ run_dump_test "ibt-plt-3a-x32"
run_dump_test "ibt-plt-3b-x32"
run_dump_test "ibt-plt-3c-x32"
run_dump_test "ibt-plt-3d-x32"
+run_dump_test "mark-plt-1a"
+run_dump_test "mark-plt-1b"
+run_dump_test "mark-plt-1c"
+run_dump_test "mark-plt-1d"
+run_dump_test "mark-plt-1a-x32"
+run_dump_test "mark-plt-1b-x32"
+run_dump_test "mark-plt-1c-x32"
+run_dump_test "mark-plt-1d-x32"
set ASFLAGS "$saved_ASFLAGS"