summaryrefslogtreecommitdiff
path: root/contrib/llvm
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-08-24 17:48:05 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-08-24 17:48:05 +0000
commita0d1f778057429ec7272dc81c1b61211602b1fa0 (patch)
treeeb5ec8dce140a92eb133905594db5e0b7c63d31f /contrib/llvm
parentf42813cfc824645a86e6dd8316418c7958e220c5 (diff)
downloadsrc-test2-a0d1f778057429ec7272dc81c1b61211602b1fa0.tar.gz
src-test2-a0d1f778057429ec7272dc81c1b61211602b1fa0.zip
Notes
Diffstat (limited to 'contrib/llvm')
-rw-r--r--contrib/llvm/tools/lld/ELF/Config.h1
-rw-r--r--contrib/llvm/tools/lld/ELF/Driver.cpp4
-rw-r--r--contrib/llvm/tools/lld/ELF/Relocations.cpp10
-rw-r--r--contrib/llvm/tools/lld/ELF/Writer.cpp5
4 files changed, 17 insertions, 3 deletions
diff --git a/contrib/llvm/tools/lld/ELF/Config.h b/contrib/llvm/tools/lld/ELF/Config.h
index 622324c13e2d..53f0852fa98f 100644
--- a/contrib/llvm/tools/lld/ELF/Config.h
+++ b/contrib/llvm/tools/lld/ELF/Config.h
@@ -181,6 +181,7 @@ struct Configuration {
bool ZCopyreloc;
bool ZExecstack;
bool ZHazardplt;
+ bool ZIfuncnoplt;
bool ZInitfirst;
bool ZKeepTextSectionPrefix;
bool ZNodelete;
diff --git a/contrib/llvm/tools/lld/ELF/Driver.cpp b/contrib/llvm/tools/lld/ELF/Driver.cpp
index 693dba64ab5a..b8be526d9424 100644
--- a/contrib/llvm/tools/lld/ELF/Driver.cpp
+++ b/contrib/llvm/tools/lld/ELF/Driver.cpp
@@ -338,7 +338,8 @@ static bool getZFlag(opt::InputArgList &Args, StringRef K1, StringRef K2,
static bool isKnown(StringRef S) {
return S == "combreloc" || S == "copyreloc" || S == "defs" ||
- S == "execstack" || S == "hazardplt" || S == "initfirst" ||
+ S == "execstack" || S == "hazardplt" || S == "ifunc-noplt" ||
+ S == "initfirst" ||
S == "keep-text-section-prefix" || S == "lazy" || S == "muldefs" ||
S == "nocombreloc" || S == "nocopyreloc" || S == "nodelete" ||
S == "nodlopen" || S == "noexecstack" ||
@@ -843,6 +844,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
Config->ZCopyreloc = getZFlag(Args, "copyreloc", "nocopyreloc", true);
Config->ZExecstack = getZFlag(Args, "execstack", "noexecstack", false);
Config->ZHazardplt = hasZOption(Args, "hazardplt");
+ Config->ZIfuncnoplt = hasZOption(Args, "ifunc-noplt");
Config->ZInitfirst = hasZOption(Args, "initfirst");
Config->ZKeepTextSectionPrefix = getZFlag(
Args, "keep-text-section-prefix", "nokeep-text-section-prefix", false);
diff --git a/contrib/llvm/tools/lld/ELF/Relocations.cpp b/contrib/llvm/tools/lld/ELF/Relocations.cpp
index 467219ad0542..5d7896a1b632 100644
--- a/contrib/llvm/tools/lld/ELF/Relocations.cpp
+++ b/contrib/llvm/tools/lld/ELF/Relocations.cpp
@@ -366,6 +366,10 @@ static bool isStaticLinkTimeConstant(RelExpr E, RelType Type, const Symbol &Sym,
R_TLSLD_HINT>(E))
return true;
+ // The computation involves output from the ifunc resolver.
+ if (Sym.isGnuIFunc() && Config->ZIfuncnoplt)
+ return false;
+
// These never do, except if the entire file is position dependent or if
// only the low bits are used.
if (E == R_GOT || E == R_PLT || E == R_TLSDESC)
@@ -816,6 +820,10 @@ static void processRelocAux(InputSectionBase &Sec, RelExpr Expr, RelType Type,
Sec.Relocations.push_back({Expr, Type, Offset, Addend, &Sym});
return;
}
+ if (Sym.isGnuIFunc() && Config->ZIfuncnoplt) {
+ InX::RelaDyn->addReloc(Type, &Sec, Offset, &Sym, Addend, R_ADDEND, Type);
+ return;
+ }
bool CanWrite = (Sec.Flags & SHF_WRITE) || !Config->ZText;
if (CanWrite) {
// R_GOT refers to a position in the got, even if the symbol is preemptible.
@@ -985,7 +993,7 @@ static void scanReloc(InputSectionBase &Sec, OffsetGetter &GetOffset, RelTy *&I,
// all dynamic symbols that can be resolved within the executable will
// actually be resolved that way at runtime, because the main exectuable
// is always at the beginning of a search list. We can leverage that fact.
- if (Sym.isGnuIFunc())
+ if (Sym.isGnuIFunc() && !Config->ZIfuncnoplt)
Expr = toPlt(Expr);
else if (!Sym.IsPreemptible && Expr == R_GOT_PC && !isAbsoluteValue(Sym))
Expr = Target->adjustRelaxExpr(Type, RelocatedAddr, Expr);
diff --git a/contrib/llvm/tools/lld/ELF/Writer.cpp b/contrib/llvm/tools/lld/ELF/Writer.cpp
index 88a2d5c71266..d9f445c29235 100644
--- a/contrib/llvm/tools/lld/ELF/Writer.cpp
+++ b/contrib/llvm/tools/lld/ELF/Writer.cpp
@@ -1561,8 +1561,11 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
applySynthetic({InX::EhFrame},
[](SyntheticSection *SS) { SS->finalizeContents(); });
- for (Symbol *S : Symtab->getSymbols())
+ for (Symbol *S : Symtab->getSymbols()) {
S->IsPreemptible |= computeIsPreemptible(*S);
+ if (S->isGnuIFunc() && Config->ZIfuncnoplt)
+ S->ExportDynamic = true;
+ }
// Scan relocations. This must be done after every symbol is declared so that
// we can correctly decide if a dynamic relocation is needed.