[llvm] [AArch64][PAC] Lower ptrauth constants in code for MachO. (PR #97665)
Daniil Kovalev via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 4 01:55:46 PDT 2024
================
@@ -848,20 +848,39 @@ void AArch64AsmPrinter::emitHwasanMemaccessSymbols(Module &M) {
}
}
-template <typename MachineModuleInfoTarget>
-static void emitAuthenticatedPointer(
- MCStreamer &OutStreamer, MCSymbol *StubLabel,
- const typename MachineModuleInfoTarget::AuthStubInfo &StubInfo) {
+static void emitAuthenticatedPointer(MCStreamer &OutStreamer,
+ MCSymbol *StubLabel,
+ const MCExpr *StubAuthPtrRef) {
// sym$auth_ptr$key$disc:
OutStreamer.emitLabel(StubLabel);
- OutStreamer.emitValue(StubInfo.AuthPtrRef, /*size=*/8);
+ OutStreamer.emitValue(StubAuthPtrRef, /*size=*/8);
}
void AArch64AsmPrinter::emitEndOfAsmFile(Module &M) {
emitHwasanMemaccessSymbols(M);
const Triple &TT = TM.getTargetTriple();
if (TT.isOSBinFormatMachO()) {
+
+ // Output authenticated pointers as indirect symbols, if we have any.
+ MachineModuleInfoMachO &MMIMacho =
+ MMI->getObjFileInfo<MachineModuleInfoMachO>();
+
+ auto Stubs = MMIMacho.getAuthGVStubList();
+
+ if (!Stubs.empty()) {
+ // Switch to the "__auth_ptr" section.
+ OutStreamer->switchSection(
+ OutContext.getMachOSection("__DATA", "__auth_ptr", MachO::S_REGULAR,
+ SectionKind::getMetadata()));
+ emitAlignment(Align(8));
+
+ for (auto &Stub : Stubs)
----------------
kovdan01 wrote:
```suggestion
for (const auto &Stub : Stubs)
```
https://github.com/llvm/llvm-project/pull/97665
More information about the llvm-commits
mailing list