aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-11-06 09:38:33 -0800
committerH.J. Lu <hjl.tools@gmail.com>2018-11-06 09:38:51 -0800
commit8a6b075bc07f66678ed0176f895847df3ea7fcef (patch)
treeb900eb85546d6700c2ff9af49d863bf08e5e490a /ld
parentddea148b3da27eb681504bf341f45abb7a74580b (diff)
downloadgdb-8a6b075bc07f66678ed0176f895847df3ea7fcef.zip
gdb-8a6b075bc07f66678ed0176f895847df3ea7fcef.tar.gz
gdb-8a6b075bc07f66678ed0176f895847df3ea7fcef.tar.bz2
elfedit: Add --enable-x86-feature/--disable-x86-feature
Add --enable-x86-feature and --disable-x86-feature options to elfedit to set and clear the IBT and SHSTK bits in program property in ELF executables and shared objects. binutils/ * doc/binutils.texi: Document --enable-x86-feature and --disable-x86-feature options for elfedit. * elfedit.c: Include "config.h" and <sys/mman.h>. (enable_x86_features): New. (disable_x86_features): Likewise. (update_gnu_property): Likewise. (elf_x86_feature): Likewise. (process_file): Call update_gnu_property on ET_EXEC or ET_DYN file. (command_line_switch): Add OPTION_ENABLE_X86_FEATURE and OPTION_DISABLE_X86_FEATURE. (options): Add--enable-x86-feature and --disable-x86-feature. (usage): Likewise. (main): Handle OPTION_ENABLE_X86_FEATURE and OPTION_DISABLE_X86_FEATURE. ld/ * testsuite/config/default.exp (ELFEDIT): New. * testsuite/ld-elf/linux-x86.exp (elfedit_test): New proc. Run elfedit tests. * testsuite/ld-elf/x86-feature-1a.rd: New file. * testsuite/ld-elf/x86-feature-1b.rd: Likewise. * testsuite/ld-elf/x86-feature-1c.rd: Likewise. * testsuite/ld-elf/x86-feature-1d.rd: Likewise. * testsuite/ld-elf/x86-feature-1e.rd: Likewise.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog11
-rw-r--r--ld/testsuite/config/default.exp4
-rw-r--r--ld/testsuite/ld-elf/linux-x86.exp46
-rw-r--r--ld/testsuite/ld-elf/x86-feature-1a.rd6
-rw-r--r--ld/testsuite/ld-elf/x86-feature-1b.rd6
-rw-r--r--ld/testsuite/ld-elf/x86-feature-1c.rd6
-rw-r--r--ld/testsuite/ld-elf/x86-feature-1d.rd6
-rw-r--r--ld/testsuite/ld-elf/x86-feature-1e.rd6
8 files changed, 91 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 17f42dc..0346ebb 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,14 @@
+2018-11-06 H.J. Lu <hongjiu.lu@intel.com>
+
+ * testsuite/config/default.exp (ELFEDIT): New.
+ * testsuite/ld-elf/linux-x86.exp (elfedit_test): New proc.
+ Run elfedit tests.
+ * testsuite/ld-elf/x86-feature-1a.rd: New file.
+ * testsuite/ld-elf/x86-feature-1b.rd: Likewise.
+ * testsuite/ld-elf/x86-feature-1c.rd: Likewise.
+ * testsuite/ld-elf/x86-feature-1d.rd: Likewise.
+ * testsuite/ld-elf/x86-feature-1e.rd: Likewise.
+
2018-11-05 H.J. Lu <hongjiu.lu@intel.com>
PR gas/23854
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index 704ac30..fbc12ea 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -243,6 +243,10 @@ if ![info exists READELFFLAGS] then {
set READELFFLAGS {}
}
+if ![info exists ELFEDIT] then {
+ set ELFEDIT [findfile $base_dir/../binutils/elfedit]
+}
+
if ![info exists LD] then {
set LD [findfile $base_dir/ld-new ./ld-new [transform ld]]
}
diff --git a/ld/testsuite/ld-elf/linux-x86.exp b/ld/testsuite/ld-elf/linux-x86.exp
index f6f5a80..a8e82eb 100644
--- a/ld/testsuite/ld-elf/linux-x86.exp
+++ b/ld/testsuite/ld-elf/linux-x86.exp
@@ -44,3 +44,49 @@ run_ld_link_exec_tests [list \
"asm" \
] \
]
+
+run_ld_link_tests [list \
+ [list \
+ "Build x86-feature-1" \
+ "-z separate-code -z shstk" \
+ "" \
+ "-mx86-used-note=yes" \
+ { start.s } \
+ {{readelf -n x86-feature-1a.rd}} \
+ "x86-feature-1" \
+ ] \
+]
+
+proc elfedit_test { options test output } {
+ global ELFEDIT
+ global READELF
+ global srcdir
+ global subdir
+
+ set test_name "elfedit $options"
+ send_log "$ELFEDIT $options tmpdir/$test\n"
+ set got [remote_exec host "$ELFEDIT $options tmpdir/$test" "" "/dev/null"]
+ if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+ send_log "$got\n"
+ unresolved "$test_name"
+ }
+ send_log "$READELF -n $options tmpdir/$test > tmpdir/$output.out\n"
+ set got [remote_exec host "$READELF -n tmpdir/$test" "" "/dev/null" "tmpdir/$output.out"]
+ if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+ send_log "$got\n"
+ unresolved "$test_name"
+}
+ if { [regexp_diff tmpdir/$output.out $srcdir/$subdir/$output.rd] } then {
+ fail "$test_name"
+ } else {
+ pass "$test_name"
+ }
+}
+
+elfedit_test "--enable-x86-feature ibt --disable-x86-feature shstk" \
+ x86-feature-1 x86-feature-1b
+elfedit_test "--enable-x86-feature ibt" x86-feature-1 x86-feature-1b
+elfedit_test "--disable-x86-feature shstk" x86-feature-1 x86-feature-1c
+elfedit_test "--disable-x86-feature ibt" x86-feature-1 x86-feature-1d
+elfedit_test "--enable-x86-feature ibt --enable-x86-feature shstk" \
+ x86-feature-1 x86-feature-1e
diff --git a/ld/testsuite/ld-elf/x86-feature-1a.rd b/ld/testsuite/ld-elf/x86-feature-1a.rd
new file mode 100644
index 0000000..26b7ba5
--- /dev/null
+++ b/ld/testsuite/ld-elf/x86-feature-1a.rd
@@ -0,0 +1,6 @@
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: SHSTK
+ x86 ISA used: <None>
+ x86 feature used: x86
diff --git a/ld/testsuite/ld-elf/x86-feature-1b.rd b/ld/testsuite/ld-elf/x86-feature-1b.rd
new file mode 100644
index 0000000..9c6ff77
--- /dev/null
+++ b/ld/testsuite/ld-elf/x86-feature-1b.rd
@@ -0,0 +1,6 @@
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
+ x86 ISA used: <None>
+ x86 feature used: x86
diff --git a/ld/testsuite/ld-elf/x86-feature-1c.rd b/ld/testsuite/ld-elf/x86-feature-1c.rd
new file mode 100644
index 0000000..9c6ff77
--- /dev/null
+++ b/ld/testsuite/ld-elf/x86-feature-1c.rd
@@ -0,0 +1,6 @@
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
+ x86 ISA used: <None>
+ x86 feature used: x86
diff --git a/ld/testsuite/ld-elf/x86-feature-1d.rd b/ld/testsuite/ld-elf/x86-feature-1d.rd
new file mode 100644
index 0000000..cca2076
--- /dev/null
+++ b/ld/testsuite/ld-elf/x86-feature-1d.rd
@@ -0,0 +1,6 @@
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: <None>
+ x86 ISA used: <None>
+ x86 feature used: x86
diff --git a/ld/testsuite/ld-elf/x86-feature-1e.rd b/ld/testsuite/ld-elf/x86-feature-1e.rd
new file mode 100644
index 0000000..391d3f7
--- /dev/null
+++ b/ld/testsuite/ld-elf/x86-feature-1e.rd
@@ -0,0 +1,6 @@
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT, SHSTK
+ x86 ISA used: <None>
+ x86 feature used: x86