#ifndef __x86_64__
- # See below for an extended explanation of the CFI instructions.
- .cfi_offset 8, 8 # New PC stored at CFA + 8
- .cfi_escape 0x15, 4, 0x7d # DW_CFA_val_offset_sf, %esp, 12/-4
- # i.e., next %esp is CFA + 12
+ # See below for an extended explanation of this.
+ .cfi_def_cfa %esp,16
pushl %eax # Save %eax in case it is a parameter.
- .cfi_def_cfa %esp,8 # Account for pushed register.
+ .cfi_adjust_cfa_offset 4 # Account for pushed register.
movl %esp,%eax # Current stack,
subl 8(%esp),%eax # less required stack frame size,
popl %eax # Restore %eax and stack.
- .cfi_def_cfa %esp,4 # Account for popped register.
+ .cfi_adjust_cfa_offset -4 # Account for popped register.
ret $8 # Return to caller, popping args.
2:
- .cfi_def_cfa %esp,8 # Back to where we were.
+ .cfi_adjust_cfa_offset 4 # Back to where we were.
popl %eax # Restore %eax and stack.
- .cfi_def_cfa %esp,4 # Account for popped register.
+ .cfi_adjust_cfa_offset -4 # Account for popped register.
addl $0x5000+BACKOFF,4(%esp) # Increment space we request.
#else
- # See below for an extended explanation of the CFI instructions.
- .cfi_offset 16, 0
- .cfi_escape 0x15, 7, 0x7f # DW_CFA_val_offset_sf, %esp, 8/-8
+ # See below for an extended explanation of this.
+ .cfi_def_cfa %rsp,16
pushq %rax # Save %rax in case caller is using
# it to preserve original %r10.
- .cfi_def_cfa %rsp,16 # Adjust for pushed register.
+ .cfi_adjust_cfa_offset 8 # Adjust for pushed register.
movq %rsp,%rax # Current stack,
subq %r10,%rax # less required stack frame size,
#else
cmpl %fs:0x40,%eax
#endif
- jb 2f # Get more space if we need it.
+ popq %rax # Restore register.
- # This breaks call/return prediction, as described above.
- incq 8(%rsp) # Increment the return address.
+ .cfi_adjust_cfa_offset -8 # Adjust for popped register.
- popq %rax # Restore register.
+ jb 2f # Get more space if we need it.
- .cfi_def_cfa %rsp,8 # Adjust for popped register.
+ # This breaks call/return prediction, as described above.
+ incq (%rsp) # Increment the return address.
ret # Return to caller.
2:
- .cfi_def_cfa %rsp,16 # Back to where we were.
-
- popq %rax # Restore register.
-
- .cfi_def_cfa %rsp,8 # Adjust for popped register.
-
addq $0x5000+BACKOFF,%r10 # Increment space we request.
- # Fall throug into morestack.
+ # Fall through into morestack.
#endif
# instruction, and just return to the real caller.
# Here CFA points just past the return address on the stack,
- # e.g., on function entry it is %esp + 4. Later we will
- # change it to %ebp + 8, as set by .cfi_def_cfa_register and
- # .cfi_def_cfa_offset above. The stack looks like this:
+ # e.g., on function entry it is %esp + 4. The stack looks
+ # like this:
# CFA + 12: stack pointer after two returns
# CFA + 8: return address of morestack caller's caller
# CFA + 4: size of parameters
# CFA: new stack frame size
# CFA - 4: return address of this function
# CFA - 8: previous value of %ebp; %ebp points here
- # We want to set %esp to the stack pointer after the double
- # return, which is CFA + 12.
- .cfi_offset 8, 8 # New PC stored at CFA + 8
- .cfi_escape 0x15, 4, 0x7d # DW_CFA_val_offset_sf, %esp, 12/-4
- # i.e., next %esp is CFA + 12
+ # Setting the new CFA to be the current CFA + 12 (i.e., %esp +
+ # 16) will make the unwinder pick up the right return address.
+
+ .cfi_def_cfa %esp,16
- # Set up a normal backtrace.
pushl %ebp
- .cfi_def_cfa_offset 8
- .cfi_offset %ebp, -8
+ .cfi_adjust_cfa_offset 4
+ .cfi_offset %ebp, -20
movl %esp,%ebp
.cfi_def_cfa_register %ebp
# register, since we don't change it, we just have to save it
# for the unwinder.
movl %ebx,-4(%ebp)
- .cfi_offset %ebx, -12
+ .cfi_offset %ebx, -24
# In 32-bit mode the registers %eax, %edx, and %ecx may be
# used for parameters, depending on the regparm and fastcall
popl %ebp
.cfi_restore %ebp
- .cfi_def_cfa %esp, 4
+ .cfi_def_cfa %esp, 16
ret $8 # Return to caller, which will
# immediately return. Pop
# arguments as we go.
# return to the caller of our caller. Let the unwinder skip
# that single return instruction, and just return to the real
# caller.
- .cfi_offset 16, 0
- .cfi_escape 0x15, 7, 0x7f # DW_CFA_val_offset_sf, %esp, 8/-8
+ .cfi_def_cfa %rsp,16
# Set up a normal backtrace.
pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset %rbp, -16
+ .cfi_adjust_cfa_offset 8
+ .cfi_offset %rbp, -24
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
.cfi_remember_state
popq %rbp
.cfi_restore %rbp
- .cfi_def_cfa %rsp, 8
+ .cfi_def_cfa %rsp, 16
ret # Return to caller, which will
# immediately return.