================
@@ -2303,6 +2310,143 @@ void AArch64AsmPrinter::emitPtrauthBranch(const
MachineInstr *MI) {
EmitToStreamer(*OutStreamer, BRInst);
}
+static void emitAddress(MCStreamer &Streamer, MCRegister Reg,
+ const MCExpr *Expr, bool DSOLocal,
+ const MCSubtargetInfo &STI) {
+ MCValue Val;
+ if (!Expr->evaluateAsRelocatable(Val, nullptr))
+ report_fatal_error("emitAddress could not evaluate");
+ if (DSOLocal) {
+ Streamer.emitInstruction(
+ MCInstBuilder(AArch64::ADRP)
+ .addReg(Reg)
+ .addExpr(MCSpecifierExpr::create(Expr, AArch64::S_ABS_PAGE,
+ Streamer.getContext())),
+ STI);
+ Streamer.emitInstruction(
+ MCInstBuilder(AArch64::ADDXri)
+ .addReg(Reg)
+ .addReg(Reg)
+ .addExpr(MCSpecifierExpr::create(Expr, AArch64::S_LO12,
+ Streamer.getContext()))
+ .addImm(0),
+ STI);
+ } else {
+ auto *SymRef = MCSymbolRefExpr::create(Val.getAddSym(),
Streamer.getContext());
+ Streamer.emitInstruction(
+ MCInstBuilder(AArch64::ADRP)
+ .addReg(Reg)
+ .addExpr(MCSpecifierExpr::create(SymRef, AArch64::S_GOT_PAGE,
+ Streamer.getContext())),
+ STI);
+ Streamer.emitInstruction(
+ MCInstBuilder(AArch64::LDRXui)
+ .addReg(Reg)
+ .addReg(Reg)
+ .addExpr(MCSpecifierExpr::create(SymRef, AArch64::S_GOT_LO12,
+ Streamer.getContext())),
+ STI);
+ if (Val.getConstant())
+ Streamer.emitInstruction(MCInstBuilder(AArch64::ADDXri)
+ .addReg(Reg)
+ .addReg(Reg)
+ .addImm(Val.getConstant())
+ .addImm(0),
+ STI);
+ }
+}
+
+static bool targetSupportsPAuthRelocation(const Triple &TT,
+ const MCExpr *Target) {
+ // No released version of glibc supports PAuth relocations.
+ if (TT.isOSGlibc())
+ return false;
+
+ // We emit PAuth constants as IRELATIVE relocations in cases where the
+ // constant cannot be represented as a PAuth relocation:
+ // 1) The signed value is not a symbol.
+ return !isa<MCConstantExpr>(Target);
+}
+
+static bool targetSupportsIRelativeRelocation(const Triple &TT) {
+ // IFUNCs are ELF-only.
+ if (!TT.isOSBinFormatELF())
+ return false;
+
+ // musl doesn't support IFUNCs.
+ if (TT.isMusl())
+ return false;
+
+ return true;
+}
+
+const MCExpr *AArch64AsmPrinter::emitPAuthRelocationAsIRelative(
----------------
fmayer wrote:
maybe for posterity add a comment of the way codegen in the different cases?
https://github.com/llvm/llvm-project/pull/133533
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits