This is an archive of the discontinued LLVM Phabricator instance.

[LLD] Do not assume /guard:cf always set together with /guard:ehcont
ClosedPublic

Authored by pengfei on May 13 2023, 3:58 AM.

Details

Summary

MS link accepts *.obj with ehcont bit set only. LLD should match this
behavoir too.

Diff Detail

Event Timeline

pengfei created this revision.May 13 2023, 3:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2023, 3:58 AM
pengfei requested review of this revision.May 13 2023, 3:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2023, 3:58 AM
rnk added inline comments.May 15 2023, 12:58 PM
lld/COFF/Writer.cpp
1735–1740

Please update this comment to avoid discussing EH continuations.

My understanding is that if you compile with /guard:ehcont- and link with /guard:ehcont, then attempts to catch exceptions in the unprotected object files will crash the program with control flow violations, but correct me if I am wrong. There is no attempt to conservatively handle objects that catch exceptions but not /guard:ehcont, they must all be recompiled with EH continuations, correct?

pengfei updated this revision to Diff 522490.May 16 2023, 1:28 AM

Update comments.

lld/COFF/Writer.cpp
1735–1740

Good catch!

This patch is to fix a problem as a side effect of D150645. User expected both cf and ehcont bits are set in the obj files and link with both. However, we only have ehcont present due to the bug.
I don't know if this would be a problem in reality, but separating cf and ehcont in lld matches with MS link. So I think it's still good to go with this.

rnk accepted this revision.May 16 2023, 7:50 AM

lgtm

This revision is now accepted and ready to land.May 16 2023, 7:50 AM