diff options
author | Fangrui Song <maskray@google.com> | 2019-05-30 01:55:43 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2019-05-30 01:55:43 +0000 |
commit | 0666f9c4e44e0841e5f2f0913659505789604f1b (patch) | |
tree | a2b5481c2d44b277c60c717c1660f4a66ec598fb /clang/lib | |
parent | a05fda68bc5e6b42948a3e3ddf0df1e069c38c19 (diff) | |
download | bcm5719-llvm-0666f9c4e44e0841e5f2f0913659505789604f1b.tar.gz bcm5719-llvm-0666f9c4e44e0841e5f2f0913659505789604f1b.zip |
[Driver] -static-pie: add -z text
This matches gcc -static-pie. The intention is to prevent dynamic
relocations in read-only segments.
In ld.bfd and gold, -z notext is the default. If text relocations are needed:
* -z notext: allow and emit DF_TEXTREL.
DF_TEXTREL is not emitted if there is no text relocation.
* -z text: error
In lld, -z text is the default (this change is a no-op).
* -z text: error on text relocations
* -z notext: allow text relocations, and emit DF_TEXTREL no matter whether
text relocations exist.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D62606
llvm-svn: 362050
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Driver/ToolChains/Gnu.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index 30a61d5ad12..c8520968e45 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -382,6 +382,8 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-static"); CmdArgs.push_back("-pie"); CmdArgs.push_back("--no-dynamic-linker"); + CmdArgs.push_back("-z"); + CmdArgs.push_back("text"); } if (ToolChain.isNoExecStackDefault()) { |