This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [COFF] Handle comdat sections without leader symbols
ClosedPublic

Authored by mstorsjo on Jul 22 2018, 2:48 PM.

Details

Summary

Discard them unless they have been associated by other means (yet unimplemented).

According to MS link.exe, such sections are illegal, but MinGW setups use them in their take on associative comdats.

This avoids leaving references to the bogus SectionChunk* PendingComdat, which cannot be dereferenced.

This fixes PR38183.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Jul 22 2018, 2:48 PM

Ping @rnk on this one as well; this is a dependency to D49700.

rnk added inline comments.Jul 23 2018, 4:56 PM
COFF/InputFiles.cpp
289 ↗(On Diff #156715)

I think this is probably the right place to do the check.

mstorsjo added inline comments.Jul 23 2018, 10:07 PM
COFF/InputFiles.cpp
289 ↗(On Diff #156715)

Yes, this is the one place where createRegular is called without checking for PendingComdat before. I thought the check felt natural there, but I can move it here instead.

mstorsjo updated this revision to Diff 156972.Jul 24 2018, 12:34 AM

Moved the check, as suggested by @rnk.

Regardless of the status of the other patch and for how to handle the associativity, this patch probably is useful, to avoid crashes if faced with such object files.

rnk accepted this revision.Jul 26 2018, 10:37 AM

lgtm

This revision is now accepted and ready to land.Jul 26 2018, 10:37 AM
This revision was automatically updated to reflect the committed changes.