aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-i386
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-06-22 05:50:20 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-06-22 05:50:31 -0700
commit48580982ef41907a45cda259a63d9e6878cbbea3 (patch)
tree34cb9f37e796a00e55ade7a1fd60cac70a30a826 /ld/testsuite/ld-i386
parentee2fdd6f36c10ceb84e05c7234983bcfbe6146d5 (diff)
x86: Support Intel Shadow Stack with SHSTK property
To support Intel Shadow Stack (SHSTK) in Intel Control-flow Enforcement Technology (CET) instructions: https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf #define GNU_PROPERTY_X86_FEATURE_1_SHSTK (1U << 1) is added to GNU program properties to indicate that all executable sections are compatible with SHSTK where return address popped from shadow stack always matches return address popped from normal stack. GNU_PROPERTY_X86_FEATURE_1_SHSTK is set on output only if it is set on all relocatable inputs. bfd/ * elf32-i386.c (elf_i386_merge_gnu_properties): If info->shstk is set, turn on GNU_PROPERTY_X86_FEATURE_1_SHSTK. (elf_i386_link_setup_gnu_properties): If info->shstk is set, turn on GNU_PROPERTY_X86_FEATURE_1_IBT. * elf64-x86-64.c (elf_x86_64_merge_gnu_properties): If info->shstk is set, turn on GNU_PROPERTY_X86_FEATURE_1_SHSTK. (elf_x86_64_link_setup_gnu_properties): If info->shstk is set, turn on GNU_PROPERTY_X86_FEATURE_1_IBT. binutils/ * readelf.c (decode_x86_feature): Decode GNU_PROPERTY_X86_FEATURE_1_SHSTK. * testsuite/binutils-all/i386/shstk.d: New file. * testsuite/binutils-all/i386/shstk.s: Likewise. * testsuite/binutils-all/x86-64/shstk-x32.d: Likewise. * testsuite/binutils-all/x86-64/shstk.d: Likewise. * testsuite/binutils-all/x86-64/shstk.s: Likewise. include/ * bfdlink.h (bfd_link_info): Add shstk. * elf/common.h (GNU_PROPERTY_X86_FEATURE_1_SHSTK): New. ld/ * NEWS: Mention -z shstk and GNU_PROPERTY_X86_FEATURE_1_SHSTK. * emulparams/cet.sh (PARSE_AND_LIST_OPTIONS_CET): Add "-z shstk". (PARSE_AND_LIST_ARGS_CASE_Z_CET): Support "-z shstk". * ld.texinfo: Document -z shstk. * testsuite/ld-i386/i386.exp: Run SHSTK tests. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/property-x86-shstk.s: New file. * testsuite/ld-i386/property-x86-shstk1a.d: Likewise. * testsuite/ld-i386/property-x86-shstk1b.d: Likewise. * testsuite/ld-i386/property-x86-shstk2.d: Likewise. * testsuite/ld-i386/property-x86-shstk3a.d: Likewise. * testsuite/ld-i386/property-x86-shstk3b.d: Likewise. * testsuite/ld-i386/property-x86-shstk4.d: Likewise. * testsuite/ld-i386/property-x86-shstk5.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk.s: Likewise. * testsuite/ld-x86-64/property-x86-shstk1a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk1a.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk1b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk1b.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk2-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk2.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk4-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk4.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk5-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk5.d: Likewise.
Diffstat (limited to 'ld/testsuite/ld-i386')
-rw-r--r--ld/testsuite/ld-i386/i386.exp7
-rw-r--r--ld/testsuite/ld-i386/property-x86-shstk.s27
-rw-r--r--ld/testsuite/ld-i386/property-x86-shstk1a.d6
-rw-r--r--ld/testsuite/ld-i386/property-x86-shstk1b.d6
-rw-r--r--ld/testsuite/ld-i386/property-x86-shstk2.d9
-rw-r--r--ld/testsuite/ld-i386/property-x86-shstk3a.d11
-rw-r--r--ld/testsuite/ld-i386/property-x86-shstk3b.d11
-rw-r--r--ld/testsuite/ld-i386/property-x86-shstk4.d9
-rw-r--r--ld/testsuite/ld-i386/property-x86-shstk5.d9
9 files changed, 95 insertions, 0 deletions
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index d30dc76703..1cecea4e38 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -427,6 +427,13 @@ run_dump_test "property-x86-ibt3a"
run_dump_test "property-x86-ibt3b"
run_dump_test "property-x86-ibt4"
run_dump_test "property-x86-ibt5"
+run_dump_test "property-x86-shstk1a"
+run_dump_test "property-x86-shstk1b"
+run_dump_test "property-x86-shstk2"
+run_dump_test "property-x86-shstk3a"
+run_dump_test "property-x86-shstk3b"
+run_dump_test "property-x86-shstk4"
+run_dump_test "property-x86-shstk5"
if { !([istarget "i?86-*-linux*"]
|| [istarget "i?86-*-gnu*"]
diff --git a/ld/testsuite/ld-i386/property-x86-shstk.s b/ld/testsuite/ld-i386/property-x86-shstk.s
new file mode 100644
index 0000000000..4c3218aa18
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-shstk.s
@@ -0,0 +1,27 @@
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .long 1f - 0f /* name length */
+ .long 5f - 2f /* data length */
+ .long 5 /* note type */
+0: .asciz "GNU" /* vendor name */
+1:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+2: .long 0xc0000002 /* pr_type. */
+ .long 4f - 3f /* pr_datasz. */
+3:
+ .long 0x2
+4:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+5:
diff --git a/ld/testsuite/ld-i386/property-x86-shstk1a.d b/ld/testsuite/ld-i386/property-x86-shstk1a.d
new file mode 100644
index 0000000000..238cebeead
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-shstk1a.d
@@ -0,0 +1,6 @@
+#source: property-x86-empty.s
+#source: property-x86-shstk.s
+#as: --32
+#ld: -r -melf_i386
+#readelf: -n
+
diff --git a/ld/testsuite/ld-i386/property-x86-shstk1b.d b/ld/testsuite/ld-i386/property-x86-shstk1b.d
new file mode 100644
index 0000000000..faa2ea7b71
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-shstk1b.d
@@ -0,0 +1,6 @@
+#source: property-x86-shstk.s
+#source: property-x86-empty.s
+#as: --32
+#ld: -r -melf_i386
+#readelf: -n
+
diff --git a/ld/testsuite/ld-i386/property-x86-shstk2.d b/ld/testsuite/ld-i386/property-x86-shstk2.d
new file mode 100644
index 0000000000..b39fa58c59
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-shstk2.d
@@ -0,0 +1,9 @@
+#source: property-x86-shstk.s
+#as: --32
+#ld: -r -melf_i386
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: SHSTK
diff --git a/ld/testsuite/ld-i386/property-x86-shstk3a.d b/ld/testsuite/ld-i386/property-x86-shstk3a.d
new file mode 100644
index 0000000000..e261038f60
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-shstk3a.d
@@ -0,0 +1,11 @@
+#source: property-x86-3.s
+#source: property-x86-shstk.s
+#as: --32
+#ld: -r -melf_i386
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA used: i486, 586, SSE2, SSE3
+ x86 ISA needed: 586, SSE, SSE3, SSE4_1
diff --git a/ld/testsuite/ld-i386/property-x86-shstk3b.d b/ld/testsuite/ld-i386/property-x86-shstk3b.d
new file mode 100644
index 0000000000..25f3d2361e
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-shstk3b.d
@@ -0,0 +1,11 @@
+#source: property-x86-shstk.s
+#source: property-x86-3.s
+#as: --32
+#ld: -r -melf_i386
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA used: i486, 586, SSE2, SSE3
+ x86 ISA needed: 586, SSE, SSE3, SSE4_1
diff --git a/ld/testsuite/ld-i386/property-x86-shstk4.d b/ld/testsuite/ld-i386/property-x86-shstk4.d
new file mode 100644
index 0000000000..d962eabb98
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-shstk4.d
@@ -0,0 +1,9 @@
+#source: property-x86-empty.s
+#as: --32
+#ld: -r -melf_i386 -z shstk
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: SHSTK
diff --git a/ld/testsuite/ld-i386/property-x86-shstk5.d b/ld/testsuite/ld-i386/property-x86-shstk5.d
new file mode 100644
index 0000000000..6d6371f653
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-shstk5.d
@@ -0,0 +1,9 @@
+#source: start.s
+#as: --32
+#ld: -r -melf_i386 -z shstk
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: SHSTK