From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 6C866385772D; Thu, 9 Nov 2023 14:59:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C866385772D Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Szabolcs Nagy To: bfd-cvs@sourceware.org Subject: [binutils-gdb] ld: aarch64: Add BTI stub insertion test PR30930 X-Act-Checkin: binutils-gdb X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/master X-Git-Oldrev: fc48504c7abe8eb9d9723632b2d53504927f46ff X-Git-Newrev: b418c9d49ece5d503eea35a3ff994e55326da6f9 Message-Id: <20231109145945.6C866385772D@sourceware.org> Date: Thu, 9 Nov 2023 14:59:45 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Nov 2023 14:59:45 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db418c9d49ece= 5d503eea35a3ff994e55326da6f9 commit b418c9d49ece5d503eea35a3ff994e55326da6f9 Author: Szabolcs Nagy Date: Tue Oct 24 16:24:22 2023 +0100 ld: aarch64: Add BTI stub insertion test PR30930 =20 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-aarc= h64/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" =20 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=3Dlp64 +#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 : + 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 + +Disassembly of section \.text: + +0000000000030000 : + 30000: 15c00004 b 7030010 <__b_func_veneer> + 30004: 17ffc007 b 20020 + \.\.\. + 7030008: 1400000a b 7030030 <__a_func_bti_veneer\+0x8> + 703000c: d503201f nop + +0000000007030010 <__b_func_veneer>: + 7030010: 90040010 adrp x16, f030000 + 7030014: 9101e210 add x16, x16, #0x78 + 7030018: d61f0200 br x16 + \.\.\. + +0000000007030028 <__a_func_bti_veneer>: + 7030028: d503245f bti c + 703002c: 163ffff5 b 30000 + \.\.\. + +0000000008030030 : + 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 + +000000000f030048 <__a_func_veneer>: + f030048: 90fc0010 adrp x16, 7030000 + 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 + \.\.\. + +0000000010030080 : + 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 +{ + . =3D 0x00010000; + .rela.plt : { *(.rela.plt) *(.rela.iplt) } + . =3D 0x00020000; + .plt : { *(.plt) *(.iplt) } + . =3D 0x00030000; + .text : { *(.text) } + . =3D 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