summaryrefslogtreecommitdiff
path: root/lld/ELF/InputSection.cpp
diff options
context:
space:
mode:
authorSterling Augustine <saugustine@google.com>2018-08-13 22:29:15 +0000
committerSterling Augustine <saugustine@google.com>2018-08-13 22:29:15 +0000
commit27f1ad54add4e09769eaaecc4f46a7001c3908a2 (patch)
tree2d99ab57a97d32a91f6021b9819b1843cb8f4ff6 /lld/ELF/InputSection.cpp
parentd203707fd3928b12330d51ac9ef4aef48c5bd65c (diff)
Support shared objects for split stack.
Diffstat (limited to 'lld/ELF/InputSection.cpp')
-rw-r--r--lld/ELF/InputSection.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 48603a30e6a..801e2f86867 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -928,9 +928,8 @@ void InputSectionBase::adjustSplitStackFunctionPrologues(uint8_t *Buf,
continue;
// Ignore calls into the split-stack api.
- Defined *D = cast<Defined>(Rel.Sym);
- if (D->getName().startswith("__morestack")) {
- if (D->getName().equals("__morestack"))
+ if (Rel.Sym->getName().startswith("__morestack")) {
+ if (Rel.Sym->getName().equals("__morestack"))
MorestackCalls.push_back(&Rel);
continue;
}
@@ -938,13 +937,18 @@ void InputSectionBase::adjustSplitStackFunctionPrologues(uint8_t *Buf,
// A relocation to non-function isn't relevant. Sometimes
// __morestack is not marked as a function, so this check comes
// after the name check.
- if (D->Type != STT_FUNC)
+ if (Rel.Sym->Type != STT_FUNC)
continue;
- // If the callee's-file was compiled with split stack, nothing to do.
- auto *IS = cast_or_null<InputSection>(D->Section);
- if (!IS || IS->getFile<ELFT>()->SplitStack)
- continue;
+ // If the callee's-file was compiled with split stack, nothing to do. In
+ // this context, a "Defined" symbol is one "defined by the binary currently
+ // being produced". So an "undefined" symbol might be provided by a shared
+ // library. It is not possible to tell how such symbols were compiled, so be
+ // conservative.
+ if (Defined *D = dyn_cast<Defined>(Rel.Sym))
+ if (InputSection *IS = cast_or_null<InputSection>(D->Section))
+ if (!IS || IS->getFile<ELFT>()->SplitStack)
+ continue;
if (enclosingPrologueAttempted(Rel.Offset, Prologues))
continue;
@@ -956,7 +960,7 @@ void InputSectionBase::adjustSplitStackFunctionPrologues(uint8_t *Buf,
continue;
if (!getFile<ELFT>()->SomeNoSplitStack)
error(lld::toString(this) + ": " + F->getName() +
- " (with -fsplit-stack) calls " + D->getName() +
+ " (with -fsplit-stack) calls " + Rel.Sym->getName() +
" (without -fsplit-stack), but couldn't adjust its prologue");
}
}