[KCFI] Fix hash offset calculation in Thumb mode
authorSami Tolvanen <samitolvanen@google.com>
Mon, 12 Jun 2023 16:24:54 +0000 (16:24 +0000)
committerSami Tolvanen <samitolvanen@google.com>
Mon, 12 Jun 2023 19:43:34 +0000 (19:43 +0000)
commitce4bb083c043d42474cd071bd5149dc5fd4430f6
tree8daab1a1c1e86b3c3805c6123b5b0c0b76db12ac
parentd167fe0c4ed6983b56c6b0209eb2a2b4cc1d3e0e
[KCFI] Fix hash offset calculation in Thumb mode

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.

Fixes #62936

Reviewed By: MaskRay, simon_tatham

Differential Revision: https://reviews.llvm.org/D152484
llvm/lib/Transforms/Instrumentation/KCFI.cpp
llvm/test/Transforms/KCFI/kcfi.ll