[lld] r192771 - Propagate deadStripOptimize()'s failure to the caller.
Rui Ueyama
ruiu at google.com
Tue Oct 15 22:03:40 PDT 2013
Author: ruiu
Date: Wed Oct 16 00:03:39 2013
New Revision: 192771
URL: http://llvm.org/viewvc/llvm-project?rev=192771&view=rev
Log:
Propagate deadStripOptimize()'s failure to the caller.
We want to make the program to exit with non-zero exit code if there's an error
during dead stripping.
Modified:
lld/trunk/include/lld/Core/Resolver.h
lld/trunk/lib/Core/Resolver.cpp
lld/trunk/test/pecoff/entry.test
Modified: lld/trunk/include/lld/Core/Resolver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Resolver.h?rev=192771&r1=192770&r2=192771&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Resolver.h (original)
+++ lld/trunk/include/lld/Core/Resolver.h Wed Oct 16 00:03:39 2013
@@ -71,7 +71,7 @@ private:
/// \brief The main function that iterates over the files to resolve
bool resolveUndefines();
void updateReferences();
- void deadStripOptimize();
+ bool deadStripOptimize();
bool checkUndefines(bool final);
void removeCoalescedAwayAtoms();
void checkDylibSymbolCollisions();
Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=192771&r1=192770&r2=192771&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Wed Oct 16 00:03:39 2013
@@ -363,11 +363,11 @@ void Resolver::markLive(const Atom &atom
// remove all atoms not actually used
-void Resolver::deadStripOptimize() {
+bool Resolver::deadStripOptimize() {
ScopedTask task(getDefaultDomain(), "deadStripOptimize");
// only do this optimization with -dead_strip
if (!_context.deadStrip())
- return;
+ return true;
// clear liveness on all atoms
_liveAtoms.clear();
@@ -386,10 +386,10 @@ void 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->definition() == Atom::definitionUndefined) {
+ if (!symAtom || symAtom->definition() == Atom::definitionUndefined) {
llvm::errs() << "Dead strip root '" << symAtom->name()
<< "' is not defined\n";
- return;
+ return false;
}
_deadStripRoots.insert(symAtom);
}
@@ -402,6 +402,7 @@ void 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;
}
@@ -473,7 +474,8 @@ bool Resolver::resolve() {
if (!this->resolveUndefines())
return false;
this->updateReferences();
- this->deadStripOptimize();
+ if (!this->deadStripOptimize())
+ return false;
if (this->checkUndefines(false)) {
if (!_context.allowRemainingUndefines())
return false;
Modified: lld/trunk/test/pecoff/entry.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/entry.test?rev=192771&r1=192770&r2=192771&view=diff
==============================================================================
--- lld/trunk/test/pecoff/entry.test (original)
+++ lld/trunk/test/pecoff/entry.test Wed Oct 16 00:03:39 2013
@@ -2,8 +2,15 @@
# Verify that entry atom will not be dead-stripped.
# RUN: yaml2obj %p/Inputs/main.obj.yaml > %t.obj
-# RUN: lld -flavor link /mllvm:-debug-only=WriterPECOFF /out:%t.exe \
-# RUN: /subsystem:console /entry:_main /force -- %t.obj >& %t.log
-# RUN: FileCheck %s < %t.log
+# RUN: lld -flavor link /mllvm:-debug-only=WriterPECOFF /out:%t1.exe \
+# RUN: /subsystem:console /entry:main /force -- %t.obj >& %t1.log
+# 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
More information about the llvm-commits
mailing list