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();


        
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to