diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2019-04-11 08:18:51 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2019-04-11 08:21:30 -0700 |
commit | 233a00833b984319d5e94db3f5d5d9a735edc984 (patch) | |
tree | cde032770e8d7027cb298b7d7a1a489b3da62647 /ld/testsuite/ld-x86-64 | |
parent | ca4e63310228df72ba47e5b29f4c275e62496dcf (diff) | |
download | gdb-233a00833b984319d5e94db3f5d5d9a735edc984.zip gdb-233a00833b984319d5e94db3f5d5d9a735edc984.tar.gz gdb-233a00833b984319d5e94db3f5d5d9a735edc984.tar.bz2 |
x86: Add -z cet-report=[none|warning|error]
Add -z cet-report=[none|warning|error] to report the missing Intel
Indirect Branch Tracking (IBT) and Shadow Stack (SHSTK) properties
in input .note.gnu.property section. -z cet-report=none, which is
the default, will make the linker not report missing properties in
input files. -z cet-report=warning will make the linker issue a
warning for missing properties in input files. -z cet-report=error
will make the linker issue an error for missing properties in input
files. Note that -z ibt will turn off the missing IBT property report
and -z shstk will turn off the missing SHSTK property report.
Supported for Linux/i386 and Linux/x86_64.
bfd/
* elf-linker-x86.h (elf_x86_cet_report): New.
(elf_linker_x86_params): Add cet_report.
* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Report
missing IBT and SHSTK properties if needed.
ld/
* ld.texi: Document -z cet-report=[none|warning|error].
* emulparams/cet.sh: Add -z cet-report=[none|warning|error].
* testsuite/ld-i386/i386.exp: Run -z cet-report=[warning|error]
tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/property-x86-cet1.d: New file.
* testsuite/ld-i386/property-x86-cet2a.d: Likewise.
* testsuite/ld-i386/property-x86-cet2b.d: Likewise.
* testsuite/ld-i386/property-x86-cet3a.d: Likewise.
* testsuite/ld-i386/property-x86-cet3b.d: Likewise.
* testsuite/ld-i386/property-x86-cet4a.d: Likewise.
* testsuite/ld-i386/property-x86-cet4b.d: Likewise.
* testsuite/ld-i386/property-x86-cet5a.d: Likewise.
* testsuite/ld-i386/property-x86-cet5b.d: Likewise.
* testsuite/ld-i386/property-x86-cet6.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet.s: Likewise.
* testsuite/ld-x86-64/property-x86-cet1-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet1.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet2a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet2a.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet2b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet2b.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet3a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet3a.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet3b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet3b.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet4a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet4a.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet4b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet4b.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet5a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet5a.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet5b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet5b.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet6-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet6.d: Likewise.
Diffstat (limited to 'ld/testsuite/ld-x86-64')
22 files changed, 197 insertions, 0 deletions
diff --git a/ld/testsuite/ld-x86-64/property-x86-cet.s b/ld/testsuite/ld-x86-64/property-x86-cet.s new file mode 100644 index 0000000..15989d6 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet.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 0x3 +4: +.ifdef __64_bit__ + .p2align 3 +.else + .p2align 2 +.endif +5: diff --git a/ld/testsuite/ld-x86-64/property-x86-cet1-x32.d b/ld/testsuite/ld-x86-64/property-x86-cet1-x32.d new file mode 100644 index 0000000..c317bff --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet1-x32.d @@ -0,0 +1,11 @@ +#source: property-x86-cet.s +#as: --x32 -mx86-used-note=yes +#ld: -r -m elf32_x86_64 -z cet-report=error +#readelf: -n + +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x00000024 NT_GNU_PROPERTY_TYPE_0 + Properties: x86 feature: IBT, SHSTK + x86 ISA used: <None> + x86 feature used: x86 diff --git a/ld/testsuite/ld-x86-64/property-x86-cet1.d b/ld/testsuite/ld-x86-64/property-x86-cet1.d new file mode 100644 index 0000000..0645177 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet1.d @@ -0,0 +1,11 @@ +#source: property-x86-cet.s +#as: --64 -defsym __64_bit__=1 -mx86-used-note=yes +#ld: -r -melf_x86_64 -z cet-report=error +#readelf: -n + +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x00000030 NT_GNU_PROPERTY_TYPE_0 + Properties: x86 feature: IBT, SHSTK + x86 ISA used: <None> + x86 feature used: x86 diff --git a/ld/testsuite/ld-x86-64/property-x86-cet2a-x32.d b/ld/testsuite/ld-x86-64/property-x86-cet2a-x32.d new file mode 100644 index 0000000..b070f52 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet2a-x32.d @@ -0,0 +1,15 @@ +#source: property-x86-empty.s +#source: property-x86-ibt.s +#source: property-x86-shstk.s +#source: property-x86-3.s +#as: --x32 -mx86-used-note=yes +#ld: -r -m elf32_x86_64 -z cet-report=warning +#warning: .*: warning: missing IBT and SHSTK properties.*: warning: missing SHSTK property.*: warning: missing IBT property +#readelf: -n + +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x00000024 NT_GNU_PROPERTY_TYPE_0 + Properties: x86 ISA needed: CMOV, SSE, SSSE3, SSE4_1 + x86 ISA used: SSE, SSE3, SSE4_1, AVX + x86 feature used: x86 diff --git a/ld/testsuite/ld-x86-64/property-x86-cet2a.d b/ld/testsuite/ld-x86-64/property-x86-cet2a.d new file mode 100644 index 0000000..18d24b6 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet2a.d @@ -0,0 +1,15 @@ +#source: property-x86-empty.s +#source: property-x86-ibt.s +#source: property-x86-shstk.s +#source: property-x86-3.s +#as: --64 -defsym __64_bit__=1 -mx86-used-note=yes +#ld: -r -melf_x86_64 -z cet-report=warning +#warning: .*: warning: missing IBT and SHSTK properties.*: warning: missing SHSTK property.*: warning: missing IBT property.*: warning: missing IBT and SHSTK properties +#readelf: -n + +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x00000030 NT_GNU_PROPERTY_TYPE_0 + Properties: x86 ISA needed: CMOV, SSE, SSSE3, SSE4_1 + x86 ISA used: SSE, SSE3, SSE4_1, AVX + x86 feature used: x86 diff --git a/ld/testsuite/ld-x86-64/property-x86-cet2b-x32.d b/ld/testsuite/ld-x86-64/property-x86-cet2b-x32.d new file mode 100644 index 0000000..9e986c2 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet2b-x32.d @@ -0,0 +1,7 @@ +#source: property-x86-empty.s +#source: property-x86-ibt.s +#source: property-x86-shstk.s +#source: property-x86-3.s +#as: --x32 -mx86-used-note=yes +#ld: -r -m elf32_x86_64 -z cet-report=error +#error: .*: error: missing IBT and SHSTK properties.*: error: missing SHSTK property.*: error: missing IBT property.*: error: missing IBT and SHSTK properties diff --git a/ld/testsuite/ld-x86-64/property-x86-cet2b.d b/ld/testsuite/ld-x86-64/property-x86-cet2b.d new file mode 100644 index 0000000..97095b3 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet2b.d @@ -0,0 +1,7 @@ +#source: property-x86-empty.s +#source: property-x86-ibt.s +#source: property-x86-shstk.s +#source: property-x86-3.s +#as: --64 -defsym __64_bit__=1 -mx86-used-note=yes +#ld: -r -melf_x86_64 -z cet-report=error +#error: .*: error: missing IBT and SHSTK properties.*: error: missing SHSTK property.*: error: missing IBT property.*: error: missing IBT and SHSTK properties diff --git a/ld/testsuite/ld-x86-64/property-x86-cet3a-x32.d b/ld/testsuite/ld-x86-64/property-x86-cet3a-x32.d new file mode 100644 index 0000000..91de5a0 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet3a-x32.d @@ -0,0 +1,4 @@ +#source: property-x86-ibt.s +#as: --x32 -mx86-used-note=yes +#ld: -r -m elf32_x86_64 -z cet-report=error +#error: .*: error: missing SHSTK property diff --git a/ld/testsuite/ld-x86-64/property-x86-cet3a.d b/ld/testsuite/ld-x86-64/property-x86-cet3a.d new file mode 100644 index 0000000..3e085f5 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet3a.d @@ -0,0 +1,4 @@ +#source: property-x86-ibt.s +#as: --64 -defsym __64_bit__=1 -mx86-used-note=yes +#ld: -r -melf_x86_64 -z cet-report=error +#error: .*: error: missing SHSTK property diff --git a/ld/testsuite/ld-x86-64/property-x86-cet3b-x32.d b/ld/testsuite/ld-x86-64/property-x86-cet3b-x32.d new file mode 100644 index 0000000..f56ce82 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet3b-x32.d @@ -0,0 +1,4 @@ +#source: property-x86-ibt.s +#as: --x32 -mx86-used-note=yes +#ld: -r -m elf32_x86_64 -z cet-report=error -z ibt +#error: .*: error: missing SHSTK property diff --git a/ld/testsuite/ld-x86-64/property-x86-cet3b.d b/ld/testsuite/ld-x86-64/property-x86-cet3b.d new file mode 100644 index 0000000..812c27e --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet3b.d @@ -0,0 +1,4 @@ +#source: property-x86-ibt.s +#as: --64 -defsym __64_bit__=1 -mx86-used-note=yes +#ld: -r -melf_x86_64 -z cet-report=error -z ibt +#error: .*: error: missing SHSTK property diff --git a/ld/testsuite/ld-x86-64/property-x86-cet4a-x32.d b/ld/testsuite/ld-x86-64/property-x86-cet4a-x32.d new file mode 100644 index 0000000..371d4b5 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet4a-x32.d @@ -0,0 +1,4 @@ +#source: property-x86-shstk.s +#as: --x32 -mx86-used-note=yes +#ld: -r -m elf32_x86_64 -z cet-report=error +#error: .*: error: missing IBT property diff --git a/ld/testsuite/ld-x86-64/property-x86-cet4a.d b/ld/testsuite/ld-x86-64/property-x86-cet4a.d new file mode 100644 index 0000000..c199017 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet4a.d @@ -0,0 +1,4 @@ +#source: property-x86-shstk.s +#as: --64 -defsym __64_bit__=1 -mx86-used-note=yes +#ld: -r -melf_x86_64 -z cet-report=error +#error: .*: error: missing IBT property diff --git a/ld/testsuite/ld-x86-64/property-x86-cet4b-x32.d b/ld/testsuite/ld-x86-64/property-x86-cet4b-x32.d new file mode 100644 index 0000000..e25791b --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet4b-x32.d @@ -0,0 +1,4 @@ +#source: property-x86-shstk.s +#as: --x32 -mx86-used-note=yes +#ld: -r -m elf32_x86_64 -z cet-report=error -z shstk +#error: .*: error: missing IBT property diff --git a/ld/testsuite/ld-x86-64/property-x86-cet4b.d b/ld/testsuite/ld-x86-64/property-x86-cet4b.d new file mode 100644 index 0000000..9796116 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet4b.d @@ -0,0 +1,4 @@ +#source: property-x86-shstk.s +#as: --64 -defsym __64_bit__=1 -mx86-used-note=yes +#ld: -r -melf_x86_64 -z cet-report=error -z shstk +#error: .*: error: missing IBT property diff --git a/ld/testsuite/ld-x86-64/property-x86-cet5a-x32.d b/ld/testsuite/ld-x86-64/property-x86-cet5a-x32.d new file mode 100644 index 0000000..dbbc68c --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet5a-x32.d @@ -0,0 +1,10 @@ +#source: property-x86-empty.s +#as: --x32 -mx86-used-note=yes +#ld: -r -m elf32_x86_64 -z cet-report=error -z cet-report=none +#readelf: -n + +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 + Properties: x86 ISA used: <None> + x86 feature used: x86 diff --git a/ld/testsuite/ld-x86-64/property-x86-cet5a.d b/ld/testsuite/ld-x86-64/property-x86-cet5a.d new file mode 100644 index 0000000..6870340 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet5a.d @@ -0,0 +1,10 @@ +#source: property-x86-empty.s +#as: --64 -defsym __64_bit__=1 -mx86-used-note=yes +#ld: -r -melf_x86_64 -z cet-report=error -z cet-report=none +#readelf: -n + +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0 + Properties: x86 ISA used: <None> + x86 feature used: x86 diff --git a/ld/testsuite/ld-x86-64/property-x86-cet5b-x32.d b/ld/testsuite/ld-x86-64/property-x86-cet5b-x32.d new file mode 100644 index 0000000..576ba22 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet5b-x32.d @@ -0,0 +1,11 @@ +#source: property-x86-empty.s +#as: --x32 -mx86-used-note=yes +#ld: -r -m elf32_x86_64 -z cet-report=error -z ibt -z shstk +#readelf: -n + +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x00000024 NT_GNU_PROPERTY_TYPE_0 + Properties: x86 feature: IBT, SHSTK + x86 ISA used: <None> + x86 feature used: x86 diff --git a/ld/testsuite/ld-x86-64/property-x86-cet5b.d b/ld/testsuite/ld-x86-64/property-x86-cet5b.d new file mode 100644 index 0000000..9f9d96e --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet5b.d @@ -0,0 +1,11 @@ +#source: property-x86-empty.s +#as: --64 -defsym __64_bit__=1 -mx86-used-note=yes +#ld: -r -melf_x86_64 -z cet-report=error -z ibt -z shstk +#readelf: -n + +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x00000030 NT_GNU_PROPERTY_TYPE_0 + Properties: x86 feature: IBT, SHSTK + x86 ISA used: <None> + x86 feature used: x86 diff --git a/ld/testsuite/ld-x86-64/property-x86-cet6-x32.d b/ld/testsuite/ld-x86-64/property-x86-cet6-x32.d new file mode 100644 index 0000000..4b74e59 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet6-x32.d @@ -0,0 +1,5 @@ +#source: start.s +#as: --x32 -mx86-used-note=no +#ld: -r -m elf32_x86_64 -z cet-report=warning +#warning: .*: warning: missing IBT and SHSTK properties +#readelf: -n diff --git a/ld/testsuite/ld-x86-64/property-x86-cet6.d b/ld/testsuite/ld-x86-64/property-x86-cet6.d new file mode 100644 index 0000000..632cbc7 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-cet6.d @@ -0,0 +1,5 @@ +#source: start.s +#as: --64 -defsym __64_bit__=1 -mx86-used-note=no +#ld: -r -melf_x86_64 -z cet-report=warning +#warning: .*: warning: missing IBT and SHSTK properties +#readelf: -n diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 47d92c9..408e52a 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -387,6 +387,26 @@ run_dump_test "property-x86-shstk4" run_dump_test "property-x86-shstk4-x32" run_dump_test "property-x86-shstk5" run_dump_test "property-x86-shstk5-x32" +run_dump_test "property-x86-cet1" +run_dump_test "property-x86-cet1-x32" +run_dump_test "property-x86-cet2a" +run_dump_test "property-x86-cet2a-x32" +run_dump_test "property-x86-cet2b" +run_dump_test "property-x86-cet2b-x32" +run_dump_test "property-x86-cet3a" +run_dump_test "property-x86-cet3a-x32" +run_dump_test "property-x86-cet3b" +run_dump_test "property-x86-cet3b-x32" +run_dump_test "property-x86-cet4a" +run_dump_test "property-x86-cet4a-x32" +run_dump_test "property-x86-cet4b" +run_dump_test "property-x86-cet4b-x32" +run_dump_test "property-x86-cet5a" +run_dump_test "property-x86-cet5a-x32" +run_dump_test "property-x86-cet5b" +run_dump_test "property-x86-cet5b-x32" +run_dump_test "property-x86-cet6" +run_dump_test "property-x86-cet6-x32" run_dump_test "pr21884" run_dump_test "pr21884-nacl" run_dump_test "pr22071" |