[PATCH] D154125: MachineFunction: -fsanitize={function, kcfi}: ensure 4-byte alignment
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 29 11:11:49 PDT 2023
MaskRay created this revision.
MaskRay added reviewers: efriedma, rjmccall, simon_tatham, samitolvanen.
Herald added subscribers: luke, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, kristof.beyls.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added subscribers: llvm-commits, wangpc.
Herald added a project: LLVM.
Fix https://github.com/llvm/llvm-project/issues/63579
% cat a.c
void foo() {}
% clang --target=arm-none-eabi -mthumb -mno-unaligned-access -fsanitize=kcfi a.c -S -o - | grep p2align
.p2align 1
% clang --target=armv6m-none-eabi -fsanitize=function a.c -S -o - | grep p2align
.p2align 1
Ensure that -fsanitize={function,kcfi} instrumented functions are aligned by at
least 4, so that loading the type hash before the function label will not cause
a misaligned access. This is especially important for -mno-unaligned-access
configurations that doesn't set `setMinFunctionAlignment` to 4 or greater.
With this patch, the generated assembly for the examples above will contain `.p2align 2`.
If `__attribute__((aligned(N)))` or `-falign-functions=N` is specified, the
larger alignment will be used.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D154125
Files:
llvm/lib/CodeGen/MachineFunction.cpp
llvm/test/CodeGen/ARM/func-sanitizer.ll
llvm/test/CodeGen/ARM/kcfi.ll
llvm/test/CodeGen/RISCV/kcfi-patchable-function-prefix.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154125.535922.patch
Type: text/x-patch
Size: 4120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230629/2435127b/attachment.bin>
More information about the llvm-commits
mailing list