Skip to content

Commit 3e32f66

Browse files
brsongraydon
authored andcommitted
rt: Write CFI instructions that (might) work on mac in __morestack
The DW_CFA_val_offset_sf instruction doesn't seem to work on mac, even after implementing it in the llvm-mc assembler, so now I'm looking for a different way to communicate the stack pointer adjustment to the unwinder.
1 parent e47f8fc commit 3e32f66

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/rt/arch/x86_64/morestack.S

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ MORESTACK:
7171
leaq 16(%rbp), %rax
7272
pushq %rax
7373

74+
// During unwinding we want to skip our caller since it's not
75+
// a complete frame and will make the unwinder sad
76+
#if defined(__linux__)
77+
// Don't understand this line
78+
.cfi_offset 16, 0
79+
// Tell the unwinding where to get the stack pointer for
80+
// our grandparent frame
81+
.cfi_offset %rsp, -24
82+
#endif
83+
84+
// Save the grandparent stack pointer for the unwinder
85+
leaq 16(%rbp), %rax
86+
pushq %rax
87+
7488
// FIXME: libgcc also saves rax. not sure if we need to
7589

7690
// Save argument registers

0 commit comments

Comments
 (0)