Fix a bug that the empty string could be added to dead strip root.

llvm-svn: 192772
This commit is contained in:
Rui Ueyama 2013-10-16 05:06:52 +00:00
parent 2847831771
commit c726c1962d
2 changed files with 3 additions and 1 deletions

View File

@ -88,6 +88,7 @@ public:
/// deadStrip() returns true.
void addDeadStripRoot(StringRef symbolName) {
assert(_deadStrip && "only applicable when deadstripping enabled");
assert(!symbolName.empty() && "Empty symbol cannot be a dead strip root");
_deadStripRoots.push_back(symbolName);
}

View File

@ -501,7 +501,8 @@ 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()) {
ctx.addDeadStripRoot(ctx.entrySymbolName());
if (!ctx.entrySymbolName().empty())
ctx.addDeadStripRoot(ctx.entrySymbolName());
for (const StringRef symbolName : ctx.initialUndefinedSymbols())
ctx.addDeadStripRoot(symbolName);
}