From: Szabolcs Nagy Date: Wed, 18 Jan 2023 12:56:46 +0000 (+0000) Subject: bfd: aarch64: Fix stubs that may break BTI PR30076 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=15b4f66b0a9a3be6caf1898d22a13c39e662006f;p=binutils-gdb.git bfd: aarch64: Fix stubs that may break BTI PR30076 Insert two stubs in a BTI enabled binary when fixing long calls: The first is near the call site and uses an indirect jump like before, but it targets the second stub that is near the call target site and uses a direct jump. This is needed when a single stub breaks BTI compatibility. The stub layout is kept fixed between sizing and building the stubs, so the location of the second stub is known at build time, this may introduce padding between stubs when those are relaxed. Stub layout with BTI disabled is unchanged. --- diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index f858d10c596..d9ebeae922c 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -2354,6 +2354,9 @@ elfNN_aarch64_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, name can be changed. The only requirement is the %s be present. */ #define STUB_ENTRY_NAME "__%s_veneer" +/* Stub name for a BTI landing stub. */ +#define BTI_STUB_ENTRY_NAME "__%s_bti_veneer" + /* The name of the dynamic interpreter. This is put in the .interp section. */ #define ELF_DYNAMIC_INTERPRETER "/lib/ld.so.1" @@ -2406,6 +2409,12 @@ static const uint32_t aarch64_long_branch_stub[] = 0x00000000, }; +static const uint32_t aarch64_bti_direct_branch_stub[] = +{ + 0xd503245f, /* bti c */ + 0x14000000, /* b