Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/ld.elf_so/arch/x86_64 Align in the stack before call...



details:   https://anonhg.NetBSD.org/src/rev/8e548230d602
branches:  trunk
changeset: 771962:8e548230d602
user:      joerg <joerg%NetBSD.org@localhost>
date:      Sun Dec 11 22:07:26 2011 +0000

description:
Align in the stack before calling _rtld in the way the x86_64 ABI
specifies. This is necessary to ensure that init functions are always
called with the correct alignment, e.g. in case they use SSE
instructions.

diffstat:

 libexec/ld.elf_so/arch/x86_64/rtld_start.S |  5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diffs (26 lines):

diff -r 735abb3c5538 -r 8e548230d602 libexec/ld.elf_so/arch/x86_64/rtld_start.S
--- a/libexec/ld.elf_so/arch/x86_64/rtld_start.S        Sun Dec 11 20:45:14 2011 +0000
+++ b/libexec/ld.elf_so/arch/x86_64/rtld_start.S        Sun Dec 11 22:07:26 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtld_start.S,v 1.8 2010/12/05 00:56:07 joerg Exp $     */
+/*     $NetBSD: rtld_start.S,v 1.9 2011/12/11 22:07:26 joerg Exp $     */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -47,6 +47,8 @@
        movq    %rsp,%r12               # stack pointer arg to _rtld
        pushq   %rbx                    # save ps_strings
 
+       andq    $~15,%rsp               # align rsp, to be restored from r12
+
        leaq    _GLOBAL_OFFSET_TABLE_(%rip),%rax
        leaq    _DYNAMIC(%rip),%rdi     # &_DYNAMIC
        movq    %rdi,%rbx
@@ -59,6 +61,7 @@
        movq    %rbx,%rsi
        call    _rtld                   # _rtld(sp, relocbase)
 
+       leaq    -8(%r12),%rsp           # restore saved rsp, including %rbx
        popq    %rbx                    # %rbx = ps_strings
        popq    %rdx                    # %rdx = cleanup
        popq    %rcx                    # %rcx = obj_main



Home | Main Index | Thread Index | Old Index