PERFORCE change 49349 for review
Peter Wemm
peter at FreeBSD.org
Fri Mar 19 23:25:35 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=49349
Change 49349 by peter at 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, at 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 at 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 at 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
More information about the p4-projects
mailing list