Skip to content

Commit 1720bc2

Browse files
committed
rt: Unwind through __morestack on 32-bit linux
1 parent 12e401c commit 1720bc2

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/rt/arch/i386/morestack.S

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,25 @@
4646

4747
#if defined(__linux__) || defined(__APPLE__)
4848
MORESTACK:
49+
#ifdef __linux__
50+
.cfi_startproc
51+
52+
// Some magic that explains to the unwinder the unusal nature
53+
// of this stack frame. Copied verbatim from libgcc, which
54+
// has comments explaining it.
55+
.cfi_offset 8, 8
56+
.cfi_escape 0x15, 4, 0x7d
57+
#endif
4958

5059
pushl %ebp
60+
#ifdef __linux__
61+
.cfi_def_cfa_offset 8
62+
.cfi_offset %ebp, -8
63+
#endif
5164
movl %esp, %ebp
65+
#ifdef __linux__
66+
.cfi_def_cfa_register %ebp
67+
#endif
5268

5369
// FIXME (1226): main is compiled with the split-stack prologue,
5470
// causing it to call __morestack, so we have to jump back out
@@ -105,7 +121,12 @@ MORESTACK:
105121
call UPCALL_CALL_C
106122

107123
addl $16,%esp
124+
108125
popl %ebp
126+
#ifdef __linux__
127+
.cfi_restore %ebp
128+
.cfi_def_cfa %esp, 4
129+
#endif
109130
retl $8
110131

111132
.L$bail:
@@ -118,6 +139,9 @@ MORESTACK:
118139

119140
jmpl *%edx
120141

142+
#ifdef __linux__
143+
.cfi_endproc
144+
#endif
121145

122146
#else
123147
MORESTACK:

0 commit comments

Comments
 (0)