|
18 | 18 |
|
19 | 19 | .text
|
20 | 20 |
|
| 21 | +/* |
| 22 | + * NOTE!!! You may notice that all of the .cfi directives in this file have |
| 23 | + * been commented out. This is because they have been shown to trigger segfaults |
| 24 | + * in libgcc when unwinding out of a SIGCANCEL handler to invoke pthread |
| 25 | + * cleanup handlers during the thread cancellation dance. By omitting the |
| 26 | + * directives, we trigger an arm64-specific fallback path in the unwinder which |
| 27 | + * recognises the signal frame and restores many of the registers directly from |
| 28 | + * the sigcontext. Re-enabling the cfi directives here therefore needs to be |
| 29 | + * much more comprehensive to reduce the risk of further regressions. |
| 30 | + */ |
| 31 | + |
21 | 32 | /* Ensure that the mysterious NOP can be associated with a function. */
|
22 |
| - .cfi_startproc |
| 33 | +// .cfi_startproc |
23 | 34 |
|
24 | 35 | /*
|
25 |
| - * .cfi_signal_frame causes the corresponding Frame Description Entry in the |
26 |
| - * .eh_frame section to be annotated as a signal frame. This allows DWARF |
27 |
| - * unwinders (e.g. libstdc++) to implement _Unwind_GetIPInfo(), which permits |
28 |
| - * unwinding out of the signal trampoline without the need for the mysterious |
29 |
| - * NOP. |
| 36 | + * .cfi_signal_frame causes the corresponding Frame Description Entry (FDE) in |
| 37 | + * the .eh_frame section to be annotated as a signal frame. This allows DWARF |
| 38 | + * unwinders (e.g. libstdc++) to implement _Unwind_GetIPInfo() and identify |
| 39 | + * the next frame using the unmodified return address instead of subtracting 1, |
| 40 | + * which may yield the wrong FDE. |
30 | 41 | */
|
31 |
| - .cfi_signal_frame |
| 42 | +// .cfi_signal_frame |
32 | 43 |
|
33 | 44 | /*
|
34 | 45 | * Tell the unwinder where to locate the frame record linking back to the
|
35 |
| - * interrupted context. We don't provide unwind info for registers other |
36 |
| - * than the frame pointer and the link register here; in practice, this |
37 |
| - * is sufficient for unwinding in C/C++ based runtimes and the values in |
38 |
| - * the sigcontext may have been modified by this point anyway. Debuggers |
| 46 | + * interrupted context. We don't provide unwind info for registers other than |
| 47 | + * the frame pointer and the link register here; in practice, this is likely to |
| 48 | + * be insufficient for unwinding in C/C++ based runtimes, especially without a |
| 49 | + * means to restore the stack pointer. Thankfully, unwinders and debuggers |
39 | 50 | * already have baked-in strategies for attempting to unwind out of signals.
|
40 | 51 | */
|
41 |
| - .cfi_def_cfa x29, 0 |
42 |
| - .cfi_offset x29, 0 * 8 |
43 |
| - .cfi_offset x30, 1 * 8 |
| 52 | +// .cfi_def_cfa x29, 0 |
| 53 | +// .cfi_offset x29, 0 * 8 |
| 54 | +// .cfi_offset x30, 1 * 8 |
44 | 55 |
|
45 | 56 | /*
|
46 | 57 | * This mysterious NOP is required for some unwinders (e.g. libc++) that
|
|
51 | 62 | nop // Mysterious NOP
|
52 | 63 |
|
53 | 64 | /*
|
54 |
| - * GDB relies on being able to identify the sigreturn instruction sequence to |
55 |
| - * unwind from signal handlers. We cannot, therefore, use SYM_FUNC_START() |
56 |
| - * here, as it will emit a BTI C instruction and break the unwinder. Thankfully, |
57 |
| - * this function is only ever called from a RET and so omitting the landing pad |
58 |
| - * is perfectly fine. |
| 65 | + * GDB, libgcc and libunwind rely on being able to identify the sigreturn |
| 66 | + * instruction sequence to unwind from signal handlers. We cannot, therefore, |
| 67 | + * use SYM_FUNC_START() here, as it will emit a BTI C instruction and break the |
| 68 | + * unwinder. Thankfully, this function is only ever called from a RET and so |
| 69 | + * omitting the landing pad is perfectly fine. |
59 | 70 | */
|
60 | 71 | SYM_CODE_START(__kernel_rt_sigreturn)
|
| 72 | +// PLEASE DO NOT MODIFY |
61 | 73 | mov x8, #__NR_rt_sigreturn
|
| 74 | +// PLEASE DO NOT MODIFY |
62 | 75 | svc #0
|
63 |
| - .cfi_endproc |
| 76 | +// PLEASE DO NOT MODIFY |
| 77 | +// .cfi_endproc |
64 | 78 | SYM_CODE_END(__kernel_rt_sigreturn)
|
65 | 79 |
|
66 | 80 | emit_aarch64_feature_1_and
|
0 commit comments