From cb0b8d7cc622fa8403e180e59d644ebcd397af9b Mon Sep 17 00:00:00 2001 From: joerg Date: Tue, 30 Nov 2010 18:37:59 +0000 Subject: [PATCH] Fix stack alignment for non-constructor/destructor calls. AMD64 stack is 16 Byte aligned at the start of the function, so always push rbx. --- lib/csu/arch/x86_64/crtbegin.S | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/csu/arch/x86_64/crtbegin.S b/lib/csu/arch/x86_64/crtbegin.S index d92adbc5a14d..7efba6881667 100644 --- a/lib/csu/arch/x86_64/crtbegin.S +++ b/lib/csu/arch/x86_64/crtbegin.S @@ -1,4 +1,4 @@ -/* $NetBSD: crtbegin.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */ +/* $NetBSD: crtbegin.S,v 1.2 2010/11/30 18:37:59 joerg Exp $ */ /*- * Copyright (c) 2010 Joerg Sonnenberger * All rights reserved. @@ -30,7 +30,7 @@ #include -RCSID("$NetBSD: crtbegin.S,v 1.1 2010/08/07 18:01:34 joerg Exp $") +RCSID("$NetBSD: crtbegin.S,v 1.2 2010/11/30 18:37:59 joerg Exp $") .section .ctors, "aw", @progbits .align 8 @@ -82,6 +82,7 @@ __do_global_dtors_aux: je 1f ret 1: + pushq %rbx movb $1, __finished(%rip) @@ -93,7 +94,6 @@ __do_global_dtors_aux: 2: #endif - pushq %rbx leaq 8+__DTOR_LIST__(%rip), %rbx 3: movq (%rbx), %rax @@ -103,14 +103,13 @@ __do_global_dtors_aux: addq $8, %rbx jmp 3b 4: - popq %rbx cmpq $0, __deregister_frame_info@GOTPCREL(%rip) je 5f leaq __EH_FRAME_LIST__(%rip), %rdi call __deregister_frame_info@PLT 5: - + popq %rbx ret @@ -119,6 +118,7 @@ __do_global_ctors_aux: je 1f ret 1: + pushq %rbx movb $1, __initialized(%rip) cmpq $0, __register_frame_info@GOTPCREL(%rip) @@ -136,7 +136,6 @@ __do_global_ctors_aux: call _Jv_RegisterClasses@PLT 3: - pushq %rbx leaq -8+__CTOR_LIST_END__(%rip), %rbx 4: movq (%rbx), %rax