GCC on AArch64 uses DW_CFA_GNU_window_save for return address signing.
In architecture revisions prior to ARMv8.3-A the pointer authentication
HINT instructions operate as NOPs.
Differential D142572
[AArch64] fix bug #55005 handle DW_CFA_GNU_window_save sebpop on Jan 25 2023, 11:35 AM. Authored by
Details
GCC on AArch64 uses DW_CFA_GNU_window_save for return address signing. In architecture revisions prior to ARMv8.3-A the pointer authentication
Diff Detail
Event Timeline
Comment Actions I added a testcase, however I was not able to check if the test catches the issue. I need some help on how to run the bolt tests. Thank you. Comment Actions Please try make check-bolt. Although test seems to be too easy, I doubt that it could check the problem.. Comment Actions Recommended check-bolt fails with: $ make check-bolt make: *** No rule to make target 'check-bolt'. Stop. If I execute the following sequence before the patch, the test will fail (also as described in the bug report https://github.com/llvm/llvm-project/issues/55005 ) $ clang -O2 -Wl,-q -o a.out dw_cfa_gnu_window_save.cc $ llvm-bolt a.out -o a.bolt BOLT-INFO: Target architecture: aarch64 BOLT-INFO: BOLT version: 5de6b94f856f696832ce7df167e1dbc096fbe598 BOLT-INFO: first alloc address is 0x400000 BOLT-INFO: creating new program header table at address 0x600000, offset 0x200000 BOLT-INFO: enabling relocation mode BOLT-INFO: disabling -align-macro-fusion on non-x86 platform ======================================= BOLT is unable to proceed because it couldn't properly understand this function. If you are running the most recent version of BOLT, you may want to report this and paste this dump. Please check that there is no sensitive contents being shared in this dump. Offending function: __do_global_dtors_aux/1(*2) Function contents ( 0000: 3F2303D5 FD7BBEA9 FD030091 F30B00F9 |?#...{..........| 0010: 93010090 60824039 80000035 DEFFFF97 |....`.@9...5....| 0020: 20008052 60820039 F30B40F9 FD7BC2A8 | ..R`..9..@..{..| 0030: BF2303D5 C0035FD6 |.#...._.| ) Binary Function "__do_global_dtors_aux/1(*2)" { All names : __do_global_dtors_aux/1 __do_global_dtors_aux/crtstuff.c/1 Number : 8 State : disassembled Address : 0x41014c Size : 0x38 MaxSize : 0x38 Offset : 0x1014c Section : .text Orc Section : .local.text.__do_global_dtors_aux/1 LSDA : 0x0 IsSimple : 1 IsMultiEntry: 0 IsSplit : 0 BB Count : 0 } .LBB07: 00000000: paciasp 00000004: stp x29, x30, [sp, #-0x20]! 00000008: mov x29, sp 0000000c: str x19, [sp, #0x10] 00000010: adrp x19, "__TMC_LIST__/1" 00000014: ldrb w0, [x19, :lo12:"__TMC_LIST__/1"] 00000018: cbnz w0, .Ltmp4 # Offset: 24 0000001c: bl "deregister_tm_clones/1" # Offset: 28 00000020: mov w0, #0x1 00000024: strb w0, [x19, :lo12:"__TMC_LIST__/1"] .Ltmp4: 00000028: ldr x19, [sp, #0x10] 0000002c: ldp x29, x30, [sp], #0x20 00000030: autiasp 00000034: ret x30 # Offset: 52 DWARF CFI Instructions: <empty> End of Function "__do_global_dtors_aux/1(*2)" ERROR: unable to fill CFI. ======================================= Comment Actions I'm not sure why check-bolt doesn't work for you, it works fine for me.. Comment Actions Added testcase that passes with the patch. Comment Actions Thanks Amir for the tip, configuring with -DLLVM_ENABLE_PROJECTS="clang;bolt;lld" enabled check-bolt target.
Comment Actions Overall LGTM, although usually we have a policy to minimise yaml tests as much as we can, removing unneeded for the tests sections, symbols, data & etc.
|
Can you add a comment here explaining why you're calling createNegateRAState? Something like
"DW_CFA_GNU_window_save and DW_CFA_GNU_NegateRAState just use the same id but mean different things. The latter is used in AArch64".
Also, guard this code under AArch64 (from what I understand, this is an AArch64-only thing)