This is an archive of the discontinued LLVM Phabricator instance.

[lld/mac] Don't crash when dead-stripping removes all unwind info
ClosedPublic

Authored by thakis on Jul 7 2021, 8:38 AM.

Details

Summary

If the input has compact unwind info but all of it is removed
after dead stripping, we would crash. Now we don't write any
__unwind_info section at all, like ld64.

This is a bit awkward to implement because we only know the final
state of unwind info after UnwindInfoSectionImpl<Ptr>::finalize(),
which is called after sections are added. So add a small amount of
bookkeeping to relocateCompactUnwind() instead (which runs earlier)
so that we can predict what finalize() will do before it runs.

Fixes PR51010.

Diff Detail

Event Timeline

thakis created this revision.Jul 7 2021, 8:38 AM
Herald added a reviewer: gkm. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
thakis requested review of this revision.Jul 7 2021, 8:38 AM
int3 accepted this revision.Jul 7 2021, 9:36 AM

I'm planning to add pointers from InputSections to their corresponding CompactUnwindEntries. Maybe I can make this less awkward along the way...

This revision is now accepted and ready to land.Jul 7 2021, 9:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2021, 10:05 AM
This revision is now accepted and ready to land.Jul 10 2021, 10:37 PM
int3 closed this revision.Jul 10 2021, 10:44 PM