[PATCH] D156716: [AArch64][PAC] Check authenticated LR value during tail call
Anatoly Trosinenko via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 6 07:23:13 PDT 2023
atrosinenko added inline comments.
================
Comment at: llvm/lib/Target/AArch64/AArch64PointerAuth.cpp:191
+ .addMemOperand(createCheckMemOperand(MF))
+ .setMIFlags(MachineInstr::FrameDestroy);
+ return MBB;
----------------
kristof.beyls wrote:
> I'm wondering why any/all of the machineinsts created in this function need to have the FrameDestroy flag set? Do you know?
Setting `MachineInstr::FrameDestroy` unconditionally in `checkAuthenticatedRegister` is definitely a mistake, thank you. Maybe I have to pass MI flags as an argument, but it seems that it works as-is, at least for generating DWARF debug info (see Epilogue Begin marker).
Added an explicit assertion that WinCFI is not requested as I don't yet emit any SEH opcodes.
```
$ cat /tmp/tail-call.c
int caller_indirect(int *n, int (fptr)(int*)) {
asm volatile ("" ::: "lr");
*n = 42;
return fptr(n);
}
$ ./bin/clang -O1 -target aarch64-linux-gnu /tmp/tail-call.c -c -o /tmp/tail-call.o -mbranch-protection=pac-ret -mllvm -aarch64-authenticated-lr-check-method=xpac-hint -g
$ dwarfdump -l /tmp/tail-call.o && llvm-objdump -d /tmp/tail-call.o
.debug_line: line number info for a single cu
Source lines (from CU-DIE at .debug_info offset 0x0000000c):
NS new statement, BB new basic block, ET end of text sequence
PE prologue end, EB epilogue begin
IS=val ISA number, DI=val discriminator value
<pc> [lno,col] NS BB ET PE EB IS= DI= uri: "filepath"
0x00000000 [ 1, 0] NS uri: "/tmp/tail-call.c"
0x0000000c [ 2, 3] NS PE
0x0000000c [ 3, 6] NS
0x00000010 [ 4,10] NS ET EB
0x00000030 [ 4,10] NS ET
/tmp/tail-call.o: file format elf64-littleaarch64
Disassembly of section .text:
0000000000000000 <caller_indirect>:
0: d503233f paciasp
4: f81f0ffe str x30, [sp, #-0x10]!
8: 52800548 mov w8, #0x2a
c: b9000008 str w8, [x0]
10: f84107fe ldr x30, [sp], #0x10
14: d50323bf autiasp
18: aa1e03f0 mov x16, x30
1c: d50320ff xpaclri
20: eb1e021f cmp x16, x30
24: 54000041 b.ne 0x2c <caller_indirect+0x2c>
28: d61f0020 br x1
2c: d4388e20 brk #0xc471
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156716/new/
https://reviews.llvm.org/D156716
More information about the llvm-commits
mailing list