[llvm-branch-commits] [lld] r351445 - Merging r351326:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jan 17 05:46:36 PST 2019
Author: hans
Date: Thu Jan 17 05:46:36 2019
New Revision: 351445
URL: http://llvm.org/viewvc/llvm-project?rev=351445&view=rev
Log:
Merging r351326:
------------------------------------------------------------------------
r351326 | psmith | 2019-01-16 13:09:13 +0100 (Wed, 16 Jan 2019) | 15 lines
[ELF] Implement option to force PIC compatible Thunks
By default LLD will generate position independent Thunks when the --pie or
--shared option is used. Reference to absolute addresses is permitted in
other cases. For some embedded systems position independent thunks are
needed for code that executes before the MMU has been set up. The option
--pic-veneer is used by ld.bfd to force position independent thunks.
The patch adds --pic-veneer as the option is needed for the Linux kernel
on Arm.
fixes pr39886
Differential Revision: https://reviews.llvm.org/D55505
------------------------------------------------------------------------
Added:
lld/branches/release_80/test/ELF/arm-force-pi-thunk.s
- copied unchanged from r351326, lld/trunk/test/ELF/arm-force-pi-thunk.s
Modified:
lld/branches/release_80/ (props changed)
lld/branches/release_80/ELF/Config.h
lld/branches/release_80/ELF/Driver.cpp
lld/branches/release_80/ELF/Options.td
lld/branches/release_80/ELF/Thunks.cpp
lld/branches/release_80/docs/ld.lld.1
Propchange: lld/branches/release_80/
------------------------------------------------------------------------------
svn:mergeinfo = /lld/trunk:351326
Modified: lld/branches/release_80/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_80/ELF/Config.h?rev=351445&r1=351444&r2=351445&view=diff
==============================================================================
--- lld/branches/release_80/ELF/Config.h (original)
+++ lld/branches/release_80/ELF/Config.h Thu Jan 17 05:46:36 2019
@@ -159,6 +159,7 @@ struct Configuration {
bool OFormatBinary;
bool Omagic;
bool OptRemarksWithHotness;
+ bool PicThunk;
bool Pie;
bool PrintGcSections;
bool PrintIcfSections;
Modified: lld/branches/release_80/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_80/ELF/Driver.cpp?rev=351445&r1=351444&r2=351445&view=diff
==============================================================================
--- lld/branches/release_80/ELF/Driver.cpp (original)
+++ lld/branches/release_80/ELF/Driver.cpp Thu Jan 17 05:46:36 2019
@@ -1006,6 +1006,7 @@ static void setConfigs(opt::InputArgList
Config->Endianness = Config->IsLE ? endianness::little : endianness::big;
Config->IsMips64EL = (K == ELF64LEKind && M == EM_MIPS);
Config->Pic = Config->Pie || Config->Shared;
+ Config->PicThunk = Args.hasArg(OPT_pic_veneer, Config->Pic);
Config->Wordsize = Config->Is64 ? 8 : 4;
// ELF defines two different ways to store relocation addends as shown below:
Modified: lld/branches/release_80/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_80/ELF/Options.td?rev=351445&r1=351444&r2=351445&view=diff
==============================================================================
--- lld/branches/release_80/ELF/Options.td (original)
+++ lld/branches/release_80/ELF/Options.td Thu Jan 17 05:46:36 2019
@@ -255,6 +255,9 @@ defm use_android_relr_tags: B<"use-andro
"Use SHT_ANDROID_RELR / DT_ANDROID_RELR* tags instead of SHT_RELR / DT_RELR*",
"Use SHT_RELR / DT_RELR* tags (default)">;
+def pic_veneer: F<"pic-veneer">,
+ HelpText<"Always generate position independent thunks (veneers)">;
+
defm pie: B<"pie",
"Create a position independent executable",
"Do not create a position independent executable (default)">;
Modified: lld/branches/release_80/ELF/Thunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_80/ELF/Thunks.cpp?rev=351445&r1=351444&r2=351445&view=diff
==============================================================================
--- lld/branches/release_80/ELF/Thunks.cpp (original)
+++ lld/branches/release_80/ELF/Thunks.cpp Thu Jan 17 05:46:36 2019
@@ -722,7 +722,7 @@ Thunk::~Thunk() = default;
static Thunk *addThunkAArch64(RelType Type, Symbol &S) {
if (Type != R_AARCH64_CALL26 && Type != R_AARCH64_JUMP26)
fatal("unrecognized relocation type");
- if (Config->Pic)
+ if (Config->PicThunk)
return make<AArch64ADRPThunk>(S);
return make<AArch64ABSLongThunk>(S);
}
@@ -739,7 +739,7 @@ static Thunk *addThunkPreArmv7(RelType R
case R_ARM_JUMP24:
case R_ARM_CALL:
case R_ARM_THM_CALL:
- if (Config->Pic)
+ if (Config->PicThunk)
return make<ARMV5PILongThunk>(S);
return make<ARMV5ABSLongThunk>(S);
}
@@ -794,13 +794,13 @@ static Thunk *addThunkArm(RelType Reloc,
case R_ARM_PLT32:
case R_ARM_JUMP24:
case R_ARM_CALL:
- if (Config->Pic)
+ if (Config->PicThunk)
return make<ARMV7PILongThunk>(S);
return make<ARMV7ABSLongThunk>(S);
case R_ARM_THM_JUMP19:
case R_ARM_THM_JUMP24:
case R_ARM_THM_CALL:
- if (Config->Pic)
+ if (Config->PicThunk)
return make<ThumbV7PILongThunk>(S);
return make<ThumbV7ABSLongThunk>(S);
}
@@ -820,7 +820,7 @@ static Thunk *addThunkPPC64(RelType Type
if (S.isInPlt())
return make<PPC64PltCallStub>(S);
- if (Config->Pic)
+ if (Config->PicThunk)
return make<PPC64PILongBranchThunk>(S);
return make<PPC64PDLongBranchThunk>(S);
Modified: lld/branches/release_80/docs/ld.lld.1
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_80/docs/ld.lld.1?rev=351445&r1=351444&r2=351445&view=diff
==============================================================================
--- lld/branches/release_80/docs/ld.lld.1 (original)
+++ lld/branches/release_80/docs/ld.lld.1 Thu Jan 17 05:46:36 2019
@@ -311,6 +311,8 @@ Write optimization remarks in YAML forma
.Ar file .
.It Fl -opt-remarks-with-hotness
Include hotness information in the optimization remarks file.
+.It Fl -pic-veneer
+Always generate position independent thunks.
.It Fl -pie
Create a position independent executable.
.It Fl -print-gc-sections
More information about the llvm-branch-commits
mailing list