This is an archive of the discontinued LLVM Phabricator instance.

[KCFI] Fix hash offset calculation in Thumb mode
ClosedPublic

Authored by samitolvanen on Jun 8 2023, 4:18 PM.

Details

Summary

ARM stores the Thumb state in the least significant bit of the
function pointers. When compiling for ARM or Thumb, as all
instructions are at least 16-bit aligned, ignore the LSB when
computing the prefix hash location, so we can support both
pure Thumb and mixed ARM/Thumb binaries.

Diff Detail

Event Timeline

samitolvanen created this revision.Jun 8 2023, 4:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2023, 4:18 PM
samitolvanen requested review of this revision.Jun 8 2023, 4:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2023, 4:18 PM
pirama added a subscriber: pirama.Jun 8 2023, 4:29 PM
MaskRay accepted this revision.Jun 8 2023, 8:11 PM
This revision is now accepted and ready to land.Jun 8 2023, 8:11 PM
simon_tatham accepted this revision.Jun 9 2023, 1:10 AM

Thanks! This should fix https://github.com/llvm/llvm-project/issues/62936.

I agree that it's better to do the fix here, instead of adding dedicated support in the backend the way AArch64 does it, because as far as I can see backend KCFI checks are inserted after register allocation and have to use registers that are already dead. And in at least one Arm situation (namely Armv6-M) no such registers are conveniently available, so the check would become more expensive.

This revision was automatically updated to reflect the committed changes.