summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/include/lld/Core/Resolver.h2
-rw-r--r--lld/lib/Core/Resolver.cpp18
-rw-r--r--lld/lib/Driver/WinLinkDriver.cpp11
-rw-r--r--lld/test/pecoff/entry.test7
-rw-r--r--lld/unittests/DriverTests/WinLinkDriverTest.cpp2
5 files changed, 17 insertions, 23 deletions
diff --git a/lld/include/lld/Core/Resolver.h b/lld/include/lld/Core/Resolver.h
index 82b8b7331b4..7ffd3523b50 100644
--- a/lld/include/lld/Core/Resolver.h
+++ b/lld/include/lld/Core/Resolver.h
@@ -71,7 +71,7 @@ private:
/// \brief The main function that iterates over the files to resolve
bool resolveUndefines();
void updateReferences();
- bool deadStripOptimize();
+ void deadStripOptimize();
bool checkUndefines(bool final);
void removeCoalescedAwayAtoms();
void checkDylibSymbolCollisions();
diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp
index 7fdb6f5aa79..3a34cd3fe3f 100644
--- a/lld/lib/Core/Resolver.cpp
+++ b/lld/lib/Core/Resolver.cpp
@@ -363,11 +363,11 @@ void Resolver::markLive(const Atom &atom) {
// remove all atoms not actually used
-bool Resolver::deadStripOptimize() {
+void Resolver::deadStripOptimize() {
ScopedTask task(getDefaultDomain(), "deadStripOptimize");
// only do this optimization with -dead_strip
if (!_context.deadStrip())
- return true;
+ return;
// clear liveness on all atoms
_liveAtoms.clear();
@@ -386,11 +386,11 @@ bool Resolver::deadStripOptimize() {
// Or, use list of names that are dead stip roots.
for (const StringRef &name : _context.deadStripRoots()) {
const Atom *symAtom = _symbolTable.findByName(name);
- if (!symAtom || symAtom->definition() == Atom::definitionUndefined) {
- llvm::errs() << "Dead strip root '" << symAtom->name()
- << "' is not defined\n";
- return false;
- }
+ assert(symAtom);
+ if (symAtom->definition() == Atom::definitionUndefined)
+ // Dead-strip root atoms can be undefined at this point only when
+ // allowUndefines flag is on. Skip such undefines.
+ continue;
_deadStripRoots.insert(symAtom);
}
@@ -402,7 +402,6 @@ bool Resolver::deadStripOptimize() {
// now remove all non-live atoms from _atoms
_atoms.erase(std::remove_if(_atoms.begin(), _atoms.end(),
NotLive(_liveAtoms)), _atoms.end());
- return true;
}
@@ -474,8 +473,7 @@ bool Resolver::resolve() {
if (!this->resolveUndefines())
return false;
this->updateReferences();
- if (!this->deadStripOptimize())
- return false;
+ this->deadStripOptimize();
if (this->checkUndefines(false)) {
if (!_context.allowRemainingUndefines())
return false;
diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp
index 0c9f177b462..644fc0ac9eb 100644
--- a/lld/lib/Driver/WinLinkDriver.cpp
+++ b/lld/lib/Driver/WinLinkDriver.cpp
@@ -501,10 +501,15 @@ WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ctx,
// symbols given by /include to the dead strip root set, so that it
// won't be removed from the output.
if (ctx.deadStrip()) {
- if (!ctx.entrySymbolName().empty())
- ctx.addDeadStripRoot(ctx.entrySymbolName());
- for (const StringRef symbolName : ctx.initialUndefinedSymbols())
+ StringRef entry = ctx.entrySymbolName();
+ if (!entry.empty()) {
+ ctx.addInitialUndefinedSymbol(entry);
+ ctx.addDeadStripRoot(entry);
+ }
+ for (const StringRef symbolName : ctx.initialUndefinedSymbols()) {
+ ctx.addInitialUndefinedSymbol(entry);
ctx.addDeadStripRoot(symbolName);
+ }
}
// Arguments after "--" are interpreted as filenames even if they
diff --git a/lld/test/pecoff/entry.test b/lld/test/pecoff/entry.test
index e7f5d1f7ee4..deee5ed825a 100644
--- a/lld/test/pecoff/entry.test
+++ b/lld/test/pecoff/entry.test
@@ -7,10 +7,3 @@
# RUN: FileCheck -check-prefix=CHECK %s < %t1.log
CHECK: : _main
-
-
-# RUN: not lld -flavor link /out:%t2.exe /subsystem:console \
-# RUN: /entry:no_such_symbol /force -- %t.obj >& %t2.log
-# RUN: FileCheck -check-prefix=FAIL %s < %t2.log
-
-FAIL: Dead strip root '_no_such_symbol' is not defined
diff --git a/lld/unittests/DriverTests/WinLinkDriverTest.cpp b/lld/unittests/DriverTests/WinLinkDriverTest.cpp
index 9f801de1899..56cc487d857 100644
--- a/lld/unittests/DriverTests/WinLinkDriverTest.cpp
+++ b/lld/unittests/DriverTests/WinLinkDriverTest.cpp
@@ -224,8 +224,6 @@ TEST_F(WinLinkParserTest, Include) {
auto symbols = _context.initialUndefinedSymbols();
EXPECT_FALSE(symbols.empty());
EXPECT_EQ("foo", symbols[0]);
- symbols.pop_front();
- EXPECT_TRUE(symbols.empty());
}
//
OpenPOWER on IntegriCloud