Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for building positions independent executables by default #22476

Closed
llvmbot opened this issue Jan 6, 2015 · 2 comments
Closed

add support for building positions independent executables by default #22476

llvmbot opened this issue Jan 6, 2015 · 2 comments
Labels
bugzilla Issues migrated from bugzilla clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 6, 2015

Bugzilla Link 22102
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @majnemer,@rnk

Extended Description

It's currently not possible to enable PIE (full ASLR) across the board without either patching the compiler or wrapping it behind a script. Other hardening flags can simply be set via CFLAGS/LDFLAGS as most build systems respect them.

The -fPIE switch needs to be passed when -f{no}-{pic,pie,PIC} is not and -pie needs to be passed for linking executables but not libraries along with some other exceptions. The list in the pending GCC patch is likely enough for Clang too:

https://gcc.gnu.org/ml/gcc-patches/2014-07/msg02231.html

Recent improvements to gcc/binutils (PIE copy relocs) means that PIE has ~0% overhead in most cases on x86_64 rather than ~1-5%, although this may not be implemented in LLVM yet. The main blocker to distributions taking advantage of it is simply making it easy to turn on.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jul 26, 2016

GCC now has support for this via ./configure --enable-default-pie in GCC6, and it is being adopted by Linux distributions.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
@nickdesaulniers
Copy link
Member

@MaskRay implemented CLANG_DEFAULT_PIE_ON_LINUX in commit 1042de9 ("[Driver] Add CLANG_DEFAULT_PIE_ON_LINUX to emulate GCC --enable-default-pie") since clang-14.

@MaskRay 's commit ca68038 ("Reland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON""")
sets CLANG_DEFAULT_PIE_ON_LINUX to y since clang-15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'
Projects
None yet
Development

No branches or pull requests

2 participants