Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Aug 2012 05:30:20 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r239031 - head/libexec/rtld-elf/arm
Message-ID:  <201208040530.q745UKpP013972@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Sat Aug  4 05:30:20 2012
New Revision: 239031
URL: http://svn.freebsd.org/changeset/base/239031

Log:
  Ensure we align the stack to 8 bytes in rtld.
  
  This is not strictly required with the current ABI but will be when we
  switch to the ARM EABI. The aapcs requires the stack to be 4 byte aligned
  at all times and 8 byte aligned when calling a public subroutine where the
  current ABI only requires sp to be a multiple of 4.

Modified:
  head/libexec/rtld-elf/arm/rtld_start.S

Modified: head/libexec/rtld-elf/arm/rtld_start.S
==============================================================================
--- head/libexec/rtld-elf/arm/rtld_start.S	Sat Aug  4 04:30:26 2012	(r239030)
+++ head/libexec/rtld-elf/arm/rtld_start.S	Sat Aug  4 05:30:20 2012	(r239031)
@@ -37,6 +37,8 @@ __FBSDID("$FreeBSD$");
 	.globl	.rtld_start
 	.type	.rtld_start,%function
 .rtld_start:
+	mov	r6, sp			/* save the stack pointer */
+	bic	sp, sp, #7		/* align the stack pointer */
 	sub	sp, sp, #8		/* make room for obj_main & exit proc */
 	mov	r4, r0			/* save ps_strings */
 	ldr	sl, .L2
@@ -52,13 +54,13 @@ __FBSDID("$FreeBSD$");
 	bl	_rtld_relocate_nonplt_self
 	mov	r1, sp
 	add	r2, sp, #4
-	add	r0, sp, #8
+	mov	r0, r6			/* load the sp the kernel gave us */
 	bl	_rtld			/* call the shared loader */
 	mov	r3, r0			/* save entry point */
 
 	ldr	r2, [sp, #0]		/* r2 = cleanup */
 	ldr	r1, [sp, #4]		/* r1 = obj_main */
-	add	sp, sp, #8		/* restore stack */
+	mov	sp, r6			/* restore stack */
 	mov	r0, r4			/* restore ps_strings */
 	mov	pc, r3			/* jump to the entry point */
 .L2:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201208040530.q745UKpP013972>