瀏覽代碼

[Pal] user_start.S: Preserve %rbp since it is callee-saved

Previously, if Pal was compiled with `-O2`, regression tests failed
because %rbp was not preserved.
Isaku Yamahata 4 年之前
父節點
當前提交
98f94654bf
共有 1 個文件被更改,包括 6 次插入5 次删除
  1. 6 5
      Pal/src/user_start.S

+ 6 - 5
Pal/src/user_start.S

@@ -21,10 +21,6 @@
 	.globl _start
 	.type _start,@function
 _start:
-	/* Clear the frame pointer.  The ABI suggests this be done, to mark
-	   the outermost frame obviously.  */
-	xorl %ebp, %ebp
-
 	popq %rdi		/* Pop the argument count.  */
 
 	/* argv starts just at the current stack top.  */
@@ -34,8 +30,12 @@ _start:
 	and  $~0xF, %rsp
 
 	/* push the exit address on the stack and preserve %rsp alignment */
-	subq $8, %rsp
 	pushq %rdx
+	/* Clear the frame pointer.  The ABI suggests this be done, to mark
+	   the outermost frame obviously.  */
+	pushq %rbp		/* %rbp is callee save. */
+	xorl %ebp, %ebp
+
 
 	/* find the environs */
 	lea (%rsi,%rdi,8), %rdx
@@ -48,4 +48,5 @@ _start:
 #endif
 
 	/* return to the exit function */
+	popq %rbp
 	retq