mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-02 18:58:15 +00:00
Pass the relocation model to LLVM for assembler files.
llvm-svn: 247981
This commit is contained in:
parent
020296a968
commit
924f6ad63d
@ -463,6 +463,7 @@ TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) {
|
||||
FeaturesStr = Features.getString();
|
||||
}
|
||||
|
||||
// Keep this synced with the equivalent code in tools/driver/cc1as_main.cpp.
|
||||
llvm::Reloc::Model RM = llvm::Reloc::Default;
|
||||
if (CodeGenOpts.RelocationModel == "static") {
|
||||
RM = llvm::Reloc::Static;
|
||||
|
@ -126,6 +126,9 @@ struct AssemblerInvocation {
|
||||
unsigned NoExecStack : 1;
|
||||
unsigned FatalWarnings : 1;
|
||||
|
||||
/// The name of the relocation model to use.
|
||||
std::string RelocationModel;
|
||||
|
||||
/// @}
|
||||
|
||||
public:
|
||||
@ -248,6 +251,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
|
||||
Opts.RelaxAll = Args.hasArg(OPT_mrelax_all);
|
||||
Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
|
||||
Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
|
||||
Opts.RelocationModel = Args.getLastArgValue(OPT_mrelocation_model, "pic");
|
||||
|
||||
return Success;
|
||||
}
|
||||
@ -321,8 +325,19 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
|
||||
std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
|
||||
|
||||
MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &SrcMgr);
|
||||
// FIXME: Assembler behavior can change with -static.
|
||||
MOFI->InitMCObjectFileInfo(Triple(Opts.Triple), Reloc::Default,
|
||||
|
||||
llvm::Reloc::Model RM = llvm::Reloc::Default;
|
||||
if (Opts.RelocationModel == "static") {
|
||||
RM = llvm::Reloc::Static;
|
||||
} else if (Opts.RelocationModel == "pic") {
|
||||
RM = llvm::Reloc::PIC_;
|
||||
} else {
|
||||
assert(Opts.RelocationModel == "dynamic-no-pic" &&
|
||||
"Invalid PIC model!");
|
||||
RM = llvm::Reloc::DynamicNoPIC;
|
||||
}
|
||||
|
||||
MOFI->InitMCObjectFileInfo(Triple(Opts.Triple), RM,
|
||||
CodeModel::Default, Ctx);
|
||||
if (Opts.SaveTemporaryLabels)
|
||||
Ctx.setAllowTemporaryLabels(false);
|
||||
|
Loading…
Reference in New Issue
Block a user