From patchwork Tue Mar 21 14:28:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 72905 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1811758wrt; Tue, 21 Mar 2023 07:30:49 -0700 (PDT) X-Google-Smtp-Source: AK7set+MJrg0H2LC92C6HNpzPKe87+TQQSjvqxgsp/FY/q3oM/Y5pmmD75T5p2bhbeiLUBMFCEvy X-Received: by 2002:a17:906:7185:b0:931:c077:2b63 with SMTP id h5-20020a170906718500b00931c0772b63mr11891416ejk.17.1679409048896; Tue, 21 Mar 2023 07:30:48 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id g19-20020aa7c593000000b004fd25330f52si13790722edq.117.2023.03.21.07.30.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 07:30:48 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=goj8gc9T; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5890F3851ABE for ; Tue, 21 Mar 2023 14:30:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5890F3851ABE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679409024; bh=24F/adFXKwa75gSrik5MGZX1R10+RaGDsi5g5aBkVag=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=goj8gc9TBQycbFWwU4Qc26yrU7Rx+3TK5pGStS/1GDDJsvvs/xJxghULhPcDYjBnc HeLsVbPx5Qt6PwdHdGgXe5KzJzbsp83Lqgm14apktCDfKb6qs0C3k1qje5Fm3Rua+V Xa2HIeR0BYuyGsOVY0yqZm7PBS1JOzvbCrUkIDSw= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2061a.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe1a::61a]) by sourceware.org (Postfix) with ESMTPS id A7723385842C for ; Tue, 21 Mar 2023 14:29:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A7723385842C Received: from AS9PR06CA0092.eurprd06.prod.outlook.com (2603:10a6:20b:465::10) by DB9PR08MB7843.eurprd08.prod.outlook.com (2603:10a6:10:39e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Tue, 21 Mar 2023 14:29:06 +0000 Received: from AM7EUR03FT033.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:465:cafe::98) by AS9PR06CA0092.outlook.office365.com (2603:10a6:20b:465::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37 via Frontend Transport; Tue, 21 Mar 2023 14:29:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT033.mail.protection.outlook.com (100.127.140.129) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.16 via Frontend Transport; Tue, 21 Mar 2023 14:29:06 +0000 Received: ("Tessian outbound cfb430c87a1e:v135"); Tue, 21 Mar 2023 14:29:06 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 31e43d86ee53ec3d X-CR-MTA-TID: 64aa7808 Received: from baf637a4ead5.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 554360A5-9702-4BA4-98D7-012F087216AE.1; Tue, 21 Mar 2023 14:29:00 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id baf637a4ead5.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 21 Mar 2023 14:29:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vq/tZaXxgCW0PUfmdK5qO73zEde3se8yD7JV4212+tSL/BH4ZfrE6HKZ37OYsm/ByCjH3XA2LO/9szngKn9N4+a5A1qQES5PW36OJpGNGs0gJRcR07Jn6SeAofVHl8DZ9jbURZvbmwP7LRGHBXlJWIga2GEDVVY1Qvo2eb5N2ZBuCNzyrN0awiP8GD+9yqH/nWp8l61MK3REbETWSRo9l0eLCcC8X0U4SNPtAweb+EOfLyW3M8aUrRDU8lGm7Km5ZLREsxkkMCUf7b0SmbDmhigITVn3XHD3nD/lOgsmkL6crPtc1Cu86pLnbpPTYWreV76NCOJOWeGDF0L6Kf6PpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=24F/adFXKwa75gSrik5MGZX1R10+RaGDsi5g5aBkVag=; b=MaBP82TyDkHHHPNC4QqhfXiMzQqJ+ctLzJ/3wXenz5ZdW3KCx/gUncIK/2gVEQR3qHnc3YQidF1gCh8fqHytryepu/U2g5YaByNeRVcJxy3/LGjQnLKPmMe0+qbl0MZj2BSdnjIvCWbTzQMzYhIeqSsQ50OMHxGOuB4sY95QNuaQU+W31xdRS0JdRFUK/LQIjqta2gB3jL8mZL0YjBuS+8r64EKjpADITcplygCXKGNYR5ImvYXULT/4TVVHuXCrJPkcHK17tr8+8eqUhCd108eGIDR4+kHhe3pRvegi3QOblQkGRWeb6tHJ6bCrMtuFLb0alBNn4zaYDdOsuVAdMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none Received: from DUZPR01CA0141.eurprd01.prod.exchangelabs.com (2603:10a6:10:4bd::28) by AM7PR08MB5527.eurprd08.prod.outlook.com (2603:10a6:20b:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Tue, 21 Mar 2023 14:28:58 +0000 Received: from DBAEUR03FT038.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4bd:cafe::ea) by DUZPR01CA0141.outlook.office365.com (2603:10a6:10:4bd::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37 via Frontend Transport; Tue, 21 Mar 2023 14:28:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT038.mail.protection.outlook.com (100.127.143.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6222.17 via Frontend Transport; Tue, 21 Mar 2023 14:28:58 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Tue, 21 Mar 2023 14:28:57 +0000 Received: from armchair.cambridge.arm.com (10.2.80.71) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.17 via Frontend Transport; Tue, 21 Mar 2023 14:28:57 +0000 To: Subject: [PATCH 3/3] bfd: aarch64: Optimize BTI stubs PR30076 Date: Tue, 21 Mar 2023 14:28:57 +0000 Message-ID: <20230321142857.672520-1-szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT038:EE_|AM7PR08MB5527:EE_|AM7EUR03FT033:EE_|DB9PR08MB7843:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ff7aca4-5e4c-4e44-d4bf-08db2a18a0b7 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Vy9UC9ANEsWxEEk+H0/SA83jFhNG3jnxHnnccGkSPluyyg+hgYAu3YKJ/wMUNrp60LIswZzRlcuGfNB6rRhoNVRJmc+nNiOFoWmUnc1ECRL+TgFSoConq3GSt45taz2u4UC16Ldttt+G6ibnGzNZMx+/OmDGVjNobsMiPAZYSdRLjWXAlzcqv5y2xwifYsp56IdTfhZkNZu9wlRWi36e+P0kwlKgJxMnt/14HJvBWiPYgQ1J6Lv1G+8eHOhmfmU+o4RvrrnlhJ/PXmZx5NH3Mde+kJCfLR+/Ey8iz2eCBgNa8i6OOxqkXiEFBRd3xP5FFOKQBf+QtVakB2+PYqfYJXHqZ5Y6hGkdl/k7i+udtwAnOpWnj8oXXe15o6EFarNteHgzC6VHS3/FXzAcm2hZRiwpkTPp60/dPwFVHiRLP/7Y0Xz9uT3L9rokUfE9PxZkGzWDYsyYMNsWwKQe/XpMcnGb4jDauPP2Xt0Kx0q4QH+XMxvTbboHOvPS1KJOhAePBzl4PaDR7vRY4D6WGBcqkN9emHf7GiWAwioKkWXqYhLVriFTK9mq/mWFlgB0RdU9L1fh9hGjFgNhuDK56N3erUHbbe+Df3hc55qCUqb0JG+zQAU4U/QNH5KZe8BI46gfTxBhZFfxPTd5C+Z9YYZlTpRZQc2HbC5ExW7ur6nMr+t4gAn+U8zocUJT5Ltbovodx6xEnS6mrg427k06kGqk7w== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230025)(4636009)(39850400004)(136003)(376002)(346002)(396003)(451199018)(36840700001)(46966006)(356005)(70586007)(70206006)(6916009)(8676002)(82310400005)(316002)(41300700001)(2906002)(186003)(26005)(8936002)(2616005)(81166007)(426003)(7696005)(336012)(82740400003)(83380400001)(40480700001)(86362001)(5660300002)(1076003)(478600001)(36860700001)(44832011)(47076005)(36756003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5527 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 26bb611d-f6f1-49e9-b6ec-08db2a189ba4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MXn3lUxkhWlhXqhDddHYI7Hk76zasB6TjKXrXe22dJIWedjR8TOpeb0iuB4cHG/nkNjoOQN1nsEj2+DXLVk9s1aUfEcTG88dzK/DL+LNex1GXXZqydYhFNruwsIek5q1sn4bLlSLLdAgWKX+24HwUPWmLn8GASHuhWZfEMxZbMpzaLv0m7s9lAorEr88b2ZwnROI1hk6y71+DUU9JyOX8yby0quh4Ska8o+2Vjf8NcrovcvlSCsMbV9Emni1vD7mabUaw/nfu2pqZ6ctHgykKjSbEtQ30uamg5I7PKG4Bbi+at8ZB0TAV7GpKZwcg1FIhlX5S2o/f/HD1HIdbQ+pZQVZYCbzvPwAPK1KfRhy4Iz3QRBzRPnxt9ae1RG6cD/tCt9zd8TJ8DC4tztch7FbQgF5OdlbgOvQU0OYl3VkxS8oqh3kj/yLZK/pRRMJBIJxtOpNaeULWI86ezyFTQvrmwbD+QyvjNGiZBPlmtN2vdPPYaFFbKIzhyJMV7S131BQhTb3qYyP6Mj/VaYL7wLe4Ksv/N9MTGnmZboMg3EmVM6Pm9civHQU64EaORYe8HZusaj/RuapbFpq0T4qOLRp2G8x8QhZUr0kQCs5CohP3c0HWQK2N7MpZjJNc+y4NDZ5hPk9BzMoWVCw9h9RBe7/nM1we2aqaB+g++PRTJnIhzipoC+0KwPwp/0yagtn1r0u+Fs3g7p0D6NNV8W2pTiL0Q== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230025)(4636009)(346002)(396003)(376002)(39860400002)(136003)(451199018)(46966006)(40470700004)(36840700001)(82310400005)(83380400001)(2616005)(316002)(426003)(47076005)(478600001)(86362001)(44832011)(8936002)(70206006)(36860700001)(81166007)(40460700003)(6916009)(40480700001)(82740400003)(70586007)(41300700001)(8676002)(36756003)(5660300002)(2906002)(1076003)(26005)(7696005)(186003)(336012); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2023 14:29:06.6259 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ff7aca4-5e4c-4e44-d4bf-08db2a18a0b7 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7843 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_DMARC_NONE, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_NONE, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Binutils From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760988022999318249?= X-GMAIL-MSGID: =?utf-8?q?1760988022999318249?= Don't insert a second stub if the target is already compatible with an indirect branch. --- bfd/elfnn-aarch64.c | 36 +++++- ld/testsuite/ld-aarch64/aarch64-elf.exp | 1 + ld/testsuite/ld-aarch64/bti-far-opt.d | 153 ++++++++++++++++++++++++ ld/testsuite/ld-aarch64/bti-far-opt.s | 53 ++++++++ 4 files changed, 239 insertions(+), 4 deletions(-) create mode 100644 ld/testsuite/ld-aarch64/bti-far-opt.d create mode 100644 ld/testsuite/ld-aarch64/bti-far-opt.s diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index d9ebeae922c..c321ceb382e 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -3670,14 +3670,42 @@ group_sections (struct elf_aarch64_link_hash_table *htab, #undef PREV_SEC #undef PREV_SEC +#define AARCH64_HINT(insn) (((insn) & 0xfffff01f) == 0xd503201f) +#define AARCH64_PACIASP 0xd503233f +#define AARCH64_PACIBSP 0xd503237f +#define AARCH64_BTI_C 0xd503245f +#define AARCH64_BTI_J 0xd503249f +#define AARCH64_BTI_JC 0xd50324df + /* True if the inserted stub does not break BTI compatibility. */ static bool -aarch64_bti_stub_p (struct elf_aarch64_stub_hash_entry *stub_entry) +aarch64_bti_stub_p (bfd *input_bfd, + struct elf_aarch64_stub_hash_entry *stub_entry) { /* Stubs without indirect branch are BTI compatible. */ - return stub_entry->stub_type != aarch64_stub_adrp_branch - && stub_entry->stub_type != aarch64_stub_long_branch; + if (stub_entry->stub_type != aarch64_stub_adrp_branch + && stub_entry->stub_type != aarch64_stub_long_branch) + return true; + + /* Return true if the target instruction is compatible with BR x16. */ + + asection *section = stub_entry->target_section; + bfd_byte loc[4]; + file_ptr off = stub_entry->target_value; + bfd_size_type count = sizeof (loc); + + if (!bfd_get_section_contents (input_bfd, section, loc, off, count)) + return false; + + uint32_t insn = bfd_getl32 (loc); + if (!AARCH64_HINT (insn)) + return false; + return insn == AARCH64_BTI_C + || insn == AARCH64_PACIASP + || insn == AARCH64_BTI_JC + || insn == AARCH64_BTI_J + || insn == AARCH64_PACIBSP; } #define AARCH64_BITS(x, pos, n) (((x) >> (pos)) & ((1 << (n)) - 1)) @@ -4614,7 +4642,7 @@ _bfd_aarch64_add_call_stub_entries (bool *stub_changed, bfd *output_bfd, /* A stub with indirect jump may break BTI compatibility, so insert another stub with direct jump near the target then. */ - if (need_bti && !aarch64_bti_stub_p (stub_entry)) + if (need_bti && !aarch64_bti_stub_p (input_bfd, stub_entry)) { stub_entry->double_stub = true; htab->has_double_stub = true; diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp index 80662de7e44..ec55bf49931 100644 --- a/ld/testsuite/ld-aarch64/aarch64-elf.exp +++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp @@ -463,6 +463,7 @@ run_dump_test "undef-tls" run_dump_test "bti-far-1" run_dump_test "bti-far-2" +run_dump_test "bti-far-opt" if { ![skip_sframe_tests] } { run_dump_test "sframe-simple-1" diff --git a/ld/testsuite/ld-aarch64/bti-far-opt.d b/ld/testsuite/ld-aarch64/bti-far-opt.d new file mode 100644 index 00000000000..ff20d0c2825 --- /dev/null +++ b/ld/testsuite/ld-aarch64/bti-far-opt.d @@ -0,0 +1,153 @@ +#name: Check linker stubs with indirect calls handle BTI when target has BTI. +#source: bti-far-opt.s +#target: [check_shared_lib_support] +#as: -mabi=lp64 +#ld: -shared -T bti-far.ld +#objdump: -dr + +[^:]*: *file format elf64-.*aarch64 + + +Disassembly of section \.plt: + +0000000000018000 <\.plt>: + 18000: d503245f bti c + 18004: a9bf7bf0 stp x16, x30, \[sp, #-16\]! + 18008: 900000d0 adrp x16, 30000 <_GLOBAL_OFFSET_TABLE_> + 1800c: f9400e11 ldr x17, \[x16, #24\] + 18010: 91006210 add x16, x16, #0x18 + 18014: d61f0220 br x17 + 18018: d503201f nop + 1801c: d503201f nop + +0000000000018020 : + 18020: 900000d0 adrp x16, 30000 <_GLOBAL_OFFSET_TABLE_> + 18024: f9401211 ldr x17, \[x16, #32\] + 18028: 91008210 add x16, x16, #0x20 + 1802c: d61f0220 br x17 + 18030: 14000004 b 18040 <__foo_bti_veneer\+0x8> + 18034: d503201f nop + +0000000000018038 <__foo_bti_veneer>: + 18038: d503245f bti c + 1803c: 17fffff9 b 18020 + +Disassembly of section \.text: + +0000000000020000 <_start>: + 20000: 97ffe008 bl 18020 + 20004: 9400000f bl 20040 <___veneer> + 20008: 94000001 bl 2000c + +000000000002000c : + 2000c: d503201f nop + +0000000000020010 : + 20010: d503241f bti + +0000000000020014 : + 20014: d503245f bti c + +0000000000020018 : + 20018: d503249f bti j + +000000000002001c : + 2001c: d50324df bti jc + +0000000000020020 : + 20020: d503233f paciasp + +0000000000020024 : + 20024: d503237f pacibsp + 20028: 1400000c b 20058 <___veneer\+0x18> + 2002c: d503201f nop + +0000000000020030 <___bti_veneer>: + 20030: d503245f bti c + 20034: 17fffff6 b 2000c + +0000000000020038 <___bti_veneer>: + 20038: d503245f bti c + 2003c: 17fffff5 b 20010 + +0000000000020040 <___veneer>: + 20040: 90091910 adrp x16, 12340000 + 20044: 9101e210 add x16, x16, #0x78 + 20048: d61f0200 br x16 + \.\.\. + +Disassembly of section \.far: + +0000000012340000 : + 12340000: 94000018 bl 12340060 <___veneer> + 12340004: 9400003d bl 123400f8 <___veneer> + 12340008: 9400002a bl 123400b0 <___veneer> + 1234000c: 94000023 bl 12340098 <___veneer> + 12340010: 9400002e bl 123400c8 <___veneer> + 12340014: 94000033 bl 123400e0 <___veneer> + 12340018: 9400001a bl 12340080 <___veneer> + +000000001234001c : + 1234001c: 1400000b b 12340048 <__foo_veneer> + 12340020: 14000010 b 12340060 <___veneer> + 12340024: 14000035 b 123400f8 <___veneer> + 12340028: 14000022 b 123400b0 <___veneer> + 1234002c: 1400001b b 12340098 <___veneer> + 12340030: 14000026 b 123400c8 <___veneer> + 12340034: 1400002b b 123400e0 <___veneer> + 12340038: 14000012 b 12340080 <___veneer> + 1234003c: 00000000 udf #0 + 12340040: 14000034 b 12340110 <___veneer\+0x18> + 12340044: d503201f nop + +0000000012340048 <__foo_veneer>: + 12340048: 90f6e6d0 adrp x16, 18000 <\.plt> + 1234004c: 9100e210 add x16, x16, #0x38 + 12340050: d61f0200 br x16 + \.\.\. + +0000000012340060 <___veneer>: + 12340060: 90f6e710 adrp x16, 20000 <_start> + 12340064: 9100c210 add x16, x16, #0x30 + 12340068: d61f0200 br x16 + \.\.\. + +0000000012340078 <___bti_veneer>: + 12340078: d503245f bti c + 1234007c: 17ffffe8 b 1234001c + +0000000012340080 <___veneer>: + 12340080: 90f6e710 adrp x16, 20000 <_start> + 12340084: 91009210 add x16, x16, #0x24 + 12340088: d61f0200 br x16 + \.\.\. + +0000000012340098 <___veneer>: + 12340098: 90f6e710 adrp x16, 20000 <_start> + 1234009c: 91006210 add x16, x16, #0x18 + 123400a0: d61f0200 br x16 + \.\.\. + +00000000123400b0 <___veneer>: + 123400b0: 90f6e710 adrp x16, 20000 <_start> + 123400b4: 91005210 add x16, x16, #0x14 + 123400b8: d61f0200 br x16 + \.\.\. + +00000000123400c8 <___veneer>: + 123400c8: 90f6e710 adrp x16, 20000 <_start> + 123400cc: 91007210 add x16, x16, #0x1c + 123400d0: d61f0200 br x16 + \.\.\. + +00000000123400e0 <___veneer>: + 123400e0: 90f6e710 adrp x16, 20000 <_start> + 123400e4: 91008210 add x16, x16, #0x20 + 123400e8: d61f0200 br x16 + \.\.\. + +00000000123400f8 <___veneer>: + 123400f8: 90f6e710 adrp x16, 20000 <_start> + 123400fc: 9100e210 add x16, x16, #0x38 + 12340100: d61f0200 br x16 + \.\.\. diff --git a/ld/testsuite/ld-aarch64/bti-far-opt.s b/ld/testsuite/ld-aarch64/bti-far-opt.s new file mode 100644 index 00000000000..516b901f20f --- /dev/null +++ b/ld/testsuite/ld-aarch64/bti-far-opt.s @@ -0,0 +1,53 @@ + .text + .global _start + .type _start, %function +_start: + bl foo + bl bar + bl baz +baz: + nop +baz_bti_: + bti +baz_bti_c: + bti c +baz_bti_j: + bti j +baz_bti_jc: + bti jc +baz_paciasp: + paciasp +baz_pacibsp: + pacibsp + + .section .far,"ax",@progbits + .global foo + .type foo, %function +foo: + bl baz + bl baz_bti_ + bl baz_bti_c + bl baz_bti_j + bl baz_bti_jc + bl baz_paciasp + bl baz_pacibsp +bar: + b foo + b baz + b baz_bti_ + b baz_bti_c + b baz_bti_j + b baz_bti_jc + b baz_paciasp + b baz_pacibsp + + .section .note.gnu.property,"a" + .align 3 + .word 4 + .word 16 + .word 5 + .string "GNU" + .word 0xc0000000 + .word 4 + .word 1 + .align 3