From 77ef13ce9d176c8881da61bf492b53aed25bdbd6 Mon Sep 17 00:00:00 2001 From: kettenis Date: Mon, 15 May 2023 13:15:17 +0000 Subject: [PATCH] Enable BTI PLT entries by default. ok jsg@ --- gnu/llvm/lld/ELF/Arch/AArch64.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gnu/llvm/lld/ELF/Arch/AArch64.cpp b/gnu/llvm/lld/ELF/Arch/AArch64.cpp index c1ab0e97efe..7021aa000ab 100644 --- a/gnu/llvm/lld/ELF/Arch/AArch64.cpp +++ b/gnu/llvm/lld/ELF/Arch/AArch64.cpp @@ -621,7 +621,11 @@ private: } // namespace AArch64BtiPac::AArch64BtiPac() { +#ifdef __OpenBSD__ + btiHeader = true; +#else btiHeader = (config->andFeatures & GNU_PROPERTY_AARCH64_FEATURE_1_BTI); +#endif // A BTI (Branch Target Indicator) Plt Entry is only required if the // address of the PLT entry can be taken by the program, which permits an // indirect jump to the PLT entry. This can happen when the address @@ -717,6 +721,10 @@ void AArch64BtiPac::writePlt(uint8_t *buf, const Symbol &sym, } static TargetInfo *getTargetInfo() { +#ifdef __OpenBSD__ + static AArch64BtiPac t; + return &t; +#else if (config->andFeatures & (GNU_PROPERTY_AARCH64_FEATURE_1_BTI | GNU_PROPERTY_AARCH64_FEATURE_1_PAC)) { static AArch64BtiPac t; @@ -724,6 +732,7 @@ static TargetInfo *getTargetInfo() { } static AArch64 t; return &t; +#endif } TargetInfo *elf::getAArch64TargetInfo() { return getTargetInfo(); } -- 2.20.1