From owner-svn-soc-all@FreeBSD.ORG Tue Jul 5 14:48:39 2011 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 630DE106567A for ; Tue, 5 Jul 2011 14:48:37 +0000 (UTC) (envelope-from xxp@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 05 Jul 2011 14:48:37 +0000 Date: Tue, 05 Jul 2011 14:48:37 +0000 From: xxp@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20110705144837.630DE106567A@hub.freebsd.org> Cc: Subject: socsvn commit: r223960 - in soc2011/xxp/xxp-head/libexec/rtld-elf: amd64 i386 X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 14:48:39 -0000 Author: xxp Date: Tue Jul 5 14:48:37 2011 New Revision: 223960 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=223960 Log: Annotate rtld-elf. Modified: soc2011/xxp/xxp-head/libexec/rtld-elf/amd64/rtld_start.S soc2011/xxp/xxp-head/libexec/rtld-elf/i386/rtld_start.S Modified: soc2011/xxp/xxp-head/libexec/rtld-elf/amd64/rtld_start.S ============================================================================== --- soc2011/xxp/xxp-head/libexec/rtld-elf/amd64/rtld_start.S Tue Jul 5 13:45:10 2011 (r223959) +++ soc2011/xxp/xxp-head/libexec/rtld-elf/amd64/rtld_start.S Tue Jul 5 14:48:37 2011 (r223960) @@ -31,13 +31,16 @@ .type .rtld_start,@function .rtld_start: xorq %rbp,%rbp # Clear frame pointer for good form + cfi_def_cfa(%rsp,0) subq $24,%rsp # A place to store exit procedure addr + cfi_adjust_cfa_offset(24) 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 + cfi_adjust_cfa_offset(-8) movq %r12,%rdi # *ap /* * At this point, %rax contains the entry point of the main program, and @@ -80,16 +83,27 @@ .type _rtld_bind_start,@function _rtld_bind_start: subq $8,%rsp + cfi_adjust_cfa_offset(8) pushfq # Save rflags + cfi_adjust_cfa_offset(8) pushq %rax # Save %rax + cfi_adjust_cfa_offset(8) pushq %rdx # Save %rdx + cfi_adjust_cfa_offset(8) pushq %rcx # Save %rcx + cfi_adjust_cfa_offset(8) pushq %rsi # Save %rsi + cfi_adjust_cfa_offset(8) pushq %rdi # Save %rdi + cfi_adjust_cfa_offset(8) pushq %r8 # Save %r8 + cfi_adjust_cfa_offset(8) pushq %r9 # Save %r9 + cfi_adjust_cfa_offset(8) pushq %r10 # Save %r10 + cfi_adjust_cfa_offset(8) pushq %r11 # Save %r11 + cfi_adjust_cfa_offset(8) movq 0x58(%rsp),%rdi # Fetch obj argument movq 0x60(%rsp),%rsi # Fetch reloff argument @@ -101,15 +115,25 @@ movq %rax,0x60(%rsp) # Store target over reloff argument popq %r11 # Restore %r11 + cfi_adjust_cfa_offset(-8) popq %r10 # Restore %r10 + cfi_adjust_cfa_offset(-8) popq %r9 # Restore %r9 + cfi_adjust_cfa_offset(-8) popq %r8 # Restore %r8 + cfi_adjust_cfa_offset(-8) popq %rdi # Restore %rdi + cfi_adjust_cfa_offset(-8) popq %rsi # Restore %rsi + cfi_adjust_cfa_offset(-8) popq %rcx # Restore %rcx + cfi_adjust_cfa_offset(-8) popq %rdx # Restore %rdx + cfi_adjust_cfa_offset(-8) popq %rax # Restore %rax + cfi_adjust_cfa_offset(-8) popfq # Restore rflags + cfi_adjust_cfa_offset(-8) leaq 16(%rsp),%rsp # Discard spare, obj, do not change rflags ret # "Return" to target address Modified: soc2011/xxp/xxp-head/libexec/rtld-elf/i386/rtld_start.S ============================================================================== --- soc2011/xxp/xxp-head/libexec/rtld-elf/i386/rtld_start.S Tue Jul 5 13:45:10 2011 (r223959) +++ soc2011/xxp/xxp-head/libexec/rtld-elf/i386/rtld_start.S Tue Jul 5 14:48:37 2011 (r223960) @@ -34,18 +34,27 @@ movl %esp,%eax # Save initial stack pointer movl %esp,%esi # Save initial stack pointer andl $0xfffffff0,%esp # Align stack pointer + cfi_def_cfa(%esp,0) subl $16,%esp # A place to store exit procedure addr + cfi_adjust_cfa_offset(16) movl %esp,%ebx # save address of exit proc movl %esp,%ecx # construct address of obj_main addl $4,%ecx subl $4,%esp # Keep stack aligned + cfi_adjust_cfa_offset(4) pushl %ecx # Pass address of obj_main + cfi_adjust_cfa_offset(4) pushl %ebx # Pass address of exit proc + cfi_adjust_cfa_offset(4) pushl %eax # Pass initial stack pointer to rtld + cfi_adjust_cfa_offset(4) call _rtld@PLT # Call rtld(sp); returns entry point addl $16,%esp # Remove arguments from stack + cfi_adjust_cfa_offset(-16) popl %edx # Get exit procedure address + cfi_adjust_cfa_offset(-4) movl %esi,%esp # Ignore obj_main + cfi_def_cfa(%esp,0) /* * At this point, %eax contains the entry point of the main program, and * %edx contains a pointer to a termination function that should be @@ -72,21 +81,32 @@ .type _rtld_bind_start,@function _rtld_bind_start: pushf # Save eflags + cfi_adjust_cfa_offset(4) pushl %eax # Save %eax + cfi_adjust_cfa_offset(4) pushl %edx # Save %edx + cfi_adjust_cfa_offset(4) pushl %ecx # Save %ecx + cfi_adjust_cfa_offset(4) pushl 20(%esp) # Copy reloff argument + cfi_adjust_cfa_offset(4) pushl 20(%esp) # Copy obj argument + cfi_adjust_cfa_offset(4) call _rtld_bind@PLT # Transfer control to the binder /* Now %eax contains the entry point of the function being called. */ addl $8,%esp # Discard binder arguments + cfi_adjust_cfa_offset(-8) movl %eax,20(%esp) # Store target over obj argument popl %ecx # Restore %ecx + cfi_adjust_cfa_offset(-4) popl %edx # Restore %edx + cfi_adjust_cfa_offset(-4) popl %eax # Restore %eax + cfi_adjust_cfa_offset(-4) popf # Restore eflags + cfi_adjust_cfa_offset(-4) leal 4(%esp),%esp # Discard reloff, do not change eflags ret # "Return" to target address