Skip to content

Commit 9d70c19

Browse files
committed
rt: Fix alignment of the call to upcall_del_stack in __morestack
1 parent 23df4de commit 9d70c19

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/rt/arch/i386/morestack.S

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ MORESTACK:
6464
// NB: This can be called with the fastcc convention so we
6565
// have to preserve any argument registers we want to use
6666

67+
// NB: __morestack is called misaligned by 4 bytes, i.e.
68+
// subl $4, %esp would get us to a normal alignment
69+
6770
// FIXME (1226): main is compiled with the split-stack prologue,
6871
// causing it to call __morestack, so we have to jump back out
6972
subl $28,%esp
@@ -120,7 +123,9 @@ MORESTACK:
120123
// Switch back to the rust stack
121124
movl %ebp, %esp
122125

123-
subl $8, %esp // Alignment
126+
// Remember that __morestack is called misaligned so %ebp
127+
// is not aligned to a 16-byte boundary, these 4 bytes realign.
128+
subl $4, %esp
124129

125130
// Now that we're on the return path we want to avoid
126131
// stomping on %eax. FIXME: Need to save and restore
@@ -137,7 +142,7 @@ MORESTACK:
137142
pushl $0
138143
call UPCALL_CALL_C
139144

140-
addl $16,%esp
145+
addl $12,%esp
141146

142147
popl %ebp
143148
#if defined(__linux__) || defined(__APPLE__)

0 commit comments

Comments
 (0)