瀏覽代碼

align stack properly for calling global ctors/dtors on x86[_64]

failure to do so was causing crashes on x86_64 when ctors used SSE,
which was first observed when ctors called variadic functions due to
the SSE prologue code inserted into every variadic function.
Rich Felker 11 年之前
父節點
當前提交
a6d272127b
共有 4 個文件被更改,包括 8 次插入0 次删除
  1. 2 0
      crt/i386/crti.s
  2. 2 0
      crt/i386/crtn.s
  3. 2 0
      crt/x86_64/crti.s
  4. 2 0
      crt/x86_64/crtn.s

+ 2 - 0
crt/i386/crti.s

@@ -1,7 +1,9 @@
 .section .init
 .section .init
 .global _init
 .global _init
 _init:
 _init:
+	sub $12,%esp
 
 
 .section .fini
 .section .fini
 .global _fini
 .global _fini
 _fini:
 _fini:
+	sub $12,%esp

+ 2 - 0
crt/i386/crtn.s

@@ -1,5 +1,7 @@
 .section .init
 .section .init
+	add $12,%esp
 	ret
 	ret
 
 
 .section .fini
 .section .fini
+	add $12,%esp
 	ret
 	ret

+ 2 - 0
crt/x86_64/crti.s

@@ -1,7 +1,9 @@
 .section .init
 .section .init
 .global _init
 .global _init
 _init:
 _init:
+	push %rax
 
 
 .section .fini
 .section .fini
 .global _fini
 .global _fini
 _fini:
 _fini:
+	push %rax

+ 2 - 0
crt/x86_64/crtn.s

@@ -1,5 +1,7 @@
 .section .init
 .section .init
+	pop %rax
 	ret
 	ret
 
 
 .section .fini
 .section .fini
+	pop %rax
 	ret
 	ret