From: Matthieu Longo Date: Thu, 7 Nov 2024 13:13:20 +0000 (+0000) Subject: aarch64: add tests for combinations of GCS options and marked/unmarked inputs X-Git-Tag: gdb-16-branchpoint~222 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4de92ce8b239061fd896e1082af2023024ff3218;p=thirdparty%2Fbinutils-gdb.git aarch64: add tests for combinations of GCS options and marked/unmarked inputs --- diff --git a/ld/testsuite/ld-aarch64/protections/gcs-1-a.d b/ld/testsuite/ld-aarch64/protections/gcs-1-a.d new file mode 100644 index 00000000000..d65bcb9f5f4 --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-1-a.d @@ -0,0 +1,9 @@ +#name: No GCS option (equivalent to -z gcs=implicit) and empty GNU note property in input emits no GCS attribute [shared] +#source: gcs.s +#source: gcs2.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs +#ld: -shared +#readelf: -n + +# Expect no GNU section at all, so readelf output should be empty. \ No newline at end of file diff --git a/ld/testsuite/ld-aarch64/protections/gcs-1-b.d b/ld/testsuite/ld-aarch64/protections/gcs-1-b.d new file mode 100644 index 00000000000..9edcd3b51ae --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-1-b.d @@ -0,0 +1,12 @@ +#name: No GCS option (equivalent to -z gcs=implicit) and GCS GNU note property in input emits GCS attribute [shared] +#source: gcs.s +#source: gcs2.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -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/protections/gcs-1-c.d b/ld/testsuite/ld-aarch64/protections/gcs-1-c.d new file mode 100644 index 00000000000..8205832f524 --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-1-c.d @@ -0,0 +1,7 @@ +#name: Specifying '-z gcs' without value raise an error +#source: gcs.s +#source: gcs2.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1 +#ld: -shared -z gcs +#error: .*: error: unrecognized value '-z gcs' diff --git a/ld/testsuite/ld-aarch64/protections/gcs-1-d.d b/ld/testsuite/ld-aarch64/protections/gcs-1-d.d new file mode 100644 index 00000000000..736330375fa --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-1-d.d @@ -0,0 +1,7 @@ +#name: Specifying invalid value for '-z gcs' raise an error +#source: gcs.s +#source: gcs2.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs +#ld: -shared -z gcs=foo +#error: .*: error: unrecognized value '-z gcs=foo' diff --git a/ld/testsuite/ld-aarch64/protections/gcs-2-a-i.d b/ld/testsuite/ld-aarch64/protections/gcs-2-a-i.d new file mode 100644 index 00000000000..77711ea0a58 --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-2-a-i.d @@ -0,0 +1,12 @@ +#name: Specifying only '-z gcs=always' with GCS marked inputs emits GCS feature without warnings for inputs with GCS feature [shared] +#source: gcs.s +#source: gcs2.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1 +#ld: -shared -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/protections/gcs-2-a-ii.d b/ld/testsuite/ld-aarch64/protections/gcs-2-a-ii.d new file mode 100644 index 00000000000..04094a9036c --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-2-a-ii.d @@ -0,0 +1,14 @@ +#name: Specifying only '-z gcs=always' emits GCS feature with warnings for missing GCS feature on inputs [shared] +#source: gcs.s +#source: gcs2.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs +#ld: -shared -z gcs=always +#warning: \A[^\n]*gcs2\.o: warning: GCS is required by -z gcs[^\n]*\n +#warning: [^\n]*gcs\.o: warning: GCS is required by -z gcs[^\n]* +#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/protections/gcs-2-b-i.d b/ld/testsuite/ld-aarch64/protections/gcs-2-b-i.d new file mode 100644 index 00000000000..cecf2742495 --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-2-b-i.d @@ -0,0 +1,12 @@ +#name: Specifying only '-z gcs=implicit' and GCS-marked inputs emits GCS feature [shared] +#source: gcs.s +#source: gcs2.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1 +#ld: -shared -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/protections/gcs-2-b-ii.d b/ld/testsuite/ld-aarch64/protections/gcs-2-b-ii.d new file mode 100644 index 00000000000..853629935bb --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-2-b-ii.d @@ -0,0 +1,7 @@ +#name: Specifying only '-z gcs=implicit' and GCS-unmarked inputs emits no GCS feature without warnings [shared] +#source: gcs.s +#source: gcs2.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs +#ld: -shared -z gcs=implicit +#readelf: -n diff --git a/ld/testsuite/ld-aarch64/protections/gcs-2-b-iii.d b/ld/testsuite/ld-aarch64/protections/gcs-2-b-iii.d new file mode 100644 index 00000000000..b49e7c4d7ac --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-2-b-iii.d @@ -0,0 +1,12 @@ +#name: Specifying only '-z gcs=implicit -z gcs-report=warning' and GCS-marked inputs emits GCS feature [shared] +#source: gcs.s +#source: gcs2.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1 +#ld: -shared -z gcs=implicit -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/protections/gcs-2-b-iv.d b/ld/testsuite/ld-aarch64/protections/gcs-2-b-iv.d new file mode 100644 index 00000000000..c98f3e0525a --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-2-b-iv.d @@ -0,0 +1,7 @@ +#name: Specifying only '-z gcs=implicit -z gcs-report=warning' and GCS-unmarked inputs emits no GCS feature without warnings [shared] +#source: gcs.s +#source: gcs2.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs +#ld: -shared -z gcs=implicit -z gcs-report=warning +#readelf: -n diff --git a/ld/testsuite/ld-aarch64/protections/gcs-2-c-i.d b/ld/testsuite/ld-aarch64/protections/gcs-2-c-i.d new file mode 100644 index 00000000000..4bf8f6cbc16 --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-2-c-i.d @@ -0,0 +1,7 @@ +#name: Specifying only '-z gcs=never' and GCS-marked inputs emits no GCS feature [shared] +#source: gcs.s +#source: gcs2.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1 +#ld: -shared -z gcs=never +#readelf: -n diff --git a/ld/testsuite/ld-aarch64/protections/gcs-2-c-ii.d b/ld/testsuite/ld-aarch64/protections/gcs-2-c-ii.d new file mode 100644 index 00000000000..6941233cb6c --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-2-c-ii.d @@ -0,0 +1,7 @@ +#name: Specifying only '-z gcs=never' and GCS-unmarked inputs emits no GCS feature [shared] +#source: gcs.s +#source: gcs2.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs +#ld: -shared -z gcs=never +#readelf: -n diff --git a/ld/testsuite/ld-aarch64/protections/gcs-3-a-i.d b/ld/testsuite/ld-aarch64/protections/gcs-3-a-i.d new file mode 100644 index 00000000000..c1c5ba3e126 --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-3-a-i.d @@ -0,0 +1,8 @@ +#name: Specifying only '-z gcs=always -z gcs-report=error' with mixed inputs emits errors [shared] +#source: gcs.s +#source: gcs2.s +#source: nogcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1 +#ld: -shared -z gcs=always -z gcs-report=error +#error: \A[^\n]*nogcs\.o: error: GCS is required by -z gcs[^\n]*$ diff --git a/ld/testsuite/ld-aarch64/protections/gcs-3-a-ii.d b/ld/testsuite/ld-aarch64/protections/gcs-3-a-ii.d new file mode 100644 index 00000000000..d7289be30cf --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-3-a-ii.d @@ -0,0 +1,14 @@ +#name: Specifying only '-z gcs=always -z gcs-report=warning' with mixed inputs emits GCS feature and warnings [shared] +#source: gcs.s +#source: gcs2.s +#source: nogcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1 +#ld: -shared -z gcs=always -z gcs-report=warning +#warning: \A[^\n]*nogcs\.o: warning: GCS is required by -z gcs[^\n]*$ +#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/protections/gcs-3-a-iii.d b/ld/testsuite/ld-aarch64/protections/gcs-3-a-iii.d new file mode 100644 index 00000000000..5f55e2f16fc --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-3-a-iii.d @@ -0,0 +1,13 @@ +#name: Specifying only '-z gcs=always -z gcs-report=none' with mixed inputs emits GCS feature and no error/warning [shared] +#source: gcs.s +#source: gcs2.s +#source: nogcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1 +#ld: -shared -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/protections/gcs-3-a-iv.d b/ld/testsuite/ld-aarch64/protections/gcs-3-a-iv.d new file mode 100644 index 00000000000..5c340c40064 --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-3-a-iv.d @@ -0,0 +1,14 @@ +#name: Specifying only '-z gcs=always -z gcs-report' with mixed inputs emits GCS feature and warnings [shared] +#source: gcs.s +#source: gcs2.s +#source: nogcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1 +#ld: -shared -z gcs=always -z gcs-report +#warning: \A[^\n]*nogcs\.o: warning: GCS is required by -z gcs[^\n]*$ +#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/protections/gcs-3-b-i.d b/ld/testsuite/ld-aarch64/protections/gcs-3-b-i.d new file mode 100644 index 00000000000..70cc1bd7c15 --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-3-b-i.d @@ -0,0 +1,8 @@ +#name: Specifying only '-z gcs=implicit -z gcs-report=error' with mixed inputs emits no error/warning, and no GCS feature [shared] +#source: gcs.s +#source: gcs2.s +#source: nogcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1 +#ld: -shared -z gcs=implicit -z gcs-report=error +#readelf: -n \ No newline at end of file diff --git a/ld/testsuite/ld-aarch64/protections/gcs-3-b-ii.d b/ld/testsuite/ld-aarch64/protections/gcs-3-b-ii.d new file mode 100644 index 00000000000..f03e7ef7feb --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-3-b-ii.d @@ -0,0 +1,8 @@ +#name: Specifying only '-z gcs=implicit -z gcs-report=warning' with mixed inputs emits no warning, and no GCS feature [shared] +#source: gcs.s +#source: gcs2.s +#source: nogcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1 +#ld: -shared -z gcs=implicit -z gcs-report=warning +#readelf: -n \ No newline at end of file diff --git a/ld/testsuite/ld-aarch64/protections/gcs-3-b-iii.d b/ld/testsuite/ld-aarch64/protections/gcs-3-b-iii.d new file mode 100644 index 00000000000..3d3e07cb310 --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-3-b-iii.d @@ -0,0 +1,8 @@ +#name: Specifying only '-z gcs=implicit -z gcs-report=none' with mixed inputs emits no warning, and no GCS feature [shared] +#source: gcs.s +#source: gcs2.s +#source: nogcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1 +#ld: -shared -z gcs=implicit -z gcs-report=none +#readelf: -n \ No newline at end of file diff --git a/ld/testsuite/ld-aarch64/protections/gcs-3-c-i.d b/ld/testsuite/ld-aarch64/protections/gcs-3-c-i.d new file mode 100644 index 00000000000..472bb656d9e --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-3-c-i.d @@ -0,0 +1,8 @@ +#name: Specifying only '-z gcs=never -z gcs-report=error' with mixed inputs emits no error/warning, and no GCS feature [shared] +#source: gcs.s +#source: gcs2.s +#source: nogcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1 +#ld: -shared -z gcs=never -z gcs-report=error +#readelf: -n \ No newline at end of file diff --git a/ld/testsuite/ld-aarch64/protections/gcs-3-c-ii.d b/ld/testsuite/ld-aarch64/protections/gcs-3-c-ii.d new file mode 100644 index 00000000000..bbe5e1092c5 --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-3-c-ii.d @@ -0,0 +1,8 @@ +#name: Specifying only '-z gcs=never -z gcs-report=warning' with mixed inputs emits no error/warning, and no GCS feature [shared] +#source: gcs.s +#source: gcs2.s +#source: nogcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1 +#ld: -shared -z gcs=never -z gcs-report=warning +#readelf: -n \ No newline at end of file diff --git a/ld/testsuite/ld-aarch64/protections/gcs-3-c-iii.d b/ld/testsuite/ld-aarch64/protections/gcs-3-c-iii.d new file mode 100644 index 00000000000..6bf96bc9985 --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs-3-c-iii.d @@ -0,0 +1,8 @@ +#name: Specifying only '-z gcs=never -z gcs-report=none' with mixed inputs emits no error/warning, and no GCS feature [shared] +#source: gcs.s +#source: gcs2.s +#source: nogcs.s +#alltargets: [check_shared_lib_support] *linux* +#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1 +#ld: -shared -z gcs=never -z gcs-report=none +#readelf: -n \ No newline at end of file diff --git a/ld/testsuite/ld-aarch64/protections/gcs.s b/ld/testsuite/ld-aarch64/protections/gcs.s new file mode 100644 index 00000000000..3a4ce002adc --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs.s @@ -0,0 +1,12 @@ + .text + .globl _start + .type _start,@function +_start: + mov x1, #2 + bl foo + +.ifdef __splitted_gnu_properties__ +.include "gnu-note-properties-selectable-split.inc" +.else +.include "gnu-note-properties-selectable-merged.inc" +.endif diff --git a/ld/testsuite/ld-aarch64/protections/gcs2.s b/ld/testsuite/ld-aarch64/protections/gcs2.s new file mode 100644 index 00000000000..1e770cc3987 --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/gcs2.s @@ -0,0 +1,32 @@ + .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 + +.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/protections/nogcs.s b/ld/testsuite/ld-aarch64/protections/nogcs.s new file mode 100644 index 00000000000..f3079afdcc6 --- /dev/null +++ b/ld/testsuite/ld-aarch64/protections/nogcs.s @@ -0,0 +1,14 @@ + .text + .global foo3 + .type foo3, %function +foo3: + 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 foo3, .-foo3