[llvm] [PAC][CodeGen][ELF][AArch64] Support signed GOT (PR #96164)
Tomas Matheson via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 5 10:46:43 PDT 2024
================
@@ -82,6 +83,25 @@ static bool ShouldSignWithBKey(const Function &F, const AArch64Subtarget &STI) {
return Key == "b_key";
}
+static bool hasELFSignedGOTHelper(const Function &F,
+ const AArch64Subtarget *STI) {
+ if (!Triple(STI->getTargetTriple()).isOSBinFormatELF())
+ return false;
+ const Module *M = F.getParent();
+ uint64_t PAuthABIPlatform = -1;
+ if (const auto *PAP = mdconst::extract_or_null<ConstantInt>(
+ M->getModuleFlag("aarch64-elf-pauthabi-platform")))
+ PAuthABIPlatform = PAP->getZExtValue();
+ if (PAuthABIPlatform != ELF::AARCH64_PAUTH_PLATFORM_LLVM_LINUX)
+ return false;
+ uint64_t PAuthABIVersion = -1;
+ if (const auto *PAV = mdconst::extract_or_null<ConstantInt>(
+ M->getModuleFlag("aarch64-elf-pauthabi-version")))
+ PAuthABIVersion = PAV->getZExtValue();
+ return (PAuthABIVersion &
+ (1 << ELF::AARCH64_PAUTH_PLATFORM_LLVM_LINUX_VERSION_GOT)) != 0;
----------------
tmatheson-arm wrote:
The function seems to return `true` if there is no `aarch64-elf-pauthabi-version` flag, which doesn't seem right?
```suggestion
const auto *PAV = mdconst::extract_or_null<ConstantInt>(
M->getModuleFlag("aarch64-elf-pauthabi-version"));
if (!PAV)
return false;
return PAV->getZExtValue() &
(1 << ELF::AARCH64_PAUTH_PLATFORM_LLVM_LINUX_VERSION_GOT);
```
https://github.com/llvm/llvm-project/pull/96164
More information about the llvm-commits
mailing list