Skip to content

Commit 932e36a

Browse files
committed
[PAC][CodeGen][ELF][AArch64] Support signed GOT
This re-applies #96164 after revert in #102434. Support the following relocations and assembly operators: - `R_AARCH64_AUTH_ADR_GOT_PAGE` (`:got_auth:` for `adrp`) - `R_AARCH64_AUTH_LD64_GOT_LO12_NC` (`:got_auth_lo12:` for `ldr`) - `R_AARCH64_AUTH_GOT_ADD_LO12_NC` (`:got_auth_lo12:` for `add`) `LOADgotAUTH` pseudo-instruction is introduced which is later expanded to actual instruction sequence like the following. ``` adrp x16, :got_auth:sym add x16, x16, :got_auth_lo12:sym ldr x0, [x16] autia x0, x16 ``` If a resign is requested, like below, `LOADgotPAC` pseudo is used, and GOT load is lowered similarly to `LOADgotAUTH`. ``` @var = global i32 0 define ptr @resign_globalvar() { ret ptr ptrauth (ptr @var, i32 3, i64 43) } ``` If FPAC bit is not set and resign is requested, a check+trap sequence similar to one used for `AUT` pseudo is emitted. Both SelectionDAG and GlobalISel are suppported. For FastISel, we fall back to SelectionDAG. Tests starting with 'ptrauth-' have corresponding variants w/o this prefix. See also specification https://github.com/ARM-software/abi-aa/blob/main/pauthabielf64/pauthabielf64.rst#appendix-signed-got
1 parent d2e9532 commit 932e36a

21 files changed

+635
-35
lines changed

llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

+150-8
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ class AArch64AsmPrinter : public AsmPrinter {
169169
// adrp-add followed by PAC sign)
170170
void LowerMOVaddrPAC(const MachineInstr &MI);
171171

172+
// Emit the sequence for LOADgotAUTH (load signed pointer from signed ELF GOT
173+
// and authenticate it with, if FPAC bit is not set, check+trap sequence after
174+
// authenticating)
175+
void LowerLOADgotAUTH(const MachineInstr &MI);
176+
172177
/// tblgen'erated driver function for lowering simple MI->MC
173178
/// pseudo instructions.
174179
bool lowerPseudoInstExpansion(const MachineInstr *MI, MCInst &Inst);
@@ -873,6 +878,22 @@ void AArch64AsmPrinter::emitEndOfAsmFile(Module &M) {
873878

874879
OutStreamer->addBlankLine();
875880
}
881+
882+
// With signed ELF GOT enabled, the linker looks at the symbol type to
883+
// choose between keys IA (for STT_FUNC) and DA (for other types). Symbols
884+
// for functions not defined in the module have STT_NOTYPE type by default.
885+
// This makes linker to emit signing schema with DA key (instead of IA) for
886+
// corresponding R_AARCH64_AUTH_GLOB_DAT dynamic reloc. To avoid that, force
887+
// all function symbols used in the module to have STT_FUNC type. See
888+
// https://github.com/ARM-software/abi-aa/blob/main/pauthabielf64/pauthabielf64.rst#default-signing-schema
889+
const auto *PtrAuthELFGOTFlag = mdconst::extract_or_null<ConstantInt>(
890+
M.getModuleFlag("ptrauth-elf-got"));
891+
if (PtrAuthELFGOTFlag && PtrAuthELFGOTFlag->getZExtValue() == 1)
892+
for (const GlobalValue &GV : M.global_values())
893+
if (!GV.use_empty() && isa<Function>(GV) &&
894+
!GV.getName().starts_with("llvm."))
895+
OutStreamer->emitSymbolAttribute(getSymbol(&GV),
896+
MCSA_ELF_TypeFunction);
876897
}
877898

878899
// Emit stack and fault map information.
@@ -2068,6 +2089,10 @@ void AArch64AsmPrinter::LowerLOADauthptrstatic(const MachineInstr &MI) {
20682089

20692090
void AArch64AsmPrinter::LowerMOVaddrPAC(const MachineInstr &MI) {
20702091
const bool IsGOTLoad = MI.getOpcode() == AArch64::LOADgotPAC;
2092+
const bool IsELFSignedGOT = MI.getParent()
2093+
->getParent()
2094+
->getInfo<AArch64FunctionInfo>()
2095+
->hasELFSignedGOT();
20712096
MachineOperand GAOp = MI.getOperand(0);
20722097
const uint64_t KeyC = MI.getOperand(1).getImm();
20732098
assert(KeyC <= AArch64PACKey::LAST &&
@@ -2084,9 +2109,17 @@ void AArch64AsmPrinter::LowerMOVaddrPAC(const MachineInstr &MI) {
20842109
// Emit:
20852110
// target materialization:
20862111
// - via GOT:
2087-
// adrp x16, :got:target
2088-
// ldr x16, [x16, :got_lo12:target]
2089-
// add offset to x16 if offset != 0
2112+
// - unsigned GOT:
2113+
// adrp x16, :got:target
2114+
// ldr x16, [x16, :got_lo12:target]
2115+
// add offset to x16 if offset != 0
2116+
// - ELF signed GOT:
2117+
// adrp x17, :got:target
2118+
// add x17, x17, :got_auth_lo12:target
2119+
// ldr x16, [x17]
2120+
// aut{i|d}a x16, x17
2121+
// check+trap sequence (if no FPAC)
2122+
// add offset to x16 if offset != 0
20902123
//
20912124
// - direct:
20922125
// adrp x16, target
@@ -2129,13 +2162,79 @@ void AArch64AsmPrinter::LowerMOVaddrPAC(const MachineInstr &MI) {
21292162
MCInstLowering.lowerOperand(GAMOLo, GAMCLo);
21302163

21312164
EmitToStreamer(
2132-
MCInstBuilder(AArch64::ADRP).addReg(AArch64::X16).addOperand(GAMCHi));
2165+
MCInstBuilder(AArch64::ADRP)
2166+
.addReg(IsGOTLoad && IsELFSignedGOT ? AArch64::X17 : AArch64::X16)
2167+
.addOperand(GAMCHi));
21332168

21342169
if (IsGOTLoad) {
2135-
EmitToStreamer(MCInstBuilder(AArch64::LDRXui)
2136-
.addReg(AArch64::X16)
2137-
.addReg(AArch64::X16)
2138-
.addOperand(GAMCLo));
2170+
if (IsELFSignedGOT) {
2171+
EmitToStreamer(MCInstBuilder(AArch64::ADDXri)
2172+
.addReg(AArch64::X17)
2173+
.addReg(AArch64::X17)
2174+
.addOperand(GAMCLo)
2175+
.addImm(0));
2176+
2177+
EmitToStreamer(MCInstBuilder(AArch64::LDRXui)
2178+
.addReg(AArch64::X16)
2179+
.addReg(AArch64::X17)
2180+
.addImm(0));
2181+
2182+
assert(GAOp.isGlobal());
2183+
assert(GAOp.getGlobal()->getValueType() != nullptr);
2184+
unsigned AuthOpcode = GAOp.getGlobal()->getValueType()->isFunctionTy()
2185+
? AArch64::AUTIA
2186+
: AArch64::AUTDA;
2187+
2188+
EmitToStreamer(MCInstBuilder(AuthOpcode)
2189+
.addReg(AArch64::X16)
2190+
.addReg(AArch64::X16)
2191+
.addReg(AArch64::X17));
2192+
2193+
if (!STI->hasFPAC()) {
2194+
auto AuthKey = (AuthOpcode == AArch64::AUTIA ? AArch64PACKey::IA
2195+
: AArch64PACKey::DA);
2196+
unsigned XPACOpc = getXPACOpcodeForKey(AuthKey);
2197+
MCSymbol *SuccessSym = createTempSymbol("auth_success_");
2198+
2199+
// XPAC has tied src/dst: use x17 as a temporary copy.
2200+
// mov x17, x16
2201+
EmitToStreamer(MCInstBuilder(AArch64::ORRXrs)
2202+
.addReg(AArch64::X17)
2203+
.addReg(AArch64::XZR)
2204+
.addReg(AArch64::X16)
2205+
.addImm(0));
2206+
2207+
// xpaci x17
2208+
EmitToStreamer(
2209+
MCInstBuilder(XPACOpc).addReg(AArch64::X17).addReg(AArch64::X17));
2210+
2211+
// cmp x16, x17
2212+
EmitToStreamer(MCInstBuilder(AArch64::SUBSXrs)
2213+
.addReg(AArch64::XZR)
2214+
.addReg(AArch64::X16)
2215+
.addReg(AArch64::X17)
2216+
.addImm(0));
2217+
2218+
// b.eq Lsuccess
2219+
EmitToStreamer(
2220+
MCInstBuilder(AArch64::Bcc)
2221+
.addImm(AArch64CC::EQ)
2222+
.addExpr(MCSymbolRefExpr::create(SuccessSym, OutContext)));
2223+
2224+
// Trapping sequences do a 'brk'.
2225+
// brk #<0xc470 + aut key>
2226+
EmitToStreamer(MCInstBuilder(AArch64::BRK).addImm(0xc470 | AuthKey));
2227+
2228+
// If the auth check succeeds, we can continue.
2229+
// Lsuccess:
2230+
OutStreamer->emitLabel(SuccessSym);
2231+
}
2232+
} else {
2233+
EmitToStreamer(MCInstBuilder(AArch64::LDRXui)
2234+
.addReg(AArch64::X16)
2235+
.addReg(AArch64::X16)
2236+
.addOperand(GAMCLo));
2237+
}
21392238
} else {
21402239
EmitToStreamer(MCInstBuilder(AArch64::ADDXri)
21412240
.addReg(AArch64::X16)
@@ -2203,6 +2302,45 @@ void AArch64AsmPrinter::LowerMOVaddrPAC(const MachineInstr &MI) {
22032302
EmitToStreamer(MIB);
22042303
}
22052304

2305+
void AArch64AsmPrinter::LowerLOADgotAUTH(const MachineInstr &MI) {
2306+
Register DstReg = MI.getOperand(0).getReg();
2307+
const MachineOperand &GAMO = MI.getOperand(1);
2308+
assert(GAMO.getOffset() == 0);
2309+
2310+
MachineOperand GAHiOp(GAMO);
2311+
MachineOperand GALoOp(GAMO);
2312+
GAHiOp.addTargetFlag(AArch64II::MO_PAGE);
2313+
GALoOp.addTargetFlag(AArch64II::MO_PAGEOFF | AArch64II::MO_NC);
2314+
2315+
MCOperand GAMCHi, GAMCLo;
2316+
MCInstLowering.lowerOperand(GAHiOp, GAMCHi);
2317+
MCInstLowering.lowerOperand(GALoOp, GAMCLo);
2318+
2319+
EmitToStreamer(
2320+
MCInstBuilder(AArch64::ADRP).addReg(AArch64::X16).addOperand(GAMCHi));
2321+
2322+
EmitToStreamer(MCInstBuilder(AArch64::ADDXri)
2323+
.addReg(AArch64::X16)
2324+
.addReg(AArch64::X16)
2325+
.addOperand(GAMCLo)
2326+
.addImm(0));
2327+
2328+
EmitToStreamer(MCInstBuilder(AArch64::LDRXui)
2329+
.addReg(DstReg)
2330+
.addReg(AArch64::X16)
2331+
.addImm(0));
2332+
2333+
assert(GAMO.isGlobal());
2334+
assert(GAMO.getGlobal()->getValueType() != nullptr);
2335+
unsigned AuthOpcode = GAMO.getGlobal()->getValueType()->isFunctionTy()
2336+
? AArch64::AUTIA
2337+
: AArch64::AUTDA;
2338+
EmitToStreamer(MCInstBuilder(AuthOpcode)
2339+
.addReg(DstReg)
2340+
.addReg(DstReg)
2341+
.addReg(AArch64::X16));
2342+
}
2343+
22062344
const MCExpr *
22072345
AArch64AsmPrinter::lowerBlockAddressConstant(const BlockAddress &BA) {
22082346
const MCExpr *BAE = AsmPrinter::lowerBlockAddressConstant(BA);
@@ -2381,6 +2519,10 @@ void AArch64AsmPrinter::emitInstruction(const MachineInstr *MI) {
23812519
LowerMOVaddrPAC(*MI);
23822520
return;
23832521

2522+
case AArch64::LOADgotAUTH:
2523+
LowerLOADgotAUTH(*MI);
2524+
return;
2525+
23842526
case AArch64::BRA:
23852527
case AArch64::BLRA:
23862528
emitPtrauthBranch(MI);

llvm/lib/Target/AArch64/AArch64FastISel.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,9 @@ unsigned AArch64FastISel::materializeGV(const GlobalValue *GV) {
453453
if (!Subtarget->useSmallAddressing() && !Subtarget->isTargetMachO())
454454
return 0;
455455

456+
if (FuncInfo.MF->getInfo<AArch64FunctionInfo>()->hasELFSignedGOT())
457+
return 0;
458+
456459
unsigned OpFlags = Subtarget->ClassifyGlobalReference(GV, TM);
457460

458461
EVT DestEVT = TLI.getValueType(DL, GV->getType(), true);

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -9598,6 +9598,11 @@ SDValue AArch64TargetLowering::getGOT(NodeTy *N, SelectionDAG &DAG,
95989598
SDValue GotAddr = getTargetNode(N, Ty, DAG, AArch64II::MO_GOT | Flags);
95999599
// FIXME: Once remat is capable of dealing with instructions with register
96009600
// operands, expand this into two nodes instead of using a wrapper node.
9601+
if (DAG.getMachineFunction()
9602+
.getInfo<AArch64FunctionInfo>()
9603+
->hasELFSignedGOT())
9604+
return SDValue(DAG.getMachineNode(AArch64::LOADgotAUTH, DL, Ty, GotAddr),
9605+
0);
96019606
return DAG.getNode(AArch64ISD::LOADgot, DL, Ty, GotAddr);
96029607
}
96039608

llvm/lib/Target/AArch64/AArch64InstrInfo.td

+9-2
Original file line numberDiff line numberDiff line change
@@ -1937,8 +1937,15 @@ let Predicates = [HasPAuth] in {
19371937
Sched<[WriteI, ReadI]> {
19381938
let isReMaterializable = 1;
19391939
let isCodeGenOnly = 1;
1940-
let Size = 40; // 12 fixed + 28 variable, for pointer offset, and discriminator
1941-
let Defs = [X16,X17];
1940+
let Size = 68; // 12 fixed + 56 variable, for pointer offset, discriminator and
1941+
// ELF signed GOT signed pointer authentication (if no FPAC)
1942+
let Defs = [X16,X17,NZCV];
1943+
}
1944+
1945+
def LOADgotAUTH : Pseudo<(outs GPR64common:$dst), (ins i64imm:$addr), []>,
1946+
Sched<[WriteI, ReadI]> {
1947+
let Defs = [X16];
1948+
let Size = 16;
19421949
}
19431950

19441951
// Load a signed global address from a special $auth_ptr$ stub slot.

llvm/lib/Target/AArch64/AArch64MCInstLower.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
#include "AArch64MCInstLower.h"
15+
#include "AArch64MachineFunctionInfo.h"
1516
#include "MCTargetDesc/AArch64MCExpr.h"
1617
#include "Utils/AArch64BaseInfo.h"
1718
#include "llvm/CodeGen/AsmPrinter.h"
@@ -185,9 +186,12 @@ MCOperand AArch64MCInstLower::lowerSymbolOperandELF(const MachineOperand &MO,
185186
MCSymbol *Sym) const {
186187
uint32_t RefFlags = 0;
187188

188-
if (MO.getTargetFlags() & AArch64II::MO_GOT)
189-
RefFlags |= AArch64MCExpr::VK_GOT;
190-
else if (MO.getTargetFlags() & AArch64II::MO_TLS) {
189+
if (MO.getTargetFlags() & AArch64II::MO_GOT) {
190+
const MachineFunction *MF = MO.getParent()->getParent()->getParent();
191+
RefFlags |= (MF->getInfo<AArch64FunctionInfo>()->hasELFSignedGOT()
192+
? AArch64MCExpr::VK_GOT_AUTH
193+
: AArch64MCExpr::VK_GOT);
194+
} else if (MO.getTargetFlags() & AArch64II::MO_TLS) {
191195
TLSModel::Model Model;
192196
if (MO.isGlobal()) {
193197
const GlobalValue *GV = MO.getGlobal();

llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ static bool ShouldSignWithBKey(const Function &F, const AArch64Subtarget &STI) {
7272
return Key == "b_key";
7373
}
7474

75+
static bool HasELFSignedGOTHelper(const Function &F,
76+
const AArch64Subtarget *STI) {
77+
if (!Triple(STI->getTargetTriple()).isOSBinFormatELF())
78+
return false;
79+
const Module *M = F.getParent();
80+
const auto *Flag = mdconst::extract_or_null<ConstantInt>(
81+
M->getModuleFlag("ptrauth-elf-got"));
82+
if (Flag && Flag->getZExtValue() == 1)
83+
return true;
84+
return false;
85+
}
86+
7587
AArch64FunctionInfo::AArch64FunctionInfo(const Function &F,
7688
const AArch64Subtarget *STI) {
7789
// If we already know that the function doesn't have a redzone, set
@@ -80,6 +92,7 @@ AArch64FunctionInfo::AArch64FunctionInfo(const Function &F,
8092
HasRedZone = false;
8193
std::tie(SignReturnAddress, SignReturnAddressAll) = GetSignReturnAddress(F);
8294
SignWithBKey = ShouldSignWithBKey(F, *STI);
95+
HasELFSignedGOT = HasELFSignedGOTHelper(F, STI);
8396
// TODO: skip functions that have no instrumented allocas for optimization
8497
IsMTETagged = F.hasFnAttribute(Attribute::SanitizeMemTag);
8598

llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h

+7
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ class AArch64FunctionInfo final : public MachineFunctionInfo {
177177
/// SignWithBKey modifies the default PAC-RET mode to signing with the B key.
178178
bool SignWithBKey = false;
179179

180+
/// HasELFSignedGOT is true if the target binary format is ELF and the IR
181+
/// module containing the corresponding function has "ptrauth-elf-got" flag
182+
/// set to 1.
183+
bool HasELFSignedGOT = false;
184+
180185
/// SigningInstrOffset captures the offset of the PAC-RET signing instruction
181186
/// within the prologue, so it can be re-used for authentication in the
182187
/// epilogue when using PC as a second salt (FEAT_PAuth_LR)
@@ -509,6 +514,8 @@ class AArch64FunctionInfo final : public MachineFunctionInfo {
509514

510515
bool shouldSignWithBKey() const { return SignWithBKey; }
511516

517+
bool hasELFSignedGOT() const { return HasELFSignedGOT; }
518+
512519
MCSymbol *getSigningInstrLabel() const { return SignInstrLabel; }
513520
void setSigningInstrLabel(MCSymbol *Label) { SignInstrLabel = Label; }
514521

llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

+19-13
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,7 @@ class AArch64Operand : public MCParsedAsmOperand {
896896
if (DarwinRefKind == MCSymbolRefExpr::VK_PAGEOFF ||
897897
ELFRefKind == AArch64MCExpr::VK_LO12 ||
898898
ELFRefKind == AArch64MCExpr::VK_GOT_LO12 ||
899+
ELFRefKind == AArch64MCExpr::VK_GOT_AUTH_LO12 ||
899900
ELFRefKind == AArch64MCExpr::VK_DTPREL_LO12 ||
900901
ELFRefKind == AArch64MCExpr::VK_DTPREL_LO12_NC ||
901902
ELFRefKind == AArch64MCExpr::VK_TPREL_LO12 ||
@@ -1007,19 +1008,20 @@ class AArch64Operand : public MCParsedAsmOperand {
10071008
int64_t Addend;
10081009
if (AArch64AsmParser::classifySymbolRef(Expr, ELFRefKind,
10091010
DarwinRefKind, Addend)) {
1010-
return DarwinRefKind == MCSymbolRefExpr::VK_PAGEOFF
1011-
|| DarwinRefKind == MCSymbolRefExpr::VK_TLVPPAGEOFF
1012-
|| (DarwinRefKind == MCSymbolRefExpr::VK_GOTPAGEOFF && Addend == 0)
1013-
|| ELFRefKind == AArch64MCExpr::VK_LO12
1014-
|| ELFRefKind == AArch64MCExpr::VK_DTPREL_HI12
1015-
|| ELFRefKind == AArch64MCExpr::VK_DTPREL_LO12
1016-
|| ELFRefKind == AArch64MCExpr::VK_DTPREL_LO12_NC
1017-
|| ELFRefKind == AArch64MCExpr::VK_TPREL_HI12
1018-
|| ELFRefKind == AArch64MCExpr::VK_TPREL_LO12
1019-
|| ELFRefKind == AArch64MCExpr::VK_TPREL_LO12_NC
1020-
|| ELFRefKind == AArch64MCExpr::VK_TLSDESC_LO12
1021-
|| ELFRefKind == AArch64MCExpr::VK_SECREL_HI12
1022-
|| ELFRefKind == AArch64MCExpr::VK_SECREL_LO12;
1011+
return DarwinRefKind == MCSymbolRefExpr::VK_PAGEOFF ||
1012+
DarwinRefKind == MCSymbolRefExpr::VK_TLVPPAGEOFF ||
1013+
(DarwinRefKind == MCSymbolRefExpr::VK_GOTPAGEOFF && Addend == 0) ||
1014+
ELFRefKind == AArch64MCExpr::VK_LO12 ||
1015+
ELFRefKind == AArch64MCExpr::VK_GOT_AUTH_LO12 ||
1016+
ELFRefKind == AArch64MCExpr::VK_DTPREL_HI12 ||
1017+
ELFRefKind == AArch64MCExpr::VK_DTPREL_LO12 ||
1018+
ELFRefKind == AArch64MCExpr::VK_DTPREL_LO12_NC ||
1019+
ELFRefKind == AArch64MCExpr::VK_TPREL_HI12 ||
1020+
ELFRefKind == AArch64MCExpr::VK_TPREL_LO12 ||
1021+
ELFRefKind == AArch64MCExpr::VK_TPREL_LO12_NC ||
1022+
ELFRefKind == AArch64MCExpr::VK_TLSDESC_LO12 ||
1023+
ELFRefKind == AArch64MCExpr::VK_SECREL_HI12 ||
1024+
ELFRefKind == AArch64MCExpr::VK_SECREL_LO12;
10231025
}
10241026

10251027
// If it's a constant, it should be a real immediate in range.
@@ -3308,6 +3310,7 @@ ParseStatus AArch64AsmParser::tryParseAdrpLabel(OperandVector &Operands) {
33083310
DarwinRefKind != MCSymbolRefExpr::VK_TLVPPAGE &&
33093311
ELFRefKind != AArch64MCExpr::VK_ABS_PAGE_NC &&
33103312
ELFRefKind != AArch64MCExpr::VK_GOT_PAGE &&
3313+
ELFRefKind != AArch64MCExpr::VK_GOT_AUTH_PAGE &&
33113314
ELFRefKind != AArch64MCExpr::VK_GOT_PAGE_LO15 &&
33123315
ELFRefKind != AArch64MCExpr::VK_GOTTPREL_PAGE &&
33133316
ELFRefKind != AArch64MCExpr::VK_TLSDESC_PAGE) {
@@ -4427,6 +4430,8 @@ bool AArch64AsmParser::parseSymbolicImmVal(const MCExpr *&ImmVal) {
44274430
.Case("got", AArch64MCExpr::VK_GOT_PAGE)
44284431
.Case("gotpage_lo15", AArch64MCExpr::VK_GOT_PAGE_LO15)
44294432
.Case("got_lo12", AArch64MCExpr::VK_GOT_LO12)
4433+
.Case("got_auth", AArch64MCExpr::VK_GOT_AUTH_PAGE)
4434+
.Case("got_auth_lo12", AArch64MCExpr::VK_GOT_AUTH_LO12)
44304435
.Case("gottprel", AArch64MCExpr::VK_GOTTPREL_PAGE)
44314436
.Case("gottprel_lo12", AArch64MCExpr::VK_GOTTPREL_LO12_NC)
44324437
.Case("gottprel_g1", AArch64MCExpr::VK_GOTTPREL_G1)
@@ -5800,6 +5805,7 @@ bool AArch64AsmParser::validateInstruction(MCInst &Inst, SMLoc &IDLoc,
58005805

58015806
// Only allow these with ADDXri/ADDWri
58025807
if ((ELFRefKind == AArch64MCExpr::VK_LO12 ||
5808+
ELFRefKind == AArch64MCExpr::VK_GOT_AUTH_LO12 ||
58035809
ELFRefKind == AArch64MCExpr::VK_DTPREL_HI12 ||
58045810
ELFRefKind == AArch64MCExpr::VK_DTPREL_LO12 ||
58055811
ELFRefKind == AArch64MCExpr::VK_DTPREL_LO12_NC ||

llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -2959,7 +2959,9 @@ bool AArch64InstructionSelector::select(MachineInstr &I) {
29592959
}
29602960

29612961
if (OpFlags & AArch64II::MO_GOT) {
2962-
I.setDesc(TII.get(AArch64::LOADgot));
2962+
I.setDesc(TII.get(MF.getInfo<AArch64FunctionInfo>()->hasELFSignedGOT()
2963+
? AArch64::LOADgotAUTH
2964+
: AArch64::LOADgot));
29632965
I.getOperand(1).setTargetFlags(OpFlags);
29642966
} else if (TM.getCodeModel() == CodeModel::Large &&
29652967
!TM.isPositionIndependent()) {

0 commit comments

Comments
 (0)