From: Matthieu Longo Date: Tue, 25 Feb 2025 17:28:03 +0000 (+0000) Subject: ld tests for AArch64-specific merge coverage for AEABI Build Attributes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1490cde2954ba65a06bd147d38df675c167dfea;p=thirdparty%2Fbinutils-gdb.git ld tests for AArch64-specific merge coverage for AEABI Build Attributes Test cases: - coverage of required subsection 'aeabi_pauthabi'. - coverage for BTI, PAC, GCS used along GNU properties. - warn on unknown attributes, and prune them from output. --- diff --git a/ld/testsuite/ld-aarch64/build-attributes/aarch64-build-attributes.exp b/ld/testsuite/ld-aarch64/build-attributes/aarch64-build-attributes.exp index 655a6797145..2eaa6b58249 100644 --- a/ld/testsuite/ld-aarch64/build-attributes/aarch64-build-attributes.exp +++ b/ld/testsuite/ld-aarch64/build-attributes/aarch64-build-attributes.exp @@ -27,19 +27,6 @@ load_file $srcdir/$subdir/../lib/aarch64-elf-lib.exp set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]] -# See definition of run_ld_link_tests in testsuite/lib/ld-lib.exp for more -# details. -# set aarch64elflinktests { -# {"Build bti-plt-so for PLT tests" -# "-shared" "" -# "-I$srcdir/$subdir -defsym __property_bti__=1" -# {bti-plt-so.s} {} "libbti-plt-so.so"} -# } - -# if [check_shared_lib_support] { -# run_ld_link_tests $aarch64elflinktests -# } - foreach t $test_list { # We need to strip the ".d", but can leave the dirname. run_dump_test [file rootname $t] \ diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-1.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-1.s new file mode 100644 index 00000000000..c5ad5e98417 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-1.s @@ -0,0 +1,9 @@ +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_BTI, 1 + + .text + .globl _start + .type _start,@function +_start: + bl foo + bl bar diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-2.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-2.s new file mode 100644 index 00000000000..1347a66739e --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-2.s @@ -0,0 +1,14 @@ +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_BTI, 1 + + .text + .globl foo2 + .type foo2,@function +foo2: + bl foo_2 + +.ifdef __split_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/build-attributes/ba-aarch64-1-bti-explicit-ok-objdump-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-explicit-ok-objdump-dump.d new file mode 100644 index 00000000000..4bf0ae044a8 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-explicit-ok-objdump-dump.d @@ -0,0 +1,53 @@ +# name: EABI build attributes: some files missing Tag_Feature_BTI, but -z force-bti generates PLT with BTI. +# source: ba-aarch64-1-bti-1.s +# source: ba-aarch64-1-void.s +# source: ba-aarch64-1-bti-via-gnu-props.s +# source: ba-aarch64-1-bti-2.s +# as: -defsym __property_bti__=1 +# ld: -shared -T bti-plt.ld -z force-bti -z bti-report=warning +#warning: \A[^\n]*ba-aarch64-1-void\.o: warning: BTI is required by -z force-bti, but this input object file lacks the necessary property note\. +# objdump: -dr -j .plt + +[^:]*: *file format elf64-.*aarch64 + +Disassembly of section \.plt: + +[0-9]+ <\.plt>: +.*: d503245f bti c +.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]! +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9400e11 ldr x17, \[x16, #24\] +.*: 91006210 add x16, x16, #0x18 +.*: d61f0220 br x17 +.*: d503201f nop +.*: d503201f nop + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401211 ldr x17, \[x16, #32\] +.*: 91008210 add x16, x16, #0x20 +.*: d61f0220 br x17 + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401611 ldr x17, \[x16, #40\] +.*: 9100a210 add x16, x16, #0x28 +.*: d61f0220 br x17 + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401a11 ldr x17, \[x16, #48\] +.*: 9100c210 add x16, x16, #0x30 +.*: d61f0220 br x17 + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401e11 ldr x17, \[x16, #56\] +.*: 9100e210 add x16, x16, #0x38 +.*: d61f0220 br x17 + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9402211 ldr x17, \[x16, #64\] +.*: 91010210 add x16, x16, #0x40 +.*: d61f0220 br x17 diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-explicit-ok-readelf-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-explicit-ok-readelf-dump.d new file mode 100644 index 00000000000..8a87503926f --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-explicit-ok-readelf-dump.d @@ -0,0 +1,24 @@ +# name: EABI build attributes: some files missing Tag_Feature_BTI, but -z force-bti means that the output has Tag_Feature_BTI=0x1 +# source: ba-aarch64-1-bti-1.s +# source: ba-aarch64-1-void.s +# source: ba-aarch64-1-bti-via-gnu-props.s +# source: ba-aarch64-1-bti-2.s +# as: -defsym __property_bti__=1 +# ld: -shared -T bti-plt.ld -z force-bti -z bti-report=warning +#warning: .*ba-aarch64-1-void\.o: warning: BTI is required by -z force-bti.* +# readelf: --arch-specific --notes + +Displaying notes found in: \.note\.gnu\.property + Owner Data size Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties:[ ]+AArch64 feature: BTI +Subsections: + - Name:[ ]+aeabi_feature_and_bits + Scope:[ ]+public + Length:[ ]+35 + Comprehension:[ ]+optional + Encoding:[ ]+ULEB128 + Values: + +Tag_Feature_BTI:[ ]+1 .* + +Tag_Feature_PAC:[ ]+0 .* + +Tag_Feature_GCS:[ ]+0 .* diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-explicit-only-one-input-without-ba-or-gnu-props.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-explicit-only-one-input-without-ba-or-gnu-props.d new file mode 100644 index 00000000000..6bbacea8fd5 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-explicit-only-one-input-without-ba-or-gnu-props.d @@ -0,0 +1,19 @@ +# name: EABI build attributes: a input object without build attributes or GNU properties, but -z force-bti means that the output has Tag_Feature_BTI=0x1 +# source: ba-aarch64-1-void.s +# as: +# ld: -shared -T bti-plt.ld -z force-bti -z bti-report=warning +#warning: .*ba-aarch64-1-void\.o: warning: BTI is required by -z force-bti.* +# readelf: --arch-specific --notes + +Displaying notes found in: \.note\.gnu\.property + Owner Data size Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties:[ ]+AArch64 feature: BTI +Subsections: + - Name:[ ]+aeabi_feature_and_bits + Scope:[ ]+public + Length:[ ]+31 + Comprehension:[ ]+optional + Encoding:[ ]+ULEB128 + Values: + +Tag_Feature_BTI:[ ]+1 .* diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-gnu-props-only-implicit-ok-readelf-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-gnu-props-only-implicit-ok-readelf-dump.d new file mode 100644 index 00000000000..3eabbc1df94 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-gnu-props-only-implicit-ok-readelf-dump.d @@ -0,0 +1,20 @@ +# name: EABI build attributes: all files with BTI GNU property means that output also has Tag_Feature_BTI=0x1 +# source: ba-aarch64-1-bti-via-gnu-props.s +# as: -defsym __property_bti__=1 +# ld: -shared -T bti-plt.ld +# readelf: --arch-specific --notes + +Displaying notes found in: \.note\.gnu\.property + Owner Data size Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties:[ ]+AArch64 feature: BTI +Subsections: + - Name:[ ]+aeabi_feature_and_bits + Scope:[ ]+public + Length:[ ]+35 + Comprehension:[ ]+optional + Encoding:[ ]+ULEB128 + Values: + +Tag_Feature_BTI:[ ]+1 .* + +Tag_Feature_PAC:[ ]+0 .* + +Tag_Feature_GCS:[ ]+0 .* diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-implicit-nok-objdump-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-implicit-nok-objdump-dump.d new file mode 100644 index 00000000000..d011b57cfbb --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-implicit-nok-objdump-dump.d @@ -0,0 +1,45 @@ +# name: EABI build attributes: some files missing Tag_Feature_BTI does not trigger generation of PLT with BTI. +# source: ba-aarch64-1-bti-1.s +# source: ba-aarch64-1-void.s +# source: ba-aarch64-1-bti-2.s +# as: +# ld: -shared -T bti-plt.ld +# objdump: -dr -j .plt + +[^:]*: *file format elf64-.*aarch64 + +Disassembly of section \.plt: + +[0-9]+ <\.plt>: +.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]! +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9400e11 ldr x17, \[x16, #24\] +.*: 91006210 add x16, x16, #0x18 +.*: d61f0220 br x17 +.*: d503201f nop +.*: d503201f nop +.*: d503201f nop + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401211 ldr x17, \[x16, #32\] +.*: 91008210 add x16, x16, #0x20 +.*: d61f0220 br x17 + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401611 ldr x17, \[x16, #40\] +.*: 9100a210 add x16, x16, #0x28 +.*: d61f0220 br x17 + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401a11 ldr x17, \[x16, #48\] +.*: 9100c210 add x16, x16, #0x30 +.*: d61f0220 br x17 + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401e11 ldr x17, \[x16, #56\] +.*: 9100e210 add x16, x16, #0x38 +.*: d61f0220 br x17 diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-implicit-nok-readelf-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-implicit-nok-readelf-dump.d new file mode 100644 index 00000000000..6b5d92e37cc --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-implicit-nok-readelf-dump.d @@ -0,0 +1,16 @@ +# name: EABI build attributes: some files missing Tag_Feature_BTI means that the output has Tag_Feature_BTI=0x0 +# source: ba-aarch64-1-bti-1.s +# source: ba-aarch64-1-void.s +# source: ba-aarch64-1-bti-2.s +# as: +# ld: -shared -T bti-plt.ld +# readelf: --arch-specific --notes + +Subsections: + - Name:[ ]+aeabi_feature_and_bits + Scope:[ ]+public + Length:[ ]+31 + Comprehension:[ ]+optional + Encoding:[ ]+ULEB128 + Values: + +Tag_Feature_BTI:[ ]+0 .* diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-implicit-ok-objdump-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-implicit-ok-objdump-dump.d new file mode 100644 index 00000000000..2a4a04454a8 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-implicit-ok-objdump-dump.d @@ -0,0 +1,38 @@ +# name: EABI build attributes: all files with Tag_Feature_BTI=0x1 generates PLT with BTI. +# source: ba-aarch64-1-bti-1.s +# source: ba-aarch64-1-bti-2.s +# as: +# ld: -shared -T bti-plt.ld +# objdump: -dr -j .plt + +[^:]*: *file format elf64-.*aarch64 + +Disassembly of section \.plt: + +[0-9]+ <\.plt>: +.*: d503245f bti c +.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]! +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9400e11 ldr x17, \[x16, #24\] +.*: 91006210 add x16, x16, #0x18 +.*: d61f0220 br x17 +.*: d503201f nop +.*: d503201f nop + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401211 ldr x17, \[x16, #32\] +.*: 91008210 add x16, x16, #0x20 +.*: d61f0220 br x17 + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401611 ldr x17, \[x16, #40\] +.*: 9100a210 add x16, x16, #0x28 +.*: d61f0220 br x17 + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401a11 ldr x17, \[x16, #48\] +.*: 9100c210 add x16, x16, #0x30 +.*: d61f0220 br x17 diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-implicit-ok-readelf-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-implicit-ok-readelf-dump.d new file mode 100644 index 00000000000..6a814604a0a --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-implicit-ok-readelf-dump.d @@ -0,0 +1,19 @@ +# name: EABI build attributes: all files with Tag_Feature_BTI=0x1 means that output also has Tag_Feature_BTI=0x1 +# source: ba-aarch64-1-bti-1.s +# source: ba-aarch64-1-bti-2.s +# as: +# ld: -shared -T bti-plt.ld +# readelf: --arch-specific --notes + +Displaying notes found in: \.note\.gnu\.property + Owner Data size Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties:[ ]+AArch64 feature: BTI +Subsections: + - Name:[ ]+aeabi_feature_and_bits + Scope:[ ]+public + Length:[ ]+31 + Comprehension:[ ]+optional + Encoding:[ ]+ULEB128 + Values: + +Tag_Feature_BTI:[ ]+1 .* diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-via-gnu-props.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-via-gnu-props.s new file mode 100644 index 00000000000..b327f6758a3 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-via-gnu-props.s @@ -0,0 +1,11 @@ + .text + .globl foo3 + .type foo3,@function +foo3: + bl foo_3 + +.ifdef __split_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/build-attributes/ba-aarch64-1-bti-with-mix-gnu-props-and-bas-implicit-ok-readelf-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-with-mix-gnu-props-and-bas-implicit-ok-readelf-dump.d new file mode 100644 index 00000000000..f7fd853469f --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-bti-with-mix-gnu-props-and-bas-implicit-ok-readelf-dump.d @@ -0,0 +1,22 @@ +# name: EABI build attributes: EABI build attributes: some files with build attribute Tag_Feature_BTI=0x1 and others with equivalent GNU property means that output also has Tag_Feature_BTI=0x1 +# source: ba-aarch64-1-bti-1.s +# source: ba-aarch64-1-bti-via-gnu-props.s +# source: ba-aarch64-1-bti-2.s +# as: -defsym __property_bti__=1 +# ld: -shared -T bti-plt.ld +# readelf: --arch-specific --notes + +Displaying notes found in: \.note\.gnu\.property + Owner Data size Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties:[ ]+AArch64 feature: BTI +Subsections: + - Name:[ ]+aeabi_feature_and_bits + Scope:[ ]+public + Length:[ ]+35 + Comprehension:[ ]+optional + Encoding:[ ]+ULEB128 + Values: + +Tag_Feature_BTI:[ ]+1 .* + +Tag_Feature_PAC:[ ]+0 .* + +Tag_Feature_GCS:[ ]+0 .* diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-1.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-1.s new file mode 100644 index 00000000000..b7e54dedefb --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-1.s @@ -0,0 +1,9 @@ +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_GCS, 1 + + .text + .globl _start + .type _start,@function +_start: + bl foo + bl bar diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-2.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-2.s new file mode 100644 index 00000000000..06bb3898ac8 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-2.s @@ -0,0 +1,14 @@ +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_GCS, 1 + + .text + .globl foo2 + .type foo2,@function +foo2: + bl foo_2 + +.ifdef __split_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/build-attributes/ba-aarch64-1-gcs-explicit-ok-readelf-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-explicit-ok-readelf-dump.d new file mode 100644 index 00000000000..4f91949ad9b --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-explicit-ok-readelf-dump.d @@ -0,0 +1,24 @@ +# name: EABI build attributes: some files missing Tag_Feature_GCS, but -z gcs=always means that GCS is required. +# source: ba-aarch64-1-gcs-1.s +# source: ba-aarch64-1-void.s +# source: ba-aarch64-1-gcs-via-gnu-props.s +# source: ba-aarch64-1-gcs-2.s +# as: -defsym __property_gcs__=1 +# ld: -shared -z gcs=always -z gcs-report=warning +#warning: .*ba-aarch64-1-void\.o: warning: GCS is required by -z gcs.* +# readelf: --arch-specific --notes + +Displaying notes found in: \.note\.gnu\.property + Owner Data size Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties:[ ]+AArch64 feature: GCS +Subsections: + - Name:[ ]+aeabi_feature_and_bits + Scope:[ ]+public + Length:[ ]+35 + Comprehension:[ ]+optional + Encoding:[ ]+ULEB128 + Values: + +Tag_Feature_BTI:[ ]+0 .* + +Tag_Feature_PAC:[ ]+0 .* + +Tag_Feature_GCS:[ ]+1 .* diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-gnu-props-only-implicit-ok-readelf-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-gnu-props-only-implicit-ok-readelf-dump.d new file mode 100644 index 00000000000..4527f086917 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-gnu-props-only-implicit-ok-readelf-dump.d @@ -0,0 +1,20 @@ +# name: EABI build attributes: all files with GCS GNU property means that output also has Tag_Feature_GCS=0x1 +# source: ba-aarch64-1-gcs-via-gnu-props.s +# as: -defsym __property_gcs__=1 +# ld: -shared +# readelf: --arch-specific --notes + +Displaying notes found in: \.note\.gnu\.property + Owner Data size Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties:[ ]+AArch64 feature: GCS +Subsections: + - Name:[ ]+aeabi_feature_and_bits + Scope:[ ]+public + Length:[ ]+35 + Comprehension:[ ]+optional + Encoding:[ ]+ULEB128 + Values: + +Tag_Feature_BTI:[ ]+0 .* + +Tag_Feature_PAC:[ ]+0 .* + +Tag_Feature_GCS:[ ]+1 .* diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-implicit-nok-readelf-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-implicit-nok-readelf-dump.d new file mode 100644 index 00000000000..d40919aadba --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-implicit-nok-readelf-dump.d @@ -0,0 +1,16 @@ +# name: EABI build attributes: some files missing Tag_Feature_GCS means that the output has Tag_Feature_GCS=0x0 +# source: ba-aarch64-1-gcs-1.s +# source: ba-aarch64-1-void.s +# source: ba-aarch64-1-gcs-2.s +# as: +# ld: -shared -z gcs=implicit -z gcs-report=warning +# readelf: --arch-specific --notes + +Subsections: + - Name:[ ]+aeabi_feature_and_bits + Scope:[ ]+public + Length:[ ]+31 + Comprehension:[ ]+optional + Encoding:[ ]+ULEB128 + Values: + +Tag_Feature_GCS:[ ]+0 .* diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-implicit-ok-readelf-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-implicit-ok-readelf-dump.d new file mode 100644 index 00000000000..318604930d2 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-implicit-ok-readelf-dump.d @@ -0,0 +1,19 @@ +# name: EABI build attributes: all files with Tag_Feature_GCS=0x1 means that output also has Tag_Feature_GCS=0x1 +# source: ba-aarch64-1-gcs-1.s +# source: ba-aarch64-1-gcs-2.s +# as: +# ld: -shared +# readelf: --arch-specific --notes + +Displaying notes found in: \.note\.gnu\.property + Owner Data size Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties:[ ]+AArch64 feature: GCS +Subsections: + - Name:[ ]+aeabi_feature_and_bits + Scope:[ ]+public + Length:[ ]+31 + Comprehension:[ ]+optional + Encoding:[ ]+ULEB128 + Values: + +Tag_Feature_GCS:[ ]+1 .* diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-via-gnu-props.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-via-gnu-props.s new file mode 100644 index 00000000000..b327f6758a3 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-gcs-via-gnu-props.s @@ -0,0 +1,11 @@ + .text + .globl foo3 + .type foo3,@function +foo3: + bl foo_3 + +.ifdef __split_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/build-attributes/ba-aarch64-1-no-bti.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-no-bti.s new file mode 100644 index 00000000000..1093ccfd240 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-no-bti.s @@ -0,0 +1,2 @@ +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_BTI, 0 diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-no-gcs.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-no-gcs.s new file mode 100644 index 00000000000..35b527fba1e --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-no-gcs.s @@ -0,0 +1,2 @@ +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_GCS, 0 diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-1.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-1.s new file mode 100644 index 00000000000..773732f622c --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-1.s @@ -0,0 +1,9 @@ +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_PAC, 1 + + .text + .globl _start + .type _start,@function +_start: + bl foo + bl bar \ No newline at end of file diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-2.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-2.s new file mode 100644 index 00000000000..4a7f805f444 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-2.s @@ -0,0 +1,14 @@ +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_PAC, 1 + + .text + .globl foo2 + .type foo2,@function +foo2: + bl foo_2 + +.ifdef __split_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/build-attributes/ba-aarch64-1-pac-ba-with-pac-plt-objdump-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-ba-with-pac-plt-objdump-dump.d new file mode 100644 index 00000000000..fc4d144e3b1 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-ba-with-pac-plt-objdump-dump.d @@ -0,0 +1,44 @@ +# name: EABI build attributes: all files with Tag_Feature_PAC=0x1 and '-z pac-plt' does generate PLT with PAC. +# source: ba-aarch64-1-pac-1.s +# source: ba-aarch64-1-pac-2.s +# as: -defsym __property_pac__=1 +# ld: -shared -T bti-plt.ld -z pac-plt +# objdump: -dr -j .plt + +[^:]*: *file format elf64-.*aarch64 + +Disassembly of section \.plt: + +[0-9]+ <\.plt>: +.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]! +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9400e11 ldr x17, \[x16, #24\] +.*: 91006210 add x16, x16, #0x18 +.*: d61f0220 br x17 +.*: d503201f nop +.*: d503201f nop +.*: d503201f nop + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401211 ldr x17, \[x16, #32\] +.*: 91008210 add x16, x16, #0x20 +.*: d503219f autia1716 +.*: d61f0220 br x17 +.*: d503201f nop + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401611 ldr x17, \[x16, #40\] +.*: 9100a210 add x16, x16, #0x28 +.*: d503219f autia1716 +.*: d61f0220 br x17 +.*: d503201f nop + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401a11 ldr x17, \[x16, #48\] +.*: 9100c210 add x16, x16, #0x30 +.*: d503219f autia1716 +.*: d61f0220 br x17 +.*: d503201f nop diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-ba-with-pac-plt-readelf-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-ba-with-pac-plt-readelf-dump.d new file mode 100644 index 00000000000..4ae69a53643 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-ba-with-pac-plt-readelf-dump.d @@ -0,0 +1,21 @@ +# name: EABI build attributes: all files with Tag_Feature_PAC=0x1 and '-z pac-plt' means that output has Tag_Feature_PAC=0x1 +# source: ba-aarch64-1-pac-1.s +# source: ba-aarch64-1-pac-2.s +# as: -defsym __property_pac__=1 +# ld: -shared -T bti-plt.ld -z pac-plt +# readelf: --arch-specific --notes + +Displaying notes found in: \.note\.gnu\.property + Owner Data size Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties:[ ]+AArch64 feature: PAC +Subsections: + - Name:[ ]+aeabi_feature_and_bits + Scope:[ ]+public + Length:[ ]+35 + Comprehension:[ ]+optional + Encoding:[ ]+ULEB128 + Values: + +Tag_Feature_BTI:[ ]+0 .* + +Tag_Feature_PAC:[ ]+1 .* + +Tag_Feature_GCS:[ ]+0 .* diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-ba-without-pac-plt-objdump-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-ba-without-pac-plt-objdump-dump.d new file mode 100644 index 00000000000..8abc5856fdd --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-ba-without-pac-plt-objdump-dump.d @@ -0,0 +1,38 @@ +# name: EABI build attributes: all files with Tag_Feature_PAC=0x1 but no '-z pac-plt' does not generate PLT with PAC. +# source: ba-aarch64-1-pac-1.s +# source: ba-aarch64-1-pac-2.s +# as: -defsym __property_pac__=1 +# ld: -shared -T bti-plt.ld +# objdump: -dr -j .plt + +[^:]*: *file format elf64-.*aarch64 + +Disassembly of section \.plt: + +[0-9]+ <\.plt>: +.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]! +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9400e11 ldr x17, \[x16, #24\] +.*: 91006210 add x16, x16, #0x18 +.*: d61f0220 br x17 +.*: d503201f nop +.*: d503201f nop +.*: d503201f nop + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401211 ldr x17, \[x16, #32\] +.*: 91008210 add x16, x16, #0x20 +.*: d61f0220 br x17 + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401611 ldr x17, \[x16, #40\] +.*: 9100a210 add x16, x16, #0x28 +.*: d61f0220 br x17 + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401a11 ldr x17, \[x16, #48\] +.*: 9100c210 add x16, x16, #0x30 +.*: d61f0220 br x17 diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-ba-without-pac-plt-readelf-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-ba-without-pac-plt-readelf-dump.d new file mode 100644 index 00000000000..22ae709831d --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-ba-without-pac-plt-readelf-dump.d @@ -0,0 +1,21 @@ +# name: EABI build attributes: all files with Tag_Feature_PAC=0x1 but no '-z pac-plt' means that output has Tag_Feature_PAC=0x1 +# source: ba-aarch64-1-pac-1.s +# source: ba-aarch64-1-pac-2.s +# as: -defsym __property_pac__=1 +# ld: -shared -T bti-plt.ld +# readelf: --arch-specific --notes + +Displaying notes found in: \.note\.gnu\.property + Owner Data size Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties:[ ]+AArch64 feature: PAC +Subsections: + - Name:[ ]+aeabi_feature_and_bits + Scope:[ ]+public + Length:[ ]+35 + Comprehension:[ ]+optional + Encoding:[ ]+ULEB128 + Values: + +Tag_Feature_BTI:[ ]+0 .* + +Tag_Feature_PAC:[ ]+1 .* + +Tag_Feature_GCS:[ ]+0 .* diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-plt-but-no-pac-ba-objdump-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-plt-but-no-pac-ba-objdump-dump.d new file mode 100644 index 00000000000..0c150b9c33e --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-plt-but-no-pac-ba-objdump-dump.d @@ -0,0 +1,53 @@ +# name: EABI build attributes: '-z pac-plt' with some files without Tag_Feature_PAC=0x1 generates PLT with PAC. +# source: ba-aarch64-1-pac-1.s +# source: ba-aarch64-1-void.s +# source: ba-aarch64-1-pac-2.s +# as: -defsym __property_pac__=1 +# ld: -shared -T bti-plt.ld -z pac-plt +# objdump: -dr -j .plt + +[^:]*: *file format elf64-.*aarch64 + +Disassembly of section \.plt: + +[0-9]+ <\.plt>: +.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]! +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9400e11 ldr x17, \[x16, #24\] +.*: 91006210 add x16, x16, #0x18 +.*: d61f0220 br x17 +.*: d503201f nop +.*: d503201f nop +.*: d503201f nop + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401211 ldr x17, \[x16, #32\] +.*: 91008210 add x16, x16, #0x20 +.*: d503219f autia1716 +.*: d61f0220 br x17 +.*: d503201f nop + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401611 ldr x17, \[x16, #40\] +.*: 9100a210 add x16, x16, #0x28 +.*: d503219f autia1716 +.*: d61f0220 br x17 +.*: d503201f nop + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401a11 ldr x17, \[x16, #48\] +.*: 9100c210 add x16, x16, #0x30 +.*: d503219f autia1716 +.*: d61f0220 br x17 +.*: d503201f nop + +[0-9]+ : +.*: [[:xdigit:]]{8} adrp x16, [[:xdigit:]]+ <_GLOBAL_OFFSET_TABLE_> +.*: f9401e11 ldr x17, \[x16, #56\] +.*: 9100e210 add x16, x16, #0x38 +.*: d503219f autia1716 +.*: d61f0220 br x17 +.*: d503201f nop diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-plt-but-no-pac-ba-readelf-dump.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-plt-but-no-pac-ba-readelf-dump.d new file mode 100644 index 00000000000..05da5802d16 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-plt-but-no-pac-ba-readelf-dump.d @@ -0,0 +1,18 @@ +# name: EABI build attributes: '-z pac-plt' with some files without Tag_Feature_PAC=0x1 does not set Tag_Feature_PAC=0x1. +# source: ba-aarch64-1-pac-1.s +# source: ba-aarch64-1-void.s +# source: ba-aarch64-1-pac-2.s +# as: -defsym __property_pac__=1 +# ld: -shared -T bti-plt.ld -z pac-plt +# readelf: --arch-specific --notes + +Subsections: + - Name:[ ]+aeabi_feature_and_bits + Scope:[ ]+public + Length:[ ]+35 + Comprehension:[ ]+optional + Encoding:[ ]+ULEB128 + Values: + +Tag_Feature_BTI:[ ]+0 .* + +Tag_Feature_PAC:[ ]+0 .* + +Tag_Feature_GCS:[ ]+0 .* diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-via-gnu-props.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-via-gnu-props.s new file mode 100644 index 00000000000..b327f6758a3 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-pac-via-gnu-props.s @@ -0,0 +1,11 @@ + .text + .globl foo3 + .type foo3,@function +foo3: + bl foo_3 + +.ifdef __split_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/build-attributes/ba-aarch64-1-required-subsection-1.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-1.s new file mode 100644 index 00000000000..1d568990680 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-1.s @@ -0,0 +1,7 @@ +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_BTI, 1 +.aeabi_attribute Tag_Feature_PAC, 1 + +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute Tag_PAuth_Platform, 0x0 +.aeabi_attribute Tag_PAuth_Schema, 0x1 diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-2.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-2.s new file mode 100644 index 00000000000..9690634b0b1 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-2.s @@ -0,0 +1,7 @@ +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_BTI, 1 +.aeabi_attribute Tag_Feature_PAC, 0 + +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute Tag_PAuth_Platform, 0x0 +.aeabi_attribute Tag_PAuth_Schema, 0x1 diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-3.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-3.s new file mode 100644 index 00000000000..5ff1b8cb67b --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-3.s @@ -0,0 +1,7 @@ +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_BTI, 1 +.aeabi_attribute Tag_Feature_PAC, 1 + +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute Tag_PAuth_Platform, 0x0 +.aeabi_attribute Tag_PAuth_Schema, 0x0 diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-4.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-4.s new file mode 100644 index 00000000000..5ff1b8cb67b --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-4.s @@ -0,0 +1,7 @@ +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_BTI, 1 +.aeabi_attribute Tag_Feature_PAC, 1 + +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute Tag_PAuth_Platform, 0x0 +.aeabi_attribute Tag_PAuth_Schema, 0x0 diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-mismatch-1.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-mismatch-1.s new file mode 100644 index 00000000000..edaf78f398c --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-mismatch-1.s @@ -0,0 +1,7 @@ +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_BTI, 1 +.aeabi_attribute Tag_Feature_PAC, 1 + +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute Tag_PAuth_Platform, 0xdead +.aeabi_attribute Tag_PAuth_Schema, 0xbeef diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-mismatch-2.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-mismatch-2.s new file mode 100644 index 00000000000..dbbb30e0e54 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-mismatch-2.s @@ -0,0 +1,7 @@ +.aeabi_subsection aeabi_feature_and_bits, required, uleb128 +.aeabi_attribute Tag_Feature_BTI, 1 +.aeabi_attribute Tag_Feature_PAC, 1 + +.aeabi_subsection aeabi_pauthabi, optional, ntbs +.aeabi_attribute Tag_PAuth_Platform, "hello" +.aeabi_attribute Tag_PAuth_Schema, "world" diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-nok-1.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-nok-1.d new file mode 100644 index 00000000000..042b3642268 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-nok-1.d @@ -0,0 +1,10 @@ +# name: EABI build attributes: combine non-matching aeabi_pauthabi subsections +# source: ba-aarch64-1-required-subsection-1.s +# source: ba-aarch64-1-required-subsection-mismatch-1.s +# source: ba-aarch64-1-required-subsection-2.s +# as: +# ld: -shared +#error: \A[^\n]*ba-aarch64-1-required-subsection-mismatch-1\.o: error: mismatching value for required object attribute 'Tag_PAuth_Platform' in subsection 'aeabi_pauthabi': 0xdead +#error: \n[^\n]*ba-aarch64-1-required-subsection-1\.o: info: conflicting value '0' lives here +#error: \n[^\n]*ba-aarch64-1-required-subsection-mismatch-1\.o: error: mismatching value for required object attribute 'Tag_PAuth_Schema' in subsection 'aeabi_pauthabi': 0xbeef +#error: \n[^\n]*ba-aarch64-1-required-subsection-1\.o: info: conflicting value '0x1' lives here\Z diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-nok-2.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-nok-2.d new file mode 100644 index 00000000000..edf43b52c75 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-nok-2.d @@ -0,0 +1,9 @@ +# name: EABI build attributes: subsections have different properties from the expected ones +# source: ba-aarch64-1-required-subsection-1.s +# source: ba-aarch64-1-required-subsection-mismatch-2.s +# source: ba-aarch64-1-required-subsection-2.s +# as: +# ld: -shared +#error: \A[^\n]*ba-aarch64-1-required-subsection-mismatch-2\.o: error: property of subsection 'aeabi_feature_and_bits' was incorrectly set. Got 'required', expected 'optional' +#error: \n[^\n]*ba-aarch64-1-required-subsection-mismatch-2\.o: error: property of subsection 'aeabi_pauthabi' was incorrectly set\. Got 'NTBS', expected 'ULEB128' +#error: \n[^\n]*ba-aarch64-1-required-subsection-mismatch-2\.o: error: property of subsection 'aeabi_pauthabi' was incorrectly set\. Got 'optional', expected 'required'\Z diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-ok-1.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-ok-1.d new file mode 100644 index 00000000000..f9d3ba043c8 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-ok-1.d @@ -0,0 +1,25 @@ +# name: EABI build attributes: combine matching aeabi_pauthabi subsections, and (platform=0x0, schema=0x1) is accepted. +# source: ba-aarch64-1-required-subsection-1.s +# source: ba-aarch64-1-required-subsection-2.s +# as: +# ld: -shared +# readelf: --arch-specific + +Subsections: + - Name:[ ]+aeabi_feature_and_bits + Scope:[ ]+public + Length:[ ]+33 + Comprehension:[ ]+optional + Encoding:[ ]+ULEB128 + Values: + +Tag_Feature_BTI:[ ]+1 .* + +Tag_Feature_PAC:[ ]+0 .* + + - Name:[ ]+aeabi_pauthabi + Scope:[ ]+public + Length:[ ]+25 + Comprehension:[ ]+required + Encoding:[ ]+ULEB128 + Values: + +Tag_PAuth_Platform:[ ]+0 .* + +Tag_PAuth_Schema:[ ]+1 .* diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-ok-2.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-ok-2.d new file mode 100644 index 00000000000..cc551a26887 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-required-subsection-ok-2.d @@ -0,0 +1,25 @@ +# name: EABI build attributes: combine matching aeabi_pauthabi subsections, and (platform=0x0, schema=0x0) is accepted. +# source: ba-aarch64-1-required-subsection-3.s +# source: ba-aarch64-1-required-subsection-4.s +# as: +# ld: -shared +# readelf: --arch-specific + +Subsections: + - Name:[ ]+aeabi_feature_and_bits + Scope:[ ]+public + Length:[ ]+33 + Comprehension:[ ]+optional + Encoding:[ ]+ULEB128 + Values: + +Tag_Feature_BTI:[ ]+1 .* + +Tag_Feature_PAC:[ ]+1 .* + + - Name:[ ]+aeabi_pauthabi + Scope:[ ]+public + Length:[ ]+25 + Comprehension:[ ]+required + Encoding:[ ]+ULEB128 + Values: + +Tag_PAuth_Platform:[ ]+0 .* + +Tag_PAuth_Schema:[ ]+0 .* diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-unknown-tag.d b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-unknown-tag.d new file mode 100644 index 00000000000..8d352873002 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-unknown-tag.d @@ -0,0 +1,20 @@ +# name: EABI build attributes: some files missing Tag_Feature_BTI, but -z force-bti means that the output has Tag_Feature_BTI=0x1 +# source: ba-aarch64-1-bti-1.s +# source: ba-aarch64-1-unknown-tag.s +# source: ba-aarch64-1-bti-via-gnu-props.s +# source: ba-aarch64-1-bti-2.s +# as: -defsym __property_bti__=1 +# ld: -shared -T bti-plt.ld +#warning: \A[^\n]*ba-aarch64-1-unknown-tag\.o: warning: cannot merge unknown tag 'Tag_unknown_4' \(=0x1\) in subsection 'aeabi_feature_and_bits'\. +# readelf: --arch-specific + +Subsections: + - Name:[ ]+aeabi_feature_and_bits + Scope:[ ]+public + Length:[ ]+35 + Comprehension:[ ]+optional + Encoding:[ ]+ULEB128 + Values: + +Tag_Feature_BTI:[ ]+1 .* + +Tag_Feature_PAC:[ ]+0 .* + +Tag_Feature_GCS:[ ]+0 .* diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-unknown-tag.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-unknown-tag.s new file mode 100644 index 00000000000..7d4f172390d --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-unknown-tag.s @@ -0,0 +1,3 @@ +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_BTI, 1 +.aeabi_attribute 4, 1 diff --git a/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-void.s b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-void.s new file mode 100644 index 00000000000..4e1896ca8f9 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/ba-aarch64-1-void.s @@ -0,0 +1,5 @@ + .text + .globl foo1 + .type foo1,@function +foo1: + bl foo_1 diff --git a/ld/testsuite/ld-aarch64/build-attributes/bti-plt.ld b/ld/testsuite/ld-aarch64/build-attributes/bti-plt.ld new file mode 100644 index 00000000000..fffb8a98cd4 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/bti-plt.ld @@ -0,0 +1,27 @@ +OUTPUT_ARCH(aarch64) +ENTRY(_start) +SECTIONS +{ + PROVIDE(__executable_start = 0x8000); + . = SEGMENT_START("text-segment", 0x8000) + SIZEOF_HEADERS; + /* Start of the executable code region. */ + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + . = 0x10000; + .rela.dyn : { *(.rela.ifunc) } + .rela.plt : { *(.rela.plt) *(.rela.iplt) } + . = 0x18000; + .plt : { *(.plt) *(.iplt) } + . = 0x20000; + .text : { *(.text) } + /* Start of the Read Only Data region. */ + .note.gnu.property : { *(.note.gnu.property) } + + /* Start of the Read Write Data region. */ + . = ALIGN (CONSTANT (MAXPAGESIZE)); + .got : { *(.got) *(.got.plt) } + /* Start of the metadata region. */ + .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) } +} diff --git a/ld/testsuite/ld-aarch64/build-attributes/gnu-note-properties-maskable-merged.inc b/ld/testsuite/ld-aarch64/build-attributes/gnu-note-properties-maskable-merged.inc new file mode 100644 index 00000000000..ea3dd7f0513 --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/gnu-note-properties-maskable-merged.inc @@ -0,0 +1,32 @@ + .set NT_GNU_PROPERTY_TYPE_0, 5 + .set GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc0000000 + .set GNU_PROPERTY_AARCH64_FEATURE_1_BTI, (0x1 << 0) + .set GNU_PROPERTY_AARCH64_FEATURE_1_PAC, (0x1 << 1) + .set GNU_PROPERTY_AARCH64_FEATURE_1_GCS, (0x1 << 2) + .set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, 0x0 +.ifndef __mask_property_bti__ + .set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_BTI ) +.endif +.ifndef __mask_property_pac__ + .set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_PAC ) +.endif +.ifndef __mask_property_gcs__ + .set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_GCS ) +.endif +.if GNU_PROPERTY_AARCH64_FEATURE_1_VALUE + .section ".note.gnu.property", "a" + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long NT_GNU_PROPERTY_TYPE_0 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long GNU_PROPERTY_AARCH64_FEATURE_1_AND /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: + .long GNU_PROPERTY_AARCH64_FEATURE_1_VALUE +4: + .p2align 3 +5: +.endif diff --git a/ld/testsuite/ld-aarch64/build-attributes/gnu-note-properties-maskable-split.inc b/ld/testsuite/ld-aarch64/build-attributes/gnu-note-properties-maskable-split.inc new file mode 100644 index 00000000000..fdbe9706fce --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/gnu-note-properties-maskable-split.inc @@ -0,0 +1,72 @@ + .set NT_GNU_PROPERTY_TYPE_0, 5 + .set GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc0000000 + .set GNU_PROPERTY_AARCH64_FEATURE_1_BTI, (0x1 << 0) + .set GNU_PROPERTY_AARCH64_FEATURE_1_PAC, (0x1 << 1) + .set GNU_PROPERTY_AARCH64_FEATURE_1_GCS, (0x1 << 2) + + .set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, 0x0 +.ifndef __mask_property_bti__ + .set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_BTI ) +.endif +.ifndef __mask_property_pac__ + .set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_PAC ) +.endif +.ifndef __mask_property_gcs__ + .set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_GCS ) +.endif + +.if GNU_PROPERTY_AARCH64_FEATURE_1_VALUE + .section ".note.gnu.property", "a" + +.ifndef __mask_property_bti__ + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long NT_GNU_PROPERTY_TYPE_0 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long GNU_PROPERTY_AARCH64_FEATURE_1_AND /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: + .long GNU_PROPERTY_AARCH64_FEATURE_1_BTI +4: + .p2align 3 +5: +.endif + +.ifndef __mask_property_pac__ + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long NT_GNU_PROPERTY_TYPE_0 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long GNU_PROPERTY_AARCH64_FEATURE_1_AND /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: + .long GNU_PROPERTY_AARCH64_FEATURE_1_PAC +4: + .p2align 3 +5: +.endif + +.ifndef __mask_property_gcs__ + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long NT_GNU_PROPERTY_TYPE_0 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long GNU_PROPERTY_AARCH64_FEATURE_1_AND /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: + .long GNU_PROPERTY_AARCH64_FEATURE_1_GCS +4: + .p2align 3 +5: +.endif + +.endif diff --git a/ld/testsuite/ld-aarch64/build-attributes/gnu-note-properties-selectable-merged.inc b/ld/testsuite/ld-aarch64/build-attributes/gnu-note-properties-selectable-merged.inc new file mode 100644 index 00000000000..783dde0c28c --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/gnu-note-properties-selectable-merged.inc @@ -0,0 +1,32 @@ + .set NT_GNU_PROPERTY_TYPE_0, 5 + .set GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc0000000 + .set GNU_PROPERTY_AARCH64_FEATURE_1_BTI, (0x1 << 0) + .set GNU_PROPERTY_AARCH64_FEATURE_1_PAC, (0x1 << 1) + .set GNU_PROPERTY_AARCH64_FEATURE_1_GCS, (0x1 << 2) + .set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, 0x0 +.ifdef __property_bti__ + .set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_BTI ) +.endif +.ifdef __property_pac__ + .set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_PAC ) +.endif +.ifdef __property_gcs__ + .set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_GCS ) +.endif +.if GNU_PROPERTY_AARCH64_FEATURE_1_VALUE + .section ".note.gnu.property", "a" + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long NT_GNU_PROPERTY_TYPE_0 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long GNU_PROPERTY_AARCH64_FEATURE_1_AND /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: + .long GNU_PROPERTY_AARCH64_FEATURE_1_VALUE +4: + .p2align 3 +5: +.endif diff --git a/ld/testsuite/ld-aarch64/build-attributes/gnu-note-properties-selectable-split.inc b/ld/testsuite/ld-aarch64/build-attributes/gnu-note-properties-selectable-split.inc new file mode 100644 index 00000000000..a171471990a --- /dev/null +++ b/ld/testsuite/ld-aarch64/build-attributes/gnu-note-properties-selectable-split.inc @@ -0,0 +1,72 @@ + .set NT_GNU_PROPERTY_TYPE_0, 5 + .set GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc0000000 + .set GNU_PROPERTY_AARCH64_FEATURE_1_BTI, (0x1 << 0) + .set GNU_PROPERTY_AARCH64_FEATURE_1_PAC, (0x1 << 1) + .set GNU_PROPERTY_AARCH64_FEATURE_1_GCS, (0x1 << 2) + + .set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, 0x0 +.ifndef __mask_property_bti__ + .set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_BTI ) +.endif +.ifndef __mask_property_pac__ + .set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_PAC ) +.endif +.ifndef __mask_property_gcs__ + .set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_GCS ) +.endif + +.if GNU_PROPERTY_AARCH64_FEATURE_1_VALUE + .section ".note.gnu.property", "a" + +.ifdef __property_bti__ + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long NT_GNU_PROPERTY_TYPE_0 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long GNU_PROPERTY_AARCH64_FEATURE_1_AND /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: + .long GNU_PROPERTY_AARCH64_FEATURE_1_BTI +4: + .p2align 3 +5: +.endif + +.ifdef __property_pac__ + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long NT_GNU_PROPERTY_TYPE_0 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long GNU_PROPERTY_AARCH64_FEATURE_1_AND /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: + .long GNU_PROPERTY_AARCH64_FEATURE_1_PAC +4: + .p2align 3 +5: +.endif + +.ifdef __property_gcs__ + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long NT_GNU_PROPERTY_TYPE_0 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long GNU_PROPERTY_AARCH64_FEATURE_1_AND /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: + .long GNU_PROPERTY_AARCH64_FEATURE_1_GCS +4: + .p2align 3 +5: +.endif + +.endif