From owner-p4-projects@FreeBSD.ORG Fri Mar 19 23:25:35 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6B16916A4D0; Fri, 19 Mar 2004 23:25:35 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2BEB316A4CE for ; Fri, 19 Mar 2004 23:25:35 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0CA2D43D1F for ; Fri, 19 Mar 2004 23:25:35 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i2K7PYGe026375 for ; Fri, 19 Mar 2004 23:25:34 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i2K7PY2Q026372 for perforce@freebsd.org; Fri, 19 Mar 2004 23:25:34 -0800 (PST) (envelope-from peter@freebsd.org) Date: Fri, 19 Mar 2004 23:25:34 -0800 (PST) Message-Id: <200403200725.i2K7PY2Q026372@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 49349 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Mar 2004 07:25:35 -0000 http://perforce.freebsd.org/chv.cgi?CH=49349 Change 49349 by peter@peter_overcee on 2004/03/19 23:25:14 argh! Fix up (I think) more misaligned stack problems. _rtld() was being called with an unaligned stack, which caused any _init()s in shared libs to be called unaligned. _rtld_bind() was also being called unaligned. Affected files ... .. //depot/projects/hammer/libexec/rtld-elf/amd64/rtld_start.S#12 edit Differences ... ==== //depot/projects/hammer/libexec/rtld-elf/amd64/rtld_start.S#12 (text+ko) ==== @@ -31,14 +31,13 @@ .type .rtld_start,@function .rtld_start: xorq %rbp,%rbp # Clear frame pointer for good form - subq $16,%rsp # A place to store exit procedure addr + subq $24,%rsp # A place to store exit procedure addr movq %rdi,%r12 movq %rsp,%rsi # save address of exit proc movq %rsp,%rdx # construct address of obj_main addq $8,%rdx call _rtld@PLT # Call rtld(sp); returns entry point popq %rsi # Get exit procedure address - addq $8,%rsp # Ignore obj_main movq %r12,%rdi # *ap /* * At this point, %rax contains the entry point of the main program, and @@ -62,8 +61,9 @@ * assembly-language code that is not ABI-compliant. * * Stack map: - * reloff 0x58 - * obj 0x50 + * reloff 0x60 + * obj 0x58 + * spare 0x50 * rflags 0x48 * rax 0x40 * rdx 0x38 @@ -90,15 +90,15 @@ pushq %r10 # Save %r10 pushq %r11 # Save %r11 - movq 0x50(%rsp),%rdi # Fetch obj argument - movq 0x58(%rsp),%rsi # Fetch reloff argument + movq 0x58(%rsp),%rdi # Fetch obj argument + movq 0x60(%rsp),%rsi # Fetch reloff argument leaq (%rsi,%rsi,2),%rsi # multiply by 3 leaq (,%rsi,8),%rsi # now 8, for 24 (sizeof Elf_Rela) call _rtld_bind@PLT # Transfer control to the binder /* Now %rax contains the entry point of the function being called. */ - movq %rax,0x58(%rsp) # Store target over reloff argument + movq %rax,0x60(%rsp) # Store target over reloff argument popq %r11 # Restore %r11 popq %r10 # Restore %r10 popq %r9 # Restore %r9