Skip to content

Commit

Permalink
[LLD][COFF] Reset outputSections for successive runs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
baszalmstra authored and mstorsjo committed Aug 22, 2020
1 parent 207d449 commit 54f5a4e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lld/COFF/Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,9 @@ void Writer::finalizeAddresses() {
void Writer::run() {
ScopedTimer t1(codeLayoutTimer);

// First, clear the output sections from previous runs
outputSections.clear();

createImportTables();
createSections();
createMiscChunks();
Expand Down

0 comments on commit 54f5a4e

Please sign in to comment.