diff options
| author | Amit Aryeh Levy <amit@amitlevy.com> | 2017-04-25 20:05:51 -0400 |
|---|---|---|
| committer | Amit Aryeh Levy <amit@amitlevy.com> | 2017-04-26 16:25:14 -0400 |
| commit | 32b92669e4ec83005eff2641b092f25be09373b8 (patch) | |
| tree | 5eca497d01aefde890278f554e28f9e00165b548 | |
| parent | b0a4074c5e87d24ff630f6aa456a64698bff3ed2 (diff) | |
| download | rust-32b92669e4ec83005eff2641b092f25be09373b8.tar.gz rust-32b92669e4ec83005eff2641b092f25be09373b8.zip | |
Add RWPI/ROPI relocation model support
Adds support for using LLVM 4's ROPI and RWPI relocation models for ARM
| -rw-r--r-- | src/librustc_llvm/ffi.rs | 3 | ||||
| -rw-r--r-- | src/librustc_trans/back/write.rs | 5 | ||||
| -rw-r--r-- | src/rustllvm/PassWrapper.cpp | 19 |
3 files changed, 22 insertions, 5 deletions
diff --git a/src/librustc_llvm/ffi.rs b/src/librustc_llvm/ffi.rs index 402166cc13f..a9a8ee93df1 100644 --- a/src/librustc_llvm/ffi.rs +++ b/src/librustc_llvm/ffi.rs @@ -288,6 +288,9 @@ pub enum RelocMode { Static = 1, PIC = 2, DynamicNoPic = 3, + ROPI = 4, + RWPI = 5, + ROPI_RWPI = 6, } /// LLVMRustCodeModel diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index ccb3f7ac882..3492403a1bf 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -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] = [ diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index c410a6b1349..1e19e28e78a 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -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; |
