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.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
LGTM
@hans - I think this definitely should go to the release branch after landing.
@baszalmstra - How do you want the commit credited in the git author line?
Cherry-picked to 11.x as 0c37a9165611880b99b1f9632179864ecb3f2e13.
I'm curious about the background here, though. When would lld::coff::link be called successively? Could we have a test for this?
That'd be when you use lld as a library from a host program, instead of using lld as a standalone executable. lld is tricky in that respect, as it fairly heavily uses global data structures (you can't have two lld linking invocations running in separate threads at the same time), and those structures need some care taken to reset them properly between each run.
I'm curious about the background here, though. When would lld::coff::link be called successively? Could we have a test for this?
D70378 covers all this, at least for the COFF driver.
Great!