]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
aarch64: fix unwinding in longjmp
authorYury Khrustalev <yury.khrustalev@arm.com>
Thu, 8 May 2025 12:53:38 +0000 (13:53 +0100)
committerYury Khrustalev <yury.khrustalev@arm.com>
Tue, 13 May 2025 12:00:57 +0000 (13:00 +0100)
Previously, longjmp() on aarch64 was using CFI directives around the
call to __libc_arm_za_disable() after CFA was redefined at the start
of longjmp(). This may result in unwinding issues. Move the call and
surrounding CFI directives to the beginning of longjmp().

Suggested-by: Wilco Dijkstra <wilco.dijkstra@arm.com>
sysdeps/aarch64/__longjmp.S

index 981bf808337e2947d294e47cc2d4f3cb0c8f1930..d062e04862de35a5c09004d7cbe7514812460dd2 100644 (file)
 /* __longjmp(jmpbuf, val) */
 
 ENTRY (__longjmp)
-       cfi_def_cfa(x0, 0)
-       cfi_offset(x19, JB_X19<<3)
-       cfi_offset(x20, JB_X20<<3)
-       cfi_offset(x21, JB_X21<<3)
-       cfi_offset(x22, JB_X22<<3)
-       cfi_offset(x23, JB_X23<<3)
-       cfi_offset(x24, JB_X24<<3)
-       cfi_offset(x25, JB_X25<<3)
-       cfi_offset(x26, JB_X26<<3)
-       cfi_offset(x27, JB_X27<<3)
-       cfi_offset(x28, JB_X28<<3)
-       cfi_offset(x29, JB_X29<<3)
-       cfi_offset(x30, JB_LR<<3)
-
-       cfi_offset( d8, JB_D8<<3)
-       cfi_offset( d9, JB_D9<<3)
-       cfi_offset(d10, JB_D10<<3)
-       cfi_offset(d11, JB_D11<<3)
-       cfi_offset(d12, JB_D12<<3)
-       cfi_offset(d13, JB_D13<<3)
-       cfi_offset(d14, JB_D14<<3)
-       cfi_offset(d15, JB_D15<<3)
 
 #if IS_IN(libc)
        /* Disable ZA state of SME in libc.a and libc.so, but not in ld.so.  */
@@ -69,6 +47,29 @@ ENTRY (__longjmp)
 # endif
 #endif
 
+       cfi_def_cfa (x0, 0)
+       cfi_offset (x19, JB_X19<<3)
+       cfi_offset (x20, JB_X20<<3)
+       cfi_offset (x21, JB_X21<<3)
+       cfi_offset (x22, JB_X22<<3)
+       cfi_offset (x23, JB_X23<<3)
+       cfi_offset (x24, JB_X24<<3)
+       cfi_offset (x25, JB_X25<<3)
+       cfi_offset (x26, JB_X26<<3)
+       cfi_offset (x27, JB_X27<<3)
+       cfi_offset (x28, JB_X28<<3)
+       cfi_offset (x29, JB_X29<<3)
+       cfi_offset (x30, JB_LR<<3)
+
+       cfi_offset ( d8, JB_D8<<3)
+       cfi_offset ( d9, JB_D9<<3)
+       cfi_offset (d10, JB_D10<<3)
+       cfi_offset (d11, JB_D11<<3)
+       cfi_offset (d12, JB_D12<<3)
+       cfi_offset (d13, JB_D13<<3)
+       cfi_offset (d14, JB_D14<<3)
+       cfi_offset (d15, JB_D15<<3)
+
        ldp     x19, x20, [x0, #JB_X19<<3]
        ldp     x21, x22, [x0, #JB_X21<<3]
        ldp     x23, x24, [x0, #JB_X23<<3]