PERFORCE change 31728 for review

Peter Wemm peter at FreeBSD.org
Fri May 23 14:09:52 PDT 2003


http://perforce.freebsd.org/chv.cgi?CH=31728

Change 31728 by peter at peter_hammer on 2003/05/23 14:09:06

	make this assemble.  The arguments have not been updated yet.
	In particular, need to take the pointer in %rdi, not %rsp

Affected files ...

.. //depot/projects/hammer/libexec/rtld-elf/amd64/rtld_start.S#5 edit

Differences ...

==== //depot/projects/hammer/libexec/rtld-elf/amd64/rtld_start.S#5 (text+ko) ====

@@ -25,25 +25,24 @@
  * $FreeBSD: src/libexec/rtld-elf/amd64/rtld_start.S,v 1.3 1999/08/28 00:10:15 peter Exp $
  */
 
-.error finish update please. needs to be updated for calling conventions at the very least
 	.text
 	.align	4
 	.globl	.rtld_start
 	.type	.rtld_start, at function
 .rtld_start:
-	xorl	%rbp,%rbp		# Clear frame pointer for good form
-	movl	%rsp,%rax		# Save initial stack pointer
-	subl	$8,%rsp			# A place to store exit procedure addr
-	movl	%rsp,%rbx		# save address of exit proc
-	movl	%rsp,%rcx		# construct address of obj_main
-	addl	$4,%rcx
-	pushl	%rcx			# Pass address of obj_main
-	pushl	%rbx			# Pass address of exit proc
-	pushl	%rax			# Pass initial stack pointer to rtld
+	xorq	%rbp,%rbp		# Clear frame pointer for good form
+	movq	%rsp,%rax		# Save initial stack pointer
+	subq	$16,%rsp		# A place to store exit procedure addr
+	movq	%rsp,%rbx		# save address of exit proc
+	movq	%rsp,%rcx		# construct address of obj_main
+	addq	$8,%rcx
+	pushq	%rcx			# Pass address of obj_main
+	pushq	%rbx			# Pass address of exit proc
+	pushq	%rax			# Pass initial stack pointer to rtld
 	call	_rtld at PLT		# Call rtld(sp); returns entry point
-	addl	$12,%rsp		# Remove arguments from stack
-	popl	%rdx			# Get exit procedure address
-	addl	$4,%rsp			# Ignore obj_main
+	addq	$24,%rsp		# Remove arguments from stack
+	popq	%rdx			# Get exit procedure address
+	addq	$8,%rsp			# Ignore obj_main
 /*
  * At this point, %rax contains the entry point of the main program, and
  * %rdx contains a pointer to a termination function that should be
@@ -69,21 +68,21 @@
 	.globl	_rtld_bind_start
 	.type	_rtld_bind_start, at function
 _rtld_bind_start:
-	pushf				# Save eflags
-	pushl	%rax			# Save %rax
-	pushl	%rdx			# Save %rdx
-	pushl	%rcx			# Save %rcx
-	pushl	20(%rsp)		# Copy reloff argument
-	pushl	20(%rsp)		# Copy obj argument
+	pushfq				# Save eflags
+	pushq	%rax			# Save %rax
+	pushq	%rdx			# Save %rdx
+	pushq	%rcx			# Save %rcx
+	pushq	20(%rsp)		# Copy reloff argument
+	pushq	20(%rsp)		# Copy obj argument
 
 	call	_rtld_bind at PLT		# Transfer control to the binder
 	/* Now %rax contains the entry point of the function being called. */
 
-	addl	$8,%rsp			# Discard binder arguments
-	movl	%rax,20(%rsp)		# Store target over obj argument
-	popl	%rcx			# Restore %rcx
-	popl	%rdx			# Restore %rdx
-	popl	%rax			# Restore %rax
-	popf				# Restore eflags
-	leal	4(%rsp),%rsp		# Discard reloff, do not change eflags
+	addq	$16,%rsp		# Discard binder arguments
+	movq	%rax,20(%rsp)		# Store target over obj argument
+	popq	%rcx			# Restore %rcx
+	popq	%rdx			# Restore %rdx
+	popq	%rax			# Restore %rax
+	popfq				# Restore eflags
+	leaq	8(%rsp),%rsp		# Discard reloff, do not change eflags
 	ret				# "Return" to target address


More information about the p4-projects mailing list