Skip to content

Target: Add target option for disabling `AArch64_ELFTargetObjectFile:… #10795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions llvm/include/llvm/Target/TargetOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ namespace llvm {
XRayFunctionIndex(true), DebugStrictDwarf(false), Hotpatch(false),
PPCGenScalarMASSEntries(false), JMCInstrument(false),
EnableCFIFixup(false), MisExpect(false), XCOFFReadOnlyPointers(false),
SupportIndirectSymViaGOTPCRel_AArch64_ELF(true),
VerifyArgABICompliance(true),
FPDenormalMode(DenormalMode::IEEE, DenormalMode::IEEE) {}

Expand Down Expand Up @@ -389,6 +390,10 @@ namespace llvm {
/// into the RO data section.
unsigned XCOFFReadOnlyPointers : 1;

/// When set to true, enables indirect symbol replacement with GOTPCREL for
/// AArch64/ELF.
unsigned SupportIndirectSymViaGOTPCRel_AArch64_ELF : 1;

/// When set to true, call/return argument extensions of narrow integers
/// are verified in the target backend if it cares about them. This is
/// not done with internal tools like llc that run many tests that ignore
Expand Down
8 changes: 5 additions & 3 deletions llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,15 @@ void AArch64TargetMachine::reset() { SubtargetMap.clear(); }
//===----------------------------------------------------------------------===//
// AArch64 Lowering public interface.
//===----------------------------------------------------------------------===//
static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
static std::unique_ptr<TargetLoweringObjectFile>
createTLOF(const Triple &TT, const TargetOptions &Options) {
if (TT.isOSBinFormatMachO())
return std::make_unique<AArch64_MachoTargetObjectFile>();
if (TT.isOSBinFormatCOFF())
return std::make_unique<AArch64_COFFTargetObjectFile>();

return std::make_unique<AArch64_ELFTargetObjectFile>();
return std::make_unique<AArch64_ELFTargetObjectFile>(
Options.SupportIndirectSymViaGOTPCRel_AArch64_ELF);
}

// Helper function to build a DataLayout string
Expand Down Expand Up @@ -365,7 +367,7 @@ AArch64TargetMachine::AArch64TargetMachine(const Target &T, const Triple &TT,
computeDefaultCPU(TT, CPU), FS, Options,
getEffectiveRelocModel(TT, RM),
getEffectiveAArch64CodeModel(TT, CM, JIT), OL),
TLOF(createTLOF(getTargetTriple())), isLittle(LittleEndian) {
TLOF(createTLOF(getTargetTriple(), Options)), isLittle(LittleEndian) {
initAsmInfo();

if (TT.isOSBinFormatMachO()) {
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ void AArch64_ELFTargetObjectFile::Initialize(MCContext &Ctx,
const TargetMachine &TM) {
TargetLoweringObjectFileELF::Initialize(Ctx, TM);
PLTRelativeSpecifier = AArch64MCExpr::VK_PLT;
SupportIndirectSymViaGOTPCRel = true;

// AARCH64 ELF ABI does not define static relocation type for TLS offset
// within a module. Do not generate AT_location for TLS variables.
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/AArch64/AArch64TargetObjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class AArch64_ELFTargetObjectFile : public TargetLoweringObjectFileELF {
void Initialize(MCContext &Ctx, const TargetMachine &TM) override;

public:
AArch64_ELFTargetObjectFile(bool SupportIndirectSymViaGOTPCRel) {
this->SupportIndirectSymViaGOTPCRel = SupportIndirectSymViaGOTPCRel;
}

const MCExpr *getIndirectSymViaGOTPCRel(const GlobalValue *GV,
const MCSymbol *Sym,
const MCValue &MV, int64_t Offset,
Expand Down