diff options
author | Srinath Parvathaneni <srinath.parvathaneni@arm.com> | 2024-10-16 15:42:08 +0100 |
---|---|---|
committer | Andre Vieira <andre.simoesdiasvieira@arm.com> | 2024-10-16 15:47:13 +0100 |
commit | 8d59fa447f688b7863a5b3e6af5015e36c7f0024 (patch) | |
tree | 7620b9253ea8b3dc830cc2ad7b4ba78de9459265 /ld/testsuite | |
parent | a9ed7a0814fc70feaad485576d043a983b6f8695 (diff) | |
download | gdb-users/ARM/gcs.zip gdb-users/ARM/gcs.tar.gz gdb-users/ARM/gcs.tar.bz2 |
aarch64: Add support for GCS to AArch64 linkerusers/ARM/gcs
This patch adds support for Guarded Control Stack in AArch64 linker.
This patch implements the following:
1) Defines GNU_PROPERTY_AARCH64_FEATURE_1_GCS bit for GCS in
GNU_PROPERTY_AARCH64_FEATURE_1_AND macro.
2) Adds readelf support to read and print the GNU properties
in AArch64.
Displaying notes found in: .note.gnu.property
[ ]+Owner[ ]+Data size[ ]+Description
GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
Properties: AArch64 feature: GCS
3) Adds support for the "-z gcs" linker option and document all the values
allowed with this option (-z gcs[=always|never|implicit]) where "-z gcs" is
equivalent to "-z gcs=always" and when this option is not passed in the
command line, it defaults to "implicit".
4) Adds support for the "-z gcs-report" linker option and document all the
values allowed with this option (-z gcs-report[=none|warning|error]) where
"-z gcs-report" is equivalent to "-z gcs-report=none" and when this option
is not passed in the command line, it defaults to "none".
The ABI changes adding GNU_PROPERTY_AARCH64_FEATURE_1_GCS to the
GNU property GNU_PROPERTY_AARCH64_FEATURE_1_AND is merged into main and
can be found in [1].
[1] https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst
Co-authored-by: Matthieu Longo <matthieu.longo@arm.com>
Co-authored-by: Yury Khrustalev <yury.khrustalev@arm.com>
Diffstat (limited to 'ld/testsuite')
27 files changed, 310 insertions, 1 deletions
diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp index c7d97f3..d5a208f 100644 --- a/ld/testsuite/ld-aarch64/aarch64-elf.exp +++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp @@ -487,3 +487,26 @@ if { [supports_dt_relr] } { if { ![skip_sframe_tests] } { run_dump_test "sframe-simple-1" } + +run_dump_test "property-gcs1" +run_dump_test "property-gcs2" +run_dump_test "property-gcs3" +run_dump_test "property-gcs4" +run_dump_test "property-gcs5" +run_dump_test "property-gcs6" +run_dump_test "property-gcs7" +run_dump_test "property-gcs8" +run_dump_test "property-gcs9" +run_dump_test "property-gcs10" +run_dump_test "property-gcs11" +run_dump_test "property-gcs12" +run_dump_test "property-gcs13" +run_dump_test "property-gcs14" +run_dump_test "property-gcs15" +run_dump_test "property-gcs16" +run_dump_test "property-gcs17" +run_dump_test "property-gcs18" +run_dump_test "property-gcs19" +run_dump_test "property-gcs20" +run_dump_test "property-gcs21" +run_dump_test "property-gcs22" diff --git a/ld/testsuite/ld-aarch64/property-bti-pac1.d b/ld/testsuite/ld-aarch64/property-bti-pac1.d index 59fa695..c28a0cb 100644 --- a/ld/testsuite/ld-aarch64/property-bti-pac1.d +++ b/ld/testsuite/ld-aarch64/property-bti-pac1.d @@ -8,4 +8,4 @@ Displaying notes found in: .note.gnu.property [ ]+Owner[ ]+Data size[ ]+Description GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 - Properties: AArch64 feature: BTI, PAC + Properties: AArch64 feature: BTI, PAC, GCS diff --git a/ld/testsuite/ld-aarch64/property-bti-pac1.s b/ld/testsuite/ld-aarch64/property-bti-pac1.s index 414c927..4215691 100644 --- a/ld/testsuite/ld-aarch64/property-bti-pac1.s +++ b/ld/testsuite/ld-aarch64/property-bti-pac1.s @@ -17,6 +17,20 @@ _start: 2: .long 0xc0000000 /* pr_type. */ .long 4f - 3f /* pr_datasz. */ 3: + .long 0x4 /* GCS. */ +4: + .p2align 3 +5: + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long 5 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long 0xc0000000 /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: .long 0x2 /* PAC. */ 4: .p2align 3 diff --git a/ld/testsuite/ld-aarch64/property-gcs.s b/ld/testsuite/ld-aarch64/property-gcs.s new file mode 100644 index 0000000..bc7e66e8 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs.s @@ -0,0 +1,25 @@ + .text + .globl _start + .type _start,@function +_start: + mov x1, #2 +.ifndef __mult__ + bl foo +.endif +.ifdef __property_gcs__ + .section ".note.gnu.property", "a" + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long 5 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long 0xc0000000 /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: + .long 0x4 /* GCS. */ +4: + .p2align 3 +5: +.endif diff --git a/ld/testsuite/ld-aarch64/property-gcs1.d b/ld/testsuite/ld-aarch64/property-gcs1.d new file mode 100644 index 0000000..c724ac5 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs1.d @@ -0,0 +1,6 @@ +#name: GNU Property (input without gcs) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 +#ld: -shared +#readelf: -n diff --git a/ld/testsuite/ld-aarch64/property-gcs10.d b/ld/testsuite/ld-aarch64/property-gcs10.d new file mode 100644 index 0000000..3a2c992 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs10.d @@ -0,0 +1,6 @@ +#name: GNU Property (input without gcs output forced with gcs=always gcs-report=error) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 +#ld: -z gcs=always -z gcs-report=error +#error: .*property-gcs.*: error: GCS turned on by -z gcs on the output when all inputs do not have GCS in NOTE section. diff --git a/ld/testsuite/ld-aarch64/property-gcs11.d b/ld/testsuite/ld-aarch64/property-gcs11.d new file mode 100644 index 0000000..094b9be --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs11.d @@ -0,0 +1,11 @@ +#name: GNU Property (input with gcs output forced with gcs) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 -defsym __property_gcs__=1 +#ld: -z gcs +#readelf: -n + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: GCS diff --git a/ld/testsuite/ld-aarch64/property-gcs12.d b/ld/testsuite/ld-aarch64/property-gcs12.d new file mode 100644 index 0000000..3555447 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs12.d @@ -0,0 +1,11 @@ +#name: GNU Property (input with gcs output forced with gcs=always) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 -defsym __property_gcs__=1 +#ld: -z gcs=always +#readelf: -n + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: GCS diff --git a/ld/testsuite/ld-aarch64/property-gcs13.d b/ld/testsuite/ld-aarch64/property-gcs13.d new file mode 100644 index 0000000..c6543ba --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs13.d @@ -0,0 +1,11 @@ +#name: GNU Property (input with gcs output forced with gcs gcs-report=none) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 -defsym __property_gcs__=1 +#ld: -z gcs -z gcs-report=none +#readelf: -n + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: GCS diff --git a/ld/testsuite/ld-aarch64/property-gcs14.d b/ld/testsuite/ld-aarch64/property-gcs14.d new file mode 100644 index 0000000..1c612b5 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs14.d @@ -0,0 +1,11 @@ +#name: GNU Property (input with gcs output forced with gcs gcs-report=warning) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 -defsym __property_gcs__=1 +#ld: -z gcs -z gcs-report=warning +#readelf: -n + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: GCS diff --git a/ld/testsuite/ld-aarch64/property-gcs15.d b/ld/testsuite/ld-aarch64/property-gcs15.d new file mode 100644 index 0000000..7e46e8e --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs15.d @@ -0,0 +1,11 @@ +#name: GNU Property (input with gcs output forced with gcs gcs-report=error) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 -defsym __property_gcs__=1 +#ld: -z gcs -z gcs-report=error +#readelf: -n + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: GCS diff --git a/ld/testsuite/ld-aarch64/property-gcs16.d b/ld/testsuite/ld-aarch64/property-gcs16.d new file mode 100644 index 0000000..c20cbe5 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs16.d @@ -0,0 +1,11 @@ +#name: GNU Property (input with gcs output forced with gcs=always gcs-report=none) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 -defsym __property_gcs__=1 +#ld: -z gcs=always -z gcs-report=none +#readelf: -n + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: GCS diff --git a/ld/testsuite/ld-aarch64/property-gcs17.d b/ld/testsuite/ld-aarch64/property-gcs17.d new file mode 100644 index 0000000..2ee3f10 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs17.d @@ -0,0 +1,11 @@ +#name: GNU Property (input with gcs output forced with gcs=always gcs-report=warning) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 -defsym __property_gcs__=1 +#ld: -z gcs=always -z gcs-report=warning +#readelf: -n + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: GCS diff --git a/ld/testsuite/ld-aarch64/property-gcs18.d b/ld/testsuite/ld-aarch64/property-gcs18.d new file mode 100644 index 0000000..6c45d77 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs18.d @@ -0,0 +1,11 @@ +#name: GNU Property (input with gcs output forced with gcs=always gcs-report=error) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 -defsym __property_gcs__=1 +#ld: -z gcs=always -z gcs-report=error +#readelf: -n + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: GCS diff --git a/ld/testsuite/ld-aarch64/property-gcs19.d b/ld/testsuite/ld-aarch64/property-gcs19.d new file mode 100644 index 0000000..588af48 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs19.d @@ -0,0 +1,6 @@ +#name: GNU Property (input without gcs output forced with gcs=never) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 +#ld: -z gcs=never +#readelf: -n diff --git a/ld/testsuite/ld-aarch64/property-gcs2.d b/ld/testsuite/ld-aarch64/property-gcs2.d new file mode 100644 index 0000000..ed545a1 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs2.d @@ -0,0 +1,11 @@ +#name: GNU Property (input with gcs) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 -defsym __property_gcs__=1 +#ld: -shared +#readelf: -n + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: GCS diff --git a/ld/testsuite/ld-aarch64/property-gcs2.s b/ld/testsuite/ld-aarch64/property-gcs2.s new file mode 100644 index 0000000..6db7d83 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs2.s @@ -0,0 +1,33 @@ + .text + .global foo + .type foo, %function +foo: + sub sp, sp, #16 + mov w0, 9 + str w0, [sp, 12] + ldr w0, [sp, 12] + add w0, w0, 4 + str w0, [sp, 12] + nop + add sp, sp, 16 + ret + .size foo, .-foo + .global bar + .type bar, %function +.ifdef __property_gcs__ + .section ".note.gnu.property", "a" + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long 5 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long 0xc0000000 /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: + .long 0x4 /* GCS. */ +4: + .p2align 3 +5: +.endif diff --git a/ld/testsuite/ld-aarch64/property-gcs20.d b/ld/testsuite/ld-aarch64/property-gcs20.d new file mode 100644 index 0000000..779e845 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs20.d @@ -0,0 +1,6 @@ +#name: GNU Property (input without gcs output forced with gcs=implicit) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 +#ld: -z gcs=implicit +#readelf: -n diff --git a/ld/testsuite/ld-aarch64/property-gcs21.d b/ld/testsuite/ld-aarch64/property-gcs21.d new file mode 100644 index 0000000..dbfb5ec --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs21.d @@ -0,0 +1,6 @@ +#name: GNU Property (input with gcs output forced with gcs=never) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 -defsym __property_gcs__=1 +#ld: -z gcs=never +#readelf: -n diff --git a/ld/testsuite/ld-aarch64/property-gcs22.d b/ld/testsuite/ld-aarch64/property-gcs22.d new file mode 100644 index 0000000..dd92399 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs22.d @@ -0,0 +1,11 @@ +#name: GNU Property (input with gcs output forced with gcs=implicit) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 -defsym __property_gcs__=1 +#ld: -z gcs=implicit +#readelf: -n + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: GCS diff --git a/ld/testsuite/ld-aarch64/property-gcs3.d b/ld/testsuite/ld-aarch64/property-gcs3.d new file mode 100644 index 0000000..0ea2d7e --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs3.d @@ -0,0 +1,11 @@ +#name: GNU Property (input without gcs output forced with gcs) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 +#ld: -z gcs +#readelf: -n + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: GCS diff --git a/ld/testsuite/ld-aarch64/property-gcs4.d b/ld/testsuite/ld-aarch64/property-gcs4.d new file mode 100644 index 0000000..0669d64 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs4.d @@ -0,0 +1,11 @@ +#name: GNU Property (input without gcs output forced with gcs=always) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 +#ld: -z gcs=always +#readelf: -n + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: GCS diff --git a/ld/testsuite/ld-aarch64/property-gcs5.d b/ld/testsuite/ld-aarch64/property-gcs5.d new file mode 100644 index 0000000..df8643a --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs5.d @@ -0,0 +1,11 @@ +#name: GNU Property (input without gcs output forced with gcs gcs-report=none) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 +#ld: -z gcs -z gcs-report=none +#readelf: -n + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: GCS diff --git a/ld/testsuite/ld-aarch64/property-gcs6.d b/ld/testsuite/ld-aarch64/property-gcs6.d new file mode 100644 index 0000000..3646e8a --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs6.d @@ -0,0 +1,12 @@ +#name: GNU Property (input without gcs output forced with gcs gcs-report=warning) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 +#ld: -z gcs -z gcs-report=warning +#readelf: -n +#warning: .*property-gcs.*: warning: GCS turned on by -z gcs on the output when all inputs do not have GCS in NOTE section. + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: GCS diff --git a/ld/testsuite/ld-aarch64/property-gcs7.d b/ld/testsuite/ld-aarch64/property-gcs7.d new file mode 100644 index 0000000..ba58fe2 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs7.d @@ -0,0 +1,6 @@ +#name: GNU Property (input without gcs output forced with gcs gcs-report=error) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 +#ld: -z gcs -z gcs-report=error +#error: .*property-gcs.*: error: GCS turned on by -z gcs on the output when all inputs do not have GCS in NOTE section. diff --git a/ld/testsuite/ld-aarch64/property-gcs8.d b/ld/testsuite/ld-aarch64/property-gcs8.d new file mode 100644 index 0000000..f442b71 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs8.d @@ -0,0 +1,11 @@ +#name: GNU Property (input without gcs output forced with gcs=always gcs-report=none) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 +#ld: -z gcs=always -z gcs-report=none +#readelf: -n + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: GCS diff --git a/ld/testsuite/ld-aarch64/property-gcs9.d b/ld/testsuite/ld-aarch64/property-gcs9.d new file mode 100644 index 0000000..82b93ec --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-gcs9.d @@ -0,0 +1,12 @@ +#name: GNU Property (input without gcs output forced with gcs=always gcs-report=warning) +#source: property-gcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __mult__=0 +#ld: -z gcs=always -z gcs-report=warning +#readelf: -n +#warning: .*property-gcs.*: warning: GCS turned on by -z gcs on the output when all inputs do not have GCS in NOTE section. + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: GCS |