[llvm-branch-commits] [lld] 0c37a91 - [LLD][COFF] Reset outputSections for successive runs

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Aug 24 10:53:51 PDT 2020


Author: Bas Zalmstra
Date: 2020-08-24T19:52:49+02:00
New Revision: 0c37a9165611880b99b1f9632179864ecb3f2e13

URL: https://github.com/llvm/llvm-project/commit/0c37a9165611880b99b1f9632179864ecb3f2e13
DIFF: https://github.com/llvm/llvm-project/commit/0c37a9165611880b99b1f9632179864ecb3f2e13.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

(cherry picked from commit 54f5a4ea4c859cf7f34f0d4955abc3a2f44bd0dc)

Added: 
    

Modified: 
    lld/COFF/Writer.cpp

Removed: 
    


################################################################################
diff  --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 082de5b8c1d6..0188f0971a75 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -599,6 +599,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-branch-commits mailing list