summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2019-06-10 12:16:41 +0000
committerRui Ueyama <ruiu@google.com>2019-06-10 12:16:41 +0000
commit1f73bbbd3a5bbe4baec841f20ac237011716fbdd (patch)
tree45495fee8a2966d050de89b85160ee59c9d9bf50
parent379aa18a39584e6956e9ebd9d574310eb4c731ba (diff)
downloadbcm5719-llvm-1f73bbbd3a5bbe4baec841f20ac237011716fbdd.tar.gz
bcm5719-llvm-1f73bbbd3a5bbe4baec841f20ac237011716fbdd.zip
[LLD][COFF] Fix missing MergeChunk::Instances cleanup in COFF::link()
Patch by Erik McClure with a modification to rebase to HEAD. When calling `COFF::link()` with `CanExitEarly` set to `false`, the function needs to clean up several global variable caches to ensure that the next invocation of the function starts from a clean slate. The `MergeChunk::Instances` cache is missing from this cleanup code, and as a result will create nondeterministic memory access errors and sometimes infinite loops due to invalid memory being referenced on the next call to `COFF::link()`. This fix simply clears `MergeChunk::Instances` before exiting the function. An additional review of the COFF library was made to try and find any other missing global caches, but I was unable to find any other than `MergeChunk`. Someone more familiar with the global variables might want to do their own check. This fix was made to support inNative <https://github.com/innative-sdk/innative>'s `.wast` script compiler, which must build multiple incremental builds. It relies on statically linking LLD because the entire compiler must be a single statically embeddable library, thus preventing it from being able to call LLD as a new process. Differential Revision: https://reviews.llvm.org/D63042 llvm-svn: 362930
-rw-r--r--lld/COFF/Driver.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 19c87028f1c..45befa6a99a 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -81,6 +81,7 @@ bool link(ArrayRef<const char *> Args, bool CanExitEarly, raw_ostream &Diag) {
ObjFile::Instances.clear();
ImportFile::Instances.clear();
BitcodeFile::Instances.clear();
+ memset(MergeChunk::Instances, 0, sizeof(MergeChunk::Instances));
return !errorCount();
}
OpenPOWER on IntegriCloud