Add cfi directives for arm64 assembler.
Fix syscall generator to add cfi directives and add the directives
for all arm64 assembler.
Bug: 15138290
Change-Id: I7f0e4a16c141ac624e5276917a3a1ed45778e057
diff --git a/libc/arch-arm64/bionic/__bionic_clone.S b/libc/arch-arm64/bionic/__bionic_clone.S
index ddd8ee0..499a6cc 100644
--- a/libc/arch-arm64/bionic/__bionic_clone.S
+++ b/libc/arch-arm64/bionic/__bionic_clone.S
@@ -32,8 +32,10 @@
ENTRY(__bionic_clone)
stp x29, x30, [sp, #-16]!
+ .cfi_def_cfa_offset 16
+ .cfi_rel_offset x29, 0
+ .cfi_rel_offset x30, 8
mov x29, sp
- str x8, [sp, #-16]!
# Copy 'fn' and 'arg' onto the child stack.
stp x5, x6, [x1, #-16]
@@ -48,8 +50,10 @@
# Are we the child?
cbz x0, .L_bc_child
- ldr x8, [sp], #16
ldp x29, x30, [sp], #16
+ .cfi_def_cfa_offset 0
+ .cfi_restore x29
+ .cfi_restore x30
# Set errno if something went wrong.
cmn x0, #(MAX_ERRNO + 1)
@@ -60,6 +64,8 @@
.L_bc_child:
# We're in the child now. Set the end of the frame record chain...
+ .cfi_undefined x29
+ .cfi_undefined x30
mov x29, xzr
# ...and call __bionic_clone_entry with the 'fn' and 'arg' we stored on the child stack.
ldp x0, x1, [sp, #-16]
diff --git a/libc/arch-arm64/bionic/futex_arm64.S b/libc/arch-arm64/bionic/futex_arm64.S
index 5a47826..00d24a4 100644
--- a/libc/arch-arm64/bionic/futex_arm64.S
+++ b/libc/arch-arm64/bionic/futex_arm64.S
@@ -34,14 +34,18 @@
// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
ENTRY(__futex_syscall4)
stp x29, x30, [sp, #-16]!
+ .cfi_def_cfa_offset 16
+ .cfi_rel_offset x29, 0
+ .cfi_rel_offset x30, 8
mov x29, sp
- str x8, [sp, #-16]!
mov x8, __NR_futex
svc #0
- ldr x8, [sp], #16
ldp x29, x30, [sp], #16
+ .cfi_def_cfa_offset 0
+ .cfi_restore x29
+ .cfi_restore x30
ret
END(__futex_syscall4)
@@ -53,34 +57,42 @@
// int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
ENTRY_PRIVATE(__futex_wait)
stp x29, x30, [sp, #-16]!
+ .cfi_def_cfa_offset 16
+ .cfi_rel_offset x29, 0
+ .cfi_rel_offset x30, 8
mov x29, sp
mov x3, x2
mov x2, x1
mov x1, #FUTEX_WAIT
- str x8, [sp, #-16]!
mov x8, __NR_futex
svc #0
- ldr x8, [sp], #16
ldp x29, x30, [sp], #16
+ .cfi_def_cfa_offset 0
+ .cfi_restore x29
+ .cfi_restore x30
ret
END(__futex_wait)
// int __futex_wake(volatile void* ftx, int count)
ENTRY_PRIVATE(__futex_wake)
stp x29, x30, [sp, #-16]!
+ .cfi_def_cfa_offset 16
+ .cfi_rel_offset x29, 0
+ .cfi_rel_offset x30, 8
mov x29, sp
mov x2, x1
mov x1, #FUTEX_WAKE
- str x8, [sp, #-16]!
mov x8, __NR_futex
svc #0
- ldr x8, [sp], #16
ldp x29, x30, [sp], #16
+ .cfi_def_cfa_offset 0
+ .cfi_restore x29
+ .cfi_restore x30
ret
END(__futex_wake)
diff --git a/libc/arch-arm64/bionic/syscall.S b/libc/arch-arm64/bionic/syscall.S
index e5be1d5..42e8883 100644
--- a/libc/arch-arm64/bionic/syscall.S
+++ b/libc/arch-arm64/bionic/syscall.S
@@ -31,11 +31,11 @@
ENTRY(syscall)
/* create AAPCS frame pointer */
stp x29, x30, [sp, #-16]!
+ .cfi_def_cfa_offset 16
+ .cfi_rel_offset x29, 0
+ .cfi_rel_offset x30, 8
mov x29, sp
- /* store x8 */
- str x8, [sp, #-16]!
-
/* Move syscall No. from x0 to x8 */
mov x8, x0
/* Move syscall parameters from x1 thru x6 to x0 thru x5 */
@@ -47,9 +47,10 @@
mov x5, x6
svc #0
- /* restore x8 */
- ldr x8, [sp], #16
ldp x29, x30, [sp], #16
+ .cfi_def_cfa_offset 0
+ .cfi_restore x29
+ .cfi_restore x30
/* check if syscall returned successfully */
cmn x0, #(MAX_ERRNO + 1)
diff --git a/libc/arch-arm64/bionic/vfork.S b/libc/arch-arm64/bionic/vfork.S
index 52009e2..c700623 100644
--- a/libc/arch-arm64/bionic/vfork.S
+++ b/libc/arch-arm64/bionic/vfork.S
@@ -37,10 +37,8 @@
mov x3, xzr
mov x4, xzr
- str x8, [sp, #-16]!
mov x8, __NR_clone
svc #0
- ldr x8, [sp], #16
cmn x0, #(MAX_ERRNO + 1)
cneg x0, x0, hi