rust/src/librustc_llvm
bors 4cb396c680 Auto merge of #41560 - alevy:rwpi-ropi, r=eddyb
Add RWPI/ROPI relocation model support

This PR adds support for using LLVM 4's ROPI and RWPI relocation models for ARM.

ROPI (Read-Only Position Independence) and RWPI (Read-Write Position Independence) are two new relocation models in LLVM for the ARM backend ([LLVM changset](https://reviews.llvm.org/rL278015)). The motivation is that these are the specific strategies we use in userspace [Tock](https://www.tockos.org) apps, so supporting this is an important step (perhaps the final step, but can't confirm yet) in enabling userspace Rust processes.

## Explanation

ROPI makes all code and immutable accesses PC relative, but not assumed to be overriden at runtime (so for example, jumps are always relative).

RWPI uses a base register (`r9`) that stores the addresses of the GOT in memory so the runtime (e.g. a kernel) only adjusts r9 tell running code where the GOT is.

## Complications adding support in Rust

While this landed in LLVM master back in August, the header files in `llvm-c` have not been updated yet to reflect it. Rust replicates that header file's version of the `LLVMRelocMode` enum as the Rust enum `llvm::RelocMode` and uses an implicit cast in the ffi to translate from Rust's notion of the relocation model to the LLVM library's notion.

My workaround for this currently is to replace the `LLVMRelocMode` argument to `LLVMTargetMachineRef` with an int and using the hardcoded int representation of the `RelocMode` enum. This is A Bad Idea(tm), but I think very nearly the right thing.

Would a better alternative be to patch rust-llvm to support these enum variants (also a fairly trivial change)?
2017-05-01 17:23:09 +00:00
..
archive_ro.rs run rustfmt on librustc_llvm folder 2016-05-29 14:57:34 +05:30
build.rs Avoid the hexagon backend on old versions of LLVM 2017-04-25 22:59:31 -04:00
Cargo.lock [LLVM] Introduce a stable representation of DIFlags 2016-12-02 21:13:31 -05:00
Cargo.toml [LLVM] Introduce a stable representation of DIFlags 2016-12-02 21:13:31 -05:00
diagnostic.rs Don't assume llvm::StringRef is null terminated 2016-11-28 17:33:13 +01:00
ffi.rs Added LLVMRustRelocMode 2017-04-28 17:33:56 -05:00
lib.rs Add Hexagon support 2017-04-25 01:56:44 -04:00