public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] ld: aarch64: Add BTI stub insertion test PR30930
@ 2023-11-09 14:59 Szabolcs Nagy
  0 siblings, 0 replies; only message in thread
From: Szabolcs Nagy @ 2023-11-09 14:59 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b418c9d49ece5d503eea35a3ff994e55326da6f9

commit b418c9d49ece5d503eea35a3ff994e55326da6f9
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Tue Oct 24 16:24:22 2023 +0100

    ld: aarch64: Add BTI stub insertion test PR30930
    
    The test creates a large shared library and covers a number of
    BTI stub insertion cases.

Diff:
---
 ld/testsuite/ld-aarch64/aarch64-elf.exp |  1 +
 ld/testsuite/ld-aarch64/bti-far-3.d     | 87 +++++++++++++++++++++++++++++++++
 ld/testsuite/ld-aarch64/bti-far-3.ld    | 12 +++++
 ld/testsuite/ld-aarch64/bti-far-3a.s    | 23 +++++++++
 ld/testsuite/ld-aarch64/bti-far-3b.s    | 25 ++++++++++
 ld/testsuite/ld-aarch64/bti-far-3c.s    | 24 +++++++++
 6 files changed, 172 insertions(+)

diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
index b025fcbd567..fa5ac3a2cdd 100644
--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
+++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
@@ -466,6 +466,7 @@ run_dump_test "undef-tls"
 run_dump_test "bti-far-1"
 run_dump_test "bti-far-2"
 run_dump_test "bti-far-opt"
+run_dump_test "bti-far-3"
 
 if { ![skip_sframe_tests] } {
   run_dump_test "sframe-simple-1"
diff --git a/ld/testsuite/ld-aarch64/bti-far-3.d b/ld/testsuite/ld-aarch64/bti-far-3.d
new file mode 100644
index 00000000000..1410b1389b2
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/bti-far-3.d
@@ -0,0 +1,87 @@
+#name: Check indirect call stub to BTI stub relaxation.
+#source: bti-far-3a.s
+#source: bti-far-3b.s
+#source: bti-far-3c.s
+#as: -mabi=lp64
+#ld: -shared -T bti-far-3.ld
+#objdump: -dr
+
+[^:]*: *file format elf64-.*aarch64
+
+
+Disassembly of section \.plt:
+
+0000000000020000 <\.plt>:
+   20000:	d503245f 	bti	c
+   20004:	a9bf7bf0 	stp	x16, x30, \[sp, #-16\]!
+   20008:	900fff10 	adrp	x16, 20000000 <_GLOBAL_OFFSET_TABLE_>
+   2000c:	f9400e11 	ldr	x17, \[x16, #24\]
+   20010:	91006210 	add	x16, x16, #0x18
+   20014:	d61f0220 	br	x17
+   20018:	d503201f 	nop
+   2001c:	d503201f 	nop
+
+0000000000020020 <extern_func@plt>:
+   20020:	900fff10 	adrp	x16, 20000000 <_GLOBAL_OFFSET_TABLE_>
+   20024:	f9401211 	ldr	x17, \[x16, #32\]
+   20028:	91008210 	add	x16, x16, #0x20
+   2002c:	d61f0220 	br	x17
+   20030:	14000004 	b	20040 <__extern_func_bti_veneer\+0x8>
+   20034:	d503201f 	nop
+
+0000000000020038 <__extern_func_bti_veneer>:
+   20038:	d503245f 	bti	c
+   2003c:	17fffff9 	b	20020 <extern_func@plt>
+
+Disassembly of section \.text:
+
+0000000000030000 <a_func>:
+       30000:	15c00004 	b	7030010 <__b_func_veneer>
+       30004:	17ffc007 	b	20020 <extern_func@plt>
+	\.\.\.
+     7030008:	1400000a 	b	7030030 <__a_func_bti_veneer\+0x8>
+     703000c:	d503201f 	nop
+
+0000000007030010 <__b_func_veneer>:
+     7030010:	90040010 	adrp	x16, f030000 <b_func\+0x6ffffd0>
+     7030014:	9101e210 	add	x16, x16, #0x78
+     7030018:	d61f0200 	br	x16
+	\.\.\.
+
+0000000007030028 <__a_func_bti_veneer>:
+     7030028:	d503245f 	bti	c
+     703002c:	163ffff5 	b	30000 <a_func>
+	\.\.\.
+
+0000000008030030 <b_func>:
+     8030030:	15c00004 	b	f030040 <__c_func_veneer>
+     8030034:	15c00005 	b	f030048 <__a_func_veneer>
+	\.\.\.
+     f030038:	14000012 	b	f030080 <__b_func_bti_veneer\+0x8>
+     f03003c:	d503201f 	nop
+
+000000000f030040 <__c_func_veneer>:
+     f030040:	d503245f 	bti	c
+     f030044:	1440000f 	b	10030080 <c_func>
+
+000000000f030048 <__a_func_veneer>:
+     f030048:	90fc0010 	adrp	x16, 7030000 <a_func\+0x7000000>
+     f03004c:	9100a210 	add	x16, x16, #0x28
+     f030050:	d61f0200 	br	x16
+	\.\.\.
+
+000000000f030060 <__extern_func_veneer>:
+     f030060:	90f87f90 	adrp	x16, 20000 <\.plt>
+     f030064:	9100e210 	add	x16, x16, #0x38
+     f030068:	d61f0200 	br	x16
+	\.\.\.
+
+000000000f030078 <__b_func_bti_veneer>:
+     f030078:	d503245f 	bti	c
+     f03007c:	163fffed 	b	8030030 <b_func>
+	\.\.\.
+
+0000000010030080 <c_func>:
+    10030080:	17bffff2 	b	f030048 <__a_func_veneer>
+    10030084:	17bffffd 	b	f030078 <__b_func_bti_veneer>
+    10030088:	17bffff6 	b	f030060 <__extern_func_veneer>
diff --git a/ld/testsuite/ld-aarch64/bti-far-3.ld b/ld/testsuite/ld-aarch64/bti-far-3.ld
new file mode 100644
index 00000000000..3265c55b8cc
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/bti-far-3.ld
@@ -0,0 +1,12 @@
+OUTPUT_ARCH(aarch64)
+SECTIONS
+{
+  . = 0x00010000;
+  .rela.plt       : { *(.rela.plt) *(.rela.iplt) }
+  . = 0x00020000;
+  .plt            : { *(.plt) *(.iplt) }
+  . = 0x00030000;
+  .text           : { *(.text) }
+  . = 0x20000000;
+  .got            : { *(.got) *(.got.plt) }
+}
diff --git a/ld/testsuite/ld-aarch64/bti-far-3a.s b/ld/testsuite/ld-aarch64/bti-far-3a.s
new file mode 100644
index 00000000000..ed53545fed7
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/bti-far-3a.s
@@ -0,0 +1,23 @@
+	.text
+	.hidden	a_func
+	.hidden	b_func
+	.hidden	c_func
+
+	.global	a_func
+	.type	a_func, %function
+a_func:
+	b	b_func
+	b	extern_func
+
+.zero	0x07000000
+
+	.section	.note.gnu.property,"a"
+	.align	3
+	.word	4
+	.word	16
+	.word	5
+	.string	"GNU"
+	.word	3221225472
+	.word	4
+	.word	1
+	.align	3
diff --git a/ld/testsuite/ld-aarch64/bti-far-3b.s b/ld/testsuite/ld-aarch64/bti-far-3b.s
new file mode 100644
index 00000000000..1f3be3d15cf
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/bti-far-3b.s
@@ -0,0 +1,25 @@
+	.text
+	.hidden	a_func
+	.hidden	b_func
+	.hidden	c_func
+
+.zero	0x01000000
+
+	.global	b_func
+	.type	b_func, %function
+b_func:
+	b	c_func
+	b	a_func
+
+.zero	0x07000000
+
+	.section	.note.gnu.property,"a"
+	.align	3
+	.word	4
+	.word	16
+	.word	5
+	.string	"GNU"
+	.word	3221225472
+	.word	4
+	.word	1
+	.align	3
diff --git a/ld/testsuite/ld-aarch64/bti-far-3c.s b/ld/testsuite/ld-aarch64/bti-far-3c.s
new file mode 100644
index 00000000000..8e2361fd771
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/bti-far-3c.s
@@ -0,0 +1,24 @@
+	.text
+	.hidden	a_func
+	.hidden	b_func
+	.hidden	c_func
+
+.zero	0x01000000
+
+	.global	c_func
+	.type	c_func, %function
+c_func:
+	b	a_func
+	b	b_func
+	b	extern_func
+
+	.section	.note.gnu.property,"a"
+	.align	3
+	.word	4
+	.word	16
+	.word	5
+	.string	"GNU"
+	.word	3221225472
+	.word	4
+	.word	1
+	.align	3

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-09 14:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-09 14:59 [binutils-gdb] ld: aarch64: Add BTI stub insertion test PR30930 Szabolcs Nagy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).