diff --git a/include/llvm/MC/MCObjectFileInfo.h b/include/llvm/MC/MCObjectFileInfo.h index 2e3d4f87060..0b1ec32bd1a 100644 --- a/include/llvm/MC/MCObjectFileInfo.h +++ b/include/llvm/MC/MCObjectFileInfo.h @@ -194,8 +194,8 @@ protected: MCSection *SXDataSection; public: - void InitMCObjectFileInfo(const Triple &TT, Reloc::Model RM, - CodeModel::Model CM, MCContext &ctx); + void InitMCObjectFileInfo(const Triple &TT, bool PIC, CodeModel::Model CM, + MCContext &ctx); bool getSupportsWeakOmittedEHFrame() const { return SupportsWeakOmittedEHFrame; @@ -347,11 +347,11 @@ public: enum Environment { IsMachO, IsELF, IsCOFF }; Environment getObjectFileType() const { return Env; } - Reloc::Model getRelocM() const { return RelocM; } + bool isPositionIndependent() const { return PositionIndependent; } private: Environment Env; - Reloc::Model RelocM; + bool PositionIndependent; CodeModel::Model CMModel; MCContext *Ctx; Triple TT; diff --git a/lib/MC/MCObjectFileInfo.cpp b/lib/MC/MCObjectFileInfo.cpp index 7d8bb89dfb1..059dcf2477e 100644 --- a/lib/MC/MCObjectFileInfo.cpp +++ b/lib/MC/MCObjectFileInfo.cpp @@ -177,7 +177,7 @@ void MCObjectFileInfo::initMachOMCObjectFileInfo(Triple T) { MachO::S_THREAD_LOCAL_VARIABLE_POINTERS, SectionKind::getMetadata()); - if (RelocM == Reloc::Static) { + if (!PositionIndependent) { StaticCtorSection = Ctx->getMachOSection("__TEXT", "__constructor", 0, SectionKind::getData()); StaticDtorSection = Ctx->getMachOSection("__TEXT", "__destructor", 0, @@ -313,18 +313,21 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(Triple T) { // Fallthrough if not using EHABI case Triple::ppc: case Triple::x86: - PersonalityEncoding = (RelocM == Reloc::PIC_) - ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 - : dwarf::DW_EH_PE_absptr; - LSDAEncoding = (RelocM == Reloc::PIC_) - ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 - : dwarf::DW_EH_PE_absptr; - TTypeEncoding = (RelocM == Reloc::PIC_) - ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 - : dwarf::DW_EH_PE_absptr; + PersonalityEncoding = PositionIndependent + ? dwarf::DW_EH_PE_indirect | + dwarf::DW_EH_PE_pcrel | + dwarf::DW_EH_PE_sdata4 + : dwarf::DW_EH_PE_absptr; + LSDAEncoding = PositionIndependent + ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 + : dwarf::DW_EH_PE_absptr; + TTypeEncoding = PositionIndependent + ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | + dwarf::DW_EH_PE_sdata4 + : dwarf::DW_EH_PE_absptr; break; case Triple::x86_64: - if (RelocM == Reloc::PIC_) { + if (PositionIndependent) { PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium) ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8); @@ -349,7 +352,7 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(Triple T) { LSDAEncoding = dwarf::DW_EH_PE_absptr; FDECFIEncoding = dwarf::DW_EH_PE_absptr; TTypeEncoding = dwarf::DW_EH_PE_absptr; - if (RelocM == Reloc::PIC_){ + if (PositionIndependent) { PersonalityEncoding |= dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel; LSDAEncoding |= dwarf::DW_EH_PE_pcrel; FDECFIEncoding |= dwarf::DW_EH_PE_pcrel; @@ -361,7 +364,7 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(Triple T) { // The small model guarantees static code/data size < 4GB, but not where it // will be in memory. Most of these could end up >2GB away so even a signed // pc-relative 32-bit address is insufficient, theoretically. - if (RelocM == Reloc::PIC_) { + if (PositionIndependent) { PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8; LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8; @@ -403,7 +406,7 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(Triple T) { break; case Triple::sparcel: case Triple::sparc: - if (RelocM == Reloc::PIC_) { + if (PositionIndependent) { LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; @@ -417,7 +420,7 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(Triple T) { break; case Triple::sparcv9: LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; - if (RelocM == Reloc::PIC_) { + if (PositionIndependent) { PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | @@ -430,7 +433,7 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(Triple T) { case Triple::systemz: // All currently-defined code models guarantee that 4-byte PC-relative // values will be in range. - if (RelocM == Reloc::PIC_) { + if (PositionIndependent) { PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; @@ -824,11 +827,10 @@ void MCObjectFileInfo::initCOFFMCObjectFileInfo(Triple T) { SectionKind::getReadOnly()); } -void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, - Reloc::Model relocm, +void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, bool PIC, CodeModel::Model cm, MCContext &ctx) { - RelocM = relocm; + PositionIndependent = PIC; CMModel = cm; Ctx = &ctx; diff --git a/lib/Object/IRObjectFile.cpp b/lib/Object/IRObjectFile.cpp index 46012b7ed48..5c943be459b 100644 --- a/lib/Object/IRObjectFile.cpp +++ b/lib/Object/IRObjectFile.cpp @@ -79,7 +79,7 @@ void IRObjectFile::CollectAsmUndefinedRefs( MCObjectFileInfo MOFI; MCContext MCCtx(MAI.get(), MRI.get(), &MOFI); - MOFI.InitMCObjectFileInfo(TT, Reloc::Default, CodeModel::Default, MCCtx); + MOFI.InitMCObjectFileInfo(TT, /*PIC*/ false, CodeModel::Default, MCCtx); std::unique_ptr Streamer(new RecordStreamer(MCCtx)); T->createNullTargetStreamer(*Streamer); diff --git a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index 2c51a592eee..00e0b3b7e00 100644 --- a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -433,8 +433,7 @@ public: CurrentFn = nullptr; - IsPicEnabled = - (getContext().getObjectFileInfo()->getRelocM() == Reloc::PIC_); + IsPicEnabled = getContext().getObjectFileInfo()->isPositionIndependent(); IsCpRestoreSet = false; CpRestoreOffset = -1; diff --git a/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp index b24d7ae596f..bd614c1f737 100644 --- a/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp +++ b/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp @@ -668,7 +668,7 @@ MipsTargetELFStreamer::MipsTargetELFStreamer(MCStreamer &S, // covers all cases so this statement covers most cases and direct object // emission must call setPic() once MCObjectFileInfo has been initialized. The // cases we don't handle here are covered by MipsAsmPrinter. - Pic = MCA.getContext().getObjectFileInfo()->getRelocM() == Reloc::PIC_; + Pic = MCA.getContext().getObjectFileInfo()->isPositionIndependent(); const FeatureBitset &Features = STI.getFeatureBits(); diff --git a/lib/Target/Mips/MipsAsmPrinter.cpp b/lib/Target/Mips/MipsAsmPrinter.cpp index 24afb8863a6..2809f47e9fb 100644 --- a/lib/Target/Mips/MipsAsmPrinter.cpp +++ b/lib/Target/Mips/MipsAsmPrinter.cpp @@ -674,7 +674,7 @@ void MipsAsmPrinter::EmitStartOfAsmFile(Module &M) { // MipsTargetStreamer has an initialization order problem when emitting an // object file directly (see MipsTargetELFStreamer for full details). Work // around it by re-initializing the PIC state here. - TS.setPic(OutContext.getObjectFileInfo()->getRelocM()); + TS.setPic(OutContext.getObjectFileInfo()->isPositionIndependent()); // Compute MIPS architecture attributes based on the default subtarget // that we'd have constructed. Module level directives aren't LTO diff --git a/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp b/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp index 16638544335..b2003b8f101 100644 --- a/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp +++ b/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp @@ -899,8 +899,7 @@ SparcAsmParser::parseSparcAsmOperand(std::unique_ptr &Op, const MCExpr *Res = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_None, getContext()); - if (isCall && - getContext().getObjectFileInfo()->getRelocM() == Reloc::PIC_) + if (isCall && getContext().getObjectFileInfo()->isPositionIndependent()) Res = SparcMCExpr::create(SparcMCExpr::VK_Sparc_WPLT30, Res, getContext()); Op = SparcOperand::CreateImm(Res, S, E); @@ -1221,7 +1220,7 @@ SparcAsmParser::adjustPICRelocation(SparcMCExpr::VariantKind VK, // actually a %pc10 or %pc22 relocation. Otherwise, they are interpreted // as %got10 or %got22 relocation. - if (getContext().getObjectFileInfo()->getRelocM() == Reloc::PIC_) { + if (getContext().getObjectFileInfo()->isPositionIndependent()) { switch(VK) { default: break; case SparcMCExpr::VK_Sparc_LO: diff --git a/lib/Target/TargetLoweringObjectFile.cpp b/lib/Target/TargetLoweringObjectFile.cpp index 4169237aa30..b2b69025851 100644 --- a/lib/Target/TargetLoweringObjectFile.cpp +++ b/lib/Target/TargetLoweringObjectFile.cpp @@ -43,7 +43,8 @@ using namespace llvm; void TargetLoweringObjectFile::Initialize(MCContext &ctx, const TargetMachine &TM) { Ctx = &ctx; - InitMCObjectFileInfo(TM.getTargetTriple(), TM.getRelocationModel(), + InitMCObjectFileInfo(TM.getTargetTriple(), + TM.getRelocationModel() == Reloc::PIC_, TM.getCodeModel(), *Ctx); } diff --git a/test/MC/Mips/cprestore-noreorder-noat.s b/test/MC/Mips/cprestore-noreorder-noat.s index 0716145effa..25ceac1c63a 100644 --- a/test/MC/Mips/cprestore-noreorder-noat.s +++ b/test/MC/Mips/cprestore-noreorder-noat.s @@ -1,17 +1,17 @@ -# RUN: not llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=pic -filetype=obj \ +# RUN: not llvm-mc %s -arch=mips -mcpu=mips32 --position-independent -filetype=obj \ # RUN: -o /dev/null 2>&1 | FileCheck %s -check-prefix=O32 -# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -relocation-model=pic \ +# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 \ # RUN: -filetype=obj -o /dev/null 2>&1 | FileCheck %s -allow-empty -check-prefix=N32 -# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -relocation-model=pic -target-abi=n32 \ +# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi=n32 \ # RUN: -filetype=obj -o /dev/null 2>&1 | FileCheck %s -allow-empty -check-prefix=N64 -# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -relocation-model=pic -target-abi=n32 \ +# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi=n32 \ # RUN: -filetype=obj -o - | llvm-objdump -d -r - | \ # RUN: FileCheck %s -check-prefix=NO-STORE -# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -relocation-model=pic -filetype=obj -o - | \ +# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -filetype=obj -o - | \ # RUN: llvm-objdump -d -r - | \ # RUN: FileCheck %s -check-prefix=NO-STORE diff --git a/test/MC/Mips/cprestore-noreorder.s b/test/MC/Mips/cprestore-noreorder.s index 4c2213301c2..1d1997493f5 100644 --- a/test/MC/Mips/cprestore-noreorder.s +++ b/test/MC/Mips/cprestore-noreorder.s @@ -1,20 +1,20 @@ -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=pic -show-encoding | \ +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 --position-independent -show-encoding | \ # RUN: FileCheck %s -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=pic -filetype=obj -o -| \ +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 --position-independent -filetype=obj -o -| \ # RUN: llvm-objdump -d -r -arch=mips - | \ # RUN: FileCheck %s -check-prefix=CHECK-FOR-STORE -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -mattr=+micromips -relocation-model=pic -show-encoding | \ +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -mattr=+micromips --position-independent -show-encoding | \ # RUN: FileCheck %s -check-prefix=MICROMIPS -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=static -show-encoding | \ +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -show-encoding | \ # RUN: FileCheck %s -check-prefix=NO-PIC -# RUN: llvm-mc %s -arch=mips -mcpu=mips64 -target-abi n32 -relocation-model=pic -show-encoding | \ +# RUN: llvm-mc %s -arch=mips -mcpu=mips64 -target-abi n32 --position-independent -show-encoding | \ # RUN: FileCheck %s -check-prefix=BAD-ABI -check-prefix=BAD-ABI-N32 -# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n64 -relocation-model=pic -show-encoding | \ +# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n64 --position-independent -show-encoding | \ # RUN: FileCheck %s -check-prefix=BAD-ABI -check-prefix=BAD-ABI-N64 .text diff --git a/test/MC/Mips/cprestore-reorder.s b/test/MC/Mips/cprestore-reorder.s index d9e9a4cdcaf..eeb4e8e99c7 100644 --- a/test/MC/Mips/cprestore-reorder.s +++ b/test/MC/Mips/cprestore-reorder.s @@ -1,20 +1,20 @@ -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=pic -show-encoding | \ +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 --position-independent -show-encoding | \ # RUN: FileCheck %s -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=pic -filetype=obj -o -| \ +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 --position-independent -filetype=obj -o -| \ # RUN: llvm-objdump -d -r -arch=mips - | \ # RUN: FileCheck %s -check-prefix=CHECK-FOR-STORE -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -mattr=+micromips -relocation-model=pic -show-encoding | \ +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -mattr=+micromips --position-independent -show-encoding | \ # RUN: FileCheck %s -check-prefix=MICROMIPS -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=static -show-encoding | \ +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -show-encoding | \ # RUN: FileCheck %s -check-prefix=NO-PIC -# RUN: llvm-mc %s -arch=mips -mcpu=mips64 -target-abi n32 -relocation-model=pic -show-encoding | \ +# RUN: llvm-mc %s -arch=mips -mcpu=mips64 -target-abi n32 --position-independent -show-encoding | \ # RUN: FileCheck %s -check-prefix=BAD-ABI -check-prefix=BAD-ABI-N32 -# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n64 -relocation-model=pic -show-encoding | \ +# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n64 --position-independent -show-encoding | \ # RUN: FileCheck %s -check-prefix=BAD-ABI -check-prefix=BAD-ABI-N64 .text diff --git a/test/MC/Mips/cprestore-warning-unused.s b/test/MC/Mips/cprestore-warning-unused.s index 41a5df71597..e4999b48fb9 100644 --- a/test/MC/Mips/cprestore-warning-unused.s +++ b/test/MC/Mips/cprestore-warning-unused.s @@ -1,4 +1,4 @@ -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=pic 2>%t1 +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 --position-independent 2>%t1 # RUN: FileCheck %s < %t1 .text diff --git a/test/MC/Mips/init-order-bug.ll b/test/MC/Mips/init-order-bug.ll index 9682dce97e9..5e972624787 100644 --- a/test/MC/Mips/init-order-bug.ll +++ b/test/MC/Mips/init-order-bug.ll @@ -1,5 +1,5 @@ ; RUN: llc -mtriple=mipsel-linux-gnu -relocation-model=pic -filetype=asm < %s | \ -; RUN: llvm-mc -triple=mipsel-linux-gnu -relocation-model=pic -filetype=obj | \ +; RUN: llvm-mc -triple=mipsel-linux-gnu --position-independent -filetype=obj | \ ; RUN: llvm-objdump -d - | FileCheck %s ; RUN: llc -mtriple=mipsel-linux-gnu -relocation-model=pic -filetype=obj < %s | \ ; RUN: llvm-objdump -d - | FileCheck %s diff --git a/test/MC/Sparc/sparc-pic.s b/test/MC/Sparc/sparc-pic.s index 1c935e0842c..f51e1e93b50 100644 --- a/test/MC/Sparc/sparc-pic.s +++ b/test/MC/Sparc/sparc-pic.s @@ -1,5 +1,5 @@ -! RUN: llvm-mc %s -arch=sparcv9 --relocation-model=pic -filetype=obj | llvm-readobj -r | FileCheck --check-prefix=PIC %s -! RUN: llvm-mc %s -arch=sparcv9 --relocation-model=static -filetype=obj | llvm-readobj -r | FileCheck --check-prefix=NOPIC %s +! RUN: llvm-mc %s -arch=sparcv9 --position-independent -filetype=obj | llvm-readobj -r | FileCheck --check-prefix=PIC %s +! RUN: llvm-mc %s -arch=sparcv9 -filetype=obj | llvm-readobj -r | FileCheck --check-prefix=NOPIC %s ! PIC: Relocations [ diff --git a/tools/dsymutil/DwarfLinker.cpp b/tools/dsymutil/DwarfLinker.cpp index f4868f35fca..efbad915a2f 100644 --- a/tools/dsymutil/DwarfLinker.cpp +++ b/tools/dsymutil/DwarfLinker.cpp @@ -595,8 +595,7 @@ bool DwarfStreamer::init(Triple TheTriple, StringRef OutputFilename) { MOFI.reset(new MCObjectFileInfo); MC.reset(new MCContext(MAI.get(), MRI.get(), MOFI.get())); - MOFI->InitMCObjectFileInfo(TheTriple, Reloc::Default, CodeModel::Default, - *MC); + MOFI->InitMCObjectFileInfo(TheTriple, /*PIC*/ false, CodeModel::Default, *MC); MAB = TheTarget->createMCAsmBackend(*MRI, TripleName, ""); if (!MAB) diff --git a/tools/llvm-dwp/llvm-dwp.cpp b/tools/llvm-dwp/llvm-dwp.cpp index 1f3bb786d41..5dbe4162ef5 100644 --- a/tools/llvm-dwp/llvm-dwp.cpp +++ b/tools/llvm-dwp/llvm-dwp.cpp @@ -616,7 +616,7 @@ int main(int argc, char **argv) { MCObjectFileInfo MOFI; MCContext MC(MAI.get(), MRI.get(), &MOFI); - MOFI.InitMCObjectFileInfo(TheTriple, Reloc::Default, CodeModel::Default, MC); + MOFI.InitMCObjectFileInfo(TheTriple, /*PIC*/ false, CodeModel::Default, MC); auto MAB = TheTarget->createMCAsmBackend(*MRI, TripleName, ""); if (!MAB) diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index b706c53299f..9ea8f2ef433 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -115,20 +115,8 @@ MAttrs("mattr", cl::desc("Target specific attributes (-mattr=help for details)"), cl::value_desc("a1,+a2,-a3,...")); -static cl::opt -RelocModel("relocation-model", - cl::desc("Choose relocation model"), - cl::init(Reloc::Default), - cl::values( - clEnumValN(Reloc::Default, "default", - "Target default relocation model"), - clEnumValN(Reloc::Static, "static", - "Non-relocatable code"), - clEnumValN(Reloc::PIC_, "pic", - "Fully relocatable, position independent code"), - clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic", - "Relocatable external references, non-relocatable code"), - clEnumValEnd)); +static cl::opt PIC("position-independent", + cl::desc("Position independent"), cl::init(false)); static cl::opt CMModel("code-model", @@ -432,7 +420,7 @@ int main(int argc, char **argv) { // MCObjectFileInfo needs a MCContext reference in order to initialize itself. MCObjectFileInfo MOFI; MCContext Ctx(MAI.get(), MRI.get(), &MOFI, &SrcMgr); - MOFI.InitMCObjectFileInfo(TheTriple, RelocModel, CMModel, Ctx); + MOFI.InitMCObjectFileInfo(TheTriple, PIC, CMModel, Ctx); if (SaveTempLabels) Ctx.setAllowTemporaryLabels(false);