summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2004-03-21 01:43:39 +0000
committerpeter <peter@FreeBSD.org>2004-03-21 01:43:39 +0000
commit88a11443a2eb7eecfe71b407b9c51bc4d9e14a07 (patch)
tree53a3c1e90f84179d25360d9b62c3830ebadcde7d /libexec
parent51e25854554afb1f8b8ac4612f655e4549758b94 (diff)
downloadFreeBSD-src-88a11443a2eb7eecfe71b407b9c51bc4d9e14a07.zip
FreeBSD-src-88a11443a2eb7eecfe71b407b9c51bc4d9e14a07.tar.gz
More stack alignment fixes. Arrange so we call _rtld() in ld-elf.so.1
with the correct alignment. This is important because this calls to library static constructors are made from here. The bug in the old crt*.s files hid this because in this case, two wrongs do indeed make a right. Also, call _rtld_bind() with the correct alignment, because it calls back into the pthread library locking functions. If things happen just the wrong way, we get a SIG10 due to the broken stack alignment.
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rtld-elf/amd64/rtld_start.S17
1 files changed, 9 insertions, 8 deletions
diff --git a/libexec/rtld-elf/amd64/rtld_start.S b/libexec/rtld-elf/amd64/rtld_start.S
index c2c6b9c..4cdad22 100644
--- a/libexec/rtld-elf/amd64/rtld_start.S
+++ b/libexec/rtld-elf/amd64/rtld_start.S
@@ -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
@@ -79,6 +79,7 @@
.globl _rtld_bind_start
.type _rtld_bind_start,@function
_rtld_bind_start:
+ subq $8,%rsp
pushfq # Save rflags
pushq %rax # Save %rax
pushq %rdx # Save %rdx
@@ -90,15 +91,15 @@ _rtld_bind_start:
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
@@ -109,5 +110,5 @@ _rtld_bind_start:
popq %rdx # Restore %rdx
popq %rax # Restore %rax
popfq # Restore rflags
- leaq 8(%rsp),%rsp # Discard obj, do not change rflags
+ leaq 16(%rsp),%rsp # Discard spare, obj, do not change rflags
ret # "Return" to target address
OpenPOWER on IntegriCloud