<div dir="ltr">I think you want to call freeArena() before returning from lld::coff::link.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 15, 2017 at 6:57 PM, Andrew Kelley via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I believe this line is the culprit:<div><br></div><div>COFF/Driver.cpp:102:</div><div><div>  make<std::unique_ptr<<wbr>MemoryBuffer>>(std::move(MB)); // take ownership</div></div><div><br></div><div>Patch forthcoming.</div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 15, 2017 at 9:45 PM, Andrew Kelley <span dir="ltr"><<a href="mailto:superjoe30@gmail.com" target="_blank">superjoe30@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I've got a patched LLD 5.0.0 like this:<div><br></div><div><div>diff --git a/deps/lld/COFF/Driver.cpp b/deps/lld/COFF/Driver.cpp</div><div>index 854c3e69..8bab1c11 100644</div><div>--- a/deps/lld/COFF/Driver.cpp</div><div>+++ b/deps/lld/COFF/Driver.cpp</div><div>@@ -1030,7 +1030,7 @@ void LinkerDriver::link(ArrayRef<co<wbr>nst char *> ArgsArr) {</div><div>   if (!Args.hasArgNoClaim(OPT_INPUT<wbr>)) {</div><div>     fixupExports();</div><div>     createImportLibrary(/*AsLib=*<wbr>/true);</div><div>-    exit(0);</div><div>+    return;</div><div>   }</div><div><br></div><div>   // Handle /delayload</div><div>@@ -1172,9 +1172,6 @@ void LinkerDriver::link(ArrayRef<co<wbr>nst char *> ArgsArr) {</div><div><br></div><div>   // Write the result.</div><div>   writeResult(&Symtab);</div><div>-</div><div>-  // Call exit to avoid calling destructors.</div><div>-  exit(0);</div><div> }</div><div><br></div><div> } // namespace coff</div><div><br></div></div><div><br></div><div>I'm getting this error from LLVM:</div><div>unable to write object file c:\msys64\home\andy\zig\zig-ca<wbr>che\compiler_rt.obj: The requested operation cannot be performed on a file with a user-mapped section open.<br></div><div><br></div><div>The same process calls LLD with this .obj as  a linker input file, then tries to write to the same .obj file later.</div><div><br></div><div>I believe LLD is mmapping the .obj file and then not cleaning it up.</div><div><br></div><div>Can I have some guidance as to where in the code I could discover this and clean it up?</div><div><br></div><div>Regards,</div><div>Andrew</div><div><a href="http://ziglang.org/" target="_blank">http://ziglang.org/</a><br></div></div>
</blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>