[PATCH v2 2/2] aarch64: ld: add tests for combination of bti and memory-seal

Matthieu Longo matthieu.longo@arm.com
Wed Apr 2 09:16:24 GMT 2025


On 2025-04-01 16:06, Yury Khrustalev wrote:
> ---
>   .../ld-aarch64/protections/bti-plt-1-b.d      |  2 +-
>   .../ld-aarch64/protections/bti-plt-1-d.d      | 32 +++++++++++++++++++
>   .../ld-aarch64/protections/bti-plt-2-d.d      | 14 ++++++++
>   3 files changed, 47 insertions(+), 1 deletion(-)
>   create mode 100644 ld/testsuite/ld-aarch64/protections/bti-plt-1-d.d
>   create mode 100644 ld/testsuite/ld-aarch64/protections/bti-plt-2-d.d
> 
> diff --git a/ld/testsuite/ld-aarch64/protections/bti-plt-1-b.d b/ld/testsuite/ld-aarch64/protections/bti-plt-1-b.d
> index 1bf956ca19f..4b0e424f77e 100644
> --- a/ld/testsuite/ld-aarch64/protections/bti-plt-1-b.d
> +++ b/ld/testsuite/ld-aarch64/protections/bti-plt-1-b.d
> @@ -2,7 +2,7 @@
>   #source: bti-plt-1.s
>   #target: [check_shared_lib_support]
>   #as: -mabi=lp64 -defsym __property_bti__=1
> -#ld: -shared -z force-bti -T bti-plt.ld -L./tmpdir -lbti-plt-so
> +#ld: -shared -T bti-plt.ld -L./tmpdir -lbti-plt-so

Is it a mistake ?
Why was this test modified ?

>   #objdump: -dr -j .plt
>   
>   [^:]*: *file format elf64-.*aarch64
> diff --git a/ld/testsuite/ld-aarch64/protections/bti-plt-1-d.d b/ld/testsuite/ld-aarch64/protections/bti-plt-1-d.d
> new file mode 100644
> index 00000000000..d1d46b6c98b
> --- /dev/null
> +++ b/ld/testsuite/ld-aarch64/protections/bti-plt-1-d.d

I would recommend to change the test name to something different to 
reflect that it does something related with memory-seal.

bti-plt-and-memory-seal-1.d ?

> @@ -0,0 +1,32 @@
> +#name: No '-z force-bti' with '-z memory-seal' with feature properties (BTI) forces the generation of BTI PLT (shared)
> +#source: bti-plt-1.s

Did you forget source: bti-plt-2.s ?
We want the readelf test to be the same as the objdump one.

> +#target: [check_shared_lib_support]
> +#as: -mabi=lp64 -defsym __property_bti__=1
> +#ld: -shared -z memory-seal -T bti-plt.ld -L./tmpdir -lbti-plt-so
> +#objdump: -dr -j .plt
> +
> +[^:]*: *file format elf64-.*aarch64
> +
> +Disassembly of section \.plt:
> +
> +[0-9]+ <\.plt>:
> +.*:	d503245f 	bti	c
> +.*:	a9bf7bf0 	stp	x16, x30, \[sp, #-16\]!
> +.*:	90000090 	adrp	x16, 28000 <_GLOBAL_OFFSET_TABLE_>
> +.*:	f9400e11 	ldr	x17, \[x16, #24\]
> +.*:	91006210 	add	x16, x16, #0x18
> +.*:	d61f0220 	br	x17
> +.*:	d503201f 	nop
> +.*:	d503201f 	nop
> +
> +[0-9]+ <.*>:
> +.*:	90000090 	adrp	x16, 28000 <_GLOBAL_OFFSET_TABLE_>
> +.*:	f9401211 	ldr	x17, \[x16, #32\]
> +.*:	91008210 	add	x16, x16, #0x20
> +.*:	d61f0220 	br	x17
> +
> +[0-9]+ <.*>:
> +.*:	90000090 	adrp	x16, 28000 <_GLOBAL_OFFSET_TABLE_>
> +.*:	f9401611 	ldr	x17, \[x16, #40\]
> +.*:	9100a210 	add	x16, x16, #0x28
> +.*:	d61f0220 	br	x17
> diff --git a/ld/testsuite/ld-aarch64/protections/bti-plt-2-d.d b/ld/testsuite/ld-aarch64/protections/bti-plt-2-d.d
> new file mode 100644
> index 00000000000..0dadcc9da5c
> --- /dev/null
> +++ b/ld/testsuite/ld-aarch64/protections/bti-plt-2-d.d

Same comment as before here.
bti-plt-and-memory-seal-2.d ?

> @@ -0,0 +1,14 @@
> +#name: No '-z force-bti' with '-z memory-seal' all input objects have BTI emits BTI feature (shared)
> +#source: bti-plt-1.s
> +#source: bti-plt-2.s
> +#target: [check_shared_lib_support]
> +#as: -mabi=lp64 -defsym __property_bti__=1
> +#ld: -z memory-seal -shared -T bti-plt.ld
> +#readelf: -n
> +
> +Displaying notes found in: .note.gnu.property
> +[ 	]+Owner[ 	]+Data size[ 	]+Description
> +  GNU                  0x00000018	NT_GNU_PROPERTY_TYPE_0
> +      Properties: memory seal\s
> +\s+AArch64 feature: BTI
> +#pass



More information about the Binutils mailing list