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:
parent
b0a4074c5e
commit
32b92669e4
3 changed files with 22 additions and 5 deletions
|
@ -288,6 +288,9 @@ pub enum RelocMode {
|
|||
Static = 1,
|
||||
PIC = 2,
|
||||
DynamicNoPic = 3,
|
||||
ROPI = 4,
|
||||
RWPI = 5,
|
||||
ROPI_RWPI = 6,
|
||||
}
|
||||
|
||||
/// LLVMRustCodeModel
|
||||
|
|
|
@ -37,11 +37,14 @@ use std::sync::mpsc::channel;
|
|||
use std::thread;
|
||||
use libc::{c_uint, c_void};
|
||||
|
||||
pub const RELOC_MODEL_ARGS : [(&'static str, llvm::RelocMode); 4] = [
|
||||
pub const RELOC_MODEL_ARGS : [(&'static str, llvm::RelocMode); 7] = [
|
||||
("pic", llvm::RelocMode::PIC),
|
||||
("static", llvm::RelocMode::Static),
|
||||
("default", llvm::RelocMode::Default),
|
||||
("dynamic-no-pic", llvm::RelocMode::DynamicNoPic),
|
||||
("ropi", llvm::RelocMode::ROPI),
|
||||
("rwpi", llvm::RelocMode::RWPI),
|
||||
("ropi-rwpi", llvm::RelocMode::ROPI_RWPI),
|
||||
];
|
||||
|
||||
pub const CODE_GEN_MODEL_ARGS : [(&'static str, llvm::CodeModel); 5] = [
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue