Page MenuHomePhabricator

[LLD][COFF] Reset outputSections for successive runs
ClosedPublic

Authored by baszalmstra on Sat, Aug 22, 9:59 AM.

Details

Summary

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.

Diff Detail

Event Timeline

baszalmstra created this revision.Sat, Aug 22, 9:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptSat, Aug 22, 9:59 AM
baszalmstra requested review of this revision.Sat, Aug 22, 9:59 AM
mstorsjo accepted this revision.Sat, Aug 22, 12:34 PM
mstorsjo added a reviewer: amccarth.
mstorsjo added subscribers: hans, mstorsjo.

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?

This revision is now accepted and ready to land.Sat, Aug 22, 12:35 PM

@baszalmstra - How do you want the commit credited in the git author line?

Bas Zalmstra <zalmstra.bas@gmail.com> will do :)

This revision was automatically updated to reflect the committed changes.
hans added a comment.Mon, Aug 24, 10:54 AM

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?

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.

aganea added a subscriber: aganea.Mon, Aug 24, 12:12 PM

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?

D70378 covers all this, at least for the COFF driver.

hans added a comment.Tue, Aug 25, 5:48 AM

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!