Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Default to PIC code on Linux #1664
Conversation
JohanEngelen
reviewed
Aug 2, 2016
| @@ -530,6 +530,10 @@ llvm::TargetMachine *createTargetMachine( | ||
| relocModel = llvm::Reloc::PIC_; | ||
| } else if (triple.getEnvironment() == llvm::Triple::Android) { | ||
| relocModel = llvm::Reloc::PIC_; | ||
| + } else if (triple.getOS() == llvm::Triple::Linux) { |
ximion
Aug 2, 2016
Contributor
Will isOSLinux be true for Android too? (because in theory, the triplet should be something like <arch>-linux-android for Android (and <arch>-linux-gnu for traditional distros).
I don't know how LLVM handles this.
ximion
Aug 2, 2016
Contributor
The docs answer this: It's exactly as I expected and we can assume a Linux OSType for Android as well (which makes the code a bit simpler).
PR is updated, thanks!
|
I'll manually merge this once green to tweak the comment a little bit – thanks for the patch! |
|
(The issue is not that Ubuntu 16.10 et al. "compile their toolchain with PIC for additional security", but that they set GCC to produce position-independent executables by default.) |
|
Right, what I was actually wanting to write there was "have their toolchain output PIC code" :) |
klickverbot
merged commit 8fcd497
into
ldc-developers:master
Aug 3, 2016
klickverbot
added this to the 1.1.0 milestone
Aug 3, 2016
|
@redstar This is important to mention in the release notes. At least one project fails to build after this change, so it's good to know what to look for. |
|
@redstar I see you already added something about it to 1.1.0-beta3 release notes. I will add a little more. |
How does this break stuff? |
|
Ah, Weka's binary instrumentation? That's a bit of a special case. It certainly should be mentioned prominently, but the change shouldn't be very disruptive. |
ximion commentedAug 2, 2016
•
Edited 1 time
-
ximion
Aug 2, 2016
Modern Linux distributions have their toolchain generate PIC code for
additional security features (like ASLR).
Since there is no (sane) way to detect whether the toolchain defaults to
PIC code, we simply default to PIC code on all Linux
distributions to avoid linking issues on these OSes.
The relocation model can be switched back to non-PIC code manually at
any time.
This change resolves issue #1618