[LLD][COFF] Reset outputSections for successive runs

The global variable outputSections in the COFF writer was not
cleared between runs which caused successive calls to lld::coff::link
to generate invalid binaries. These binaries when loaded would result
in "invalid win32 applications" and/or "bad image" errors.

Differential Revision: https://reviews.llvm.org/D86401
This commit is contained in:
Bas Zalmstra 2020-08-22 23:04:22 +03:00 committed by Martin Storsjö
parent 207d4499df
commit 54f5a4ea4c
1 changed files with 3 additions and 0 deletions

View File

@ -601,6 +601,9 @@ void Writer::finalizeAddresses() {
void Writer::run() { void Writer::run() {
ScopedTimer t1(codeLayoutTimer); ScopedTimer t1(codeLayoutTimer);
// First, clear the output sections from previous runs
outputSections.clear();
createImportTables(); createImportTables();
createSections(); createSections();
createMiscChunks(); createMiscChunks();