Add RWPI/ROPI relocation model support

Adds support for using LLVM 4's ROPI and RWPI relocation models for ARM
This commit is contained in:
Amit Aryeh Levy 2017-04-25 20:05:51 -04:00
parent b0a4074c5e
commit 32b92669e4
3 changed files with 22 additions and 5 deletions

View file

@ -290,7 +290,7 @@ extern "C" void LLVMRustPrintTargetFeatures(LLVMTargetMachineRef) {
extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
const char *TripleStr, const char *CPU, const char *Feature,
LLVMRustCodeModel RustCM, LLVMRelocMode Reloc,
LLVMRustCodeModel RustCM, int Reloc,
LLVMRustCodeGenOptLevel RustOptLevel, bool UseSoftFloat,
bool PositionIndependentExecutable, bool FunctionSections,
bool DataSections) {
@ -304,15 +304,26 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
auto OptLevel = fromRust(RustOptLevel);
switch (Reloc) {
case LLVMRelocStatic:
case 1:
RM = Reloc::Static;
break;
case LLVMRelocPIC:
case 2:
RM = Reloc::PIC_;
break;
case LLVMRelocDynamicNoPic:
case 3:
RM = Reloc::DynamicNoPIC;
break;
#if LLVM_VERSION_GE(4, 0)
case 4:
RM = Reloc::ROPI;
break;
case 5:
RM = Reloc::RWPI;
break;
case 6:
RM = Reloc::ROPI_RWPI;
break;
#endif
default:
#if LLVM_VERSION_LE(3, 8)
RM = Reloc::Default;