[lld] 54f5a4e - [LLD][COFF] Reset outputSections for successive runs

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 22 13:08:53 PDT 2020


Author: Bas Zalmstra
Date: 2020-08-22T23:08:43+03:00
New Revision: 54f5a4ea4c859cf7f34f0d4955abc3a2f44bd0dc

URL: https://github.com/llvm/llvm-project/commit/54f5a4ea4c859cf7f34f0d4955abc3a2f44bd0dc
DIFF: https://github.com/llvm/llvm-project/commit/54f5a4ea4c859cf7f34f0d4955abc3a2f44bd0dc.diff

LOG: [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

Added: 
    

Modified: 
    lld/COFF/Writer.cpp

Removed: 
    


################################################################################
diff  --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 36ecdcd13512..82dff2e5bb62 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -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();


        


More information about the llvm-commits mailing list