From owner-svn-src-all@FreeBSD.ORG Thu Jul 10 09:55:38 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BA49DEE1; Thu, 10 Jul 2014 09:55:38 +0000 (UTC) Received: from h2.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "funkthat.com", Issuer "funkthat.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 8907E27CE; Thu, 10 Jul 2014 09:55:38 +0000 (UTC) Received: from h2.funkthat.com (localhost [127.0.0.1]) by h2.funkthat.com (8.14.3/8.14.3) with ESMTP id s6A9tb5q025781 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 10 Jul 2014 02:55:37 -0700 (PDT) (envelope-from jmg@h2.funkthat.com) Received: (from jmg@localhost) by h2.funkthat.com (8.14.3/8.14.3/Submit) id s6A9tbMq025780; Thu, 10 Jul 2014 02:55:37 -0700 (PDT) (envelope-from jmg) Date: Thu, 10 Jul 2014 02:55:37 -0700 From: John-Mark Gurney To: Nathan Whitehorn Subject: Re: svn commit: r268310 - head/libexec/rtld-elf/arm Message-ID: <20140710095537.GW45513@funkthat.com> References: <201407061024.s66AO6R9012248@svn.freebsd.org> <53B9A1CD.2010803@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <53B9A1CD.2010803@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Operating-System: FreeBSD 7.2-RELEASE i386 X-PGP-Fingerprint: 54BA 873B 6515 3F10 9E88 9322 9CB1 8F74 6D3F A396 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html X-TipJar: bitcoin:13Qmb6AeTgQecazTWph4XasEsP7nGRbAPE X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.2 (h2.funkthat.com [127.0.0.1]); Thu, 10 Jul 2014 02:55:37 -0700 (PDT) Cc: Andrew Turner , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jul 2014 09:55:38 -0000 Nathan Whitehorn wrote this message on Sun, Jul 06, 2014 at 12:21 -0700: > Thank you! I can now upgrade my AVILA for the first time in 3 years. > Most things seem to work fine, despite the long absence. Per my email to -arm... Let me know if you have any further issues w/ it... > On 07/06/14 03:24, Andrew Turner wrote: > >Author: andrew > >Date: Sun Jul 6 10:24:06 2014 > >New Revision: 268310 > >URL: http://svnweb.freebsd.org/changeset/base/268310 > > > >Log: > > Align the stack in _rtld_bind_start. Normally this is called with the > > correct stack alignment, however when we have a leaf function that uses > > thread local storage it calls __aeabi_read_tp to get the thread pointer. > > Neither GCC or clang see this as a function call so will align the stack > > to a 4-byte boundary. This may be a problem as _rtld_bind expects to be > > on an 8-byte boundary. > > > > The solution is to store a copy of the stack pointer and force the > > alignment before calling _rtld_bind. > > > > This fixes a problem with armeb where applications would crash in odd > > ways. > > It should also remove the need for a local patch to clang to force the > > stack alignment to an 8-byte boundary, even for leaf functions. Further > > testing will be needed before reverting this local change to clang as we > > may rely on it in other places. > > > > Reviewed by: jmg@ > > > >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 Sun Jul 6 07:34:18 2014 > >(r268309) > >+++ head/libexec/rtld-elf/arm/rtld_start.S Sun Jul 6 10:24:06 2014 > >(r268310) > >@@ -77,7 +77,7 @@ __FBSDID("$FreeBSD$"); > > * lr = &GOT[2] > > */ > > _rtld_bind_start: > >- stmdb sp!,{r0-r4,sl,fp} > >+ stmdb sp!,{r0-r5,sl,fp} > > > > sub r1, ip, lr /* r1 = 4 * (n + 1) */ > > sub r1, r1, #4 /* r1 = 4 * n */ > >@@ -86,11 +86,14 @@ _rtld_bind_start: > > ldr r0, [lr, #-4] /* get obj ptr from GOT[1] */ > > mov r4, ip /* save GOT location */ > > > >+ mov r5, sp /* Save the stack pointer */ > >+ bic sp, sp, #7 /* Align the stack pointer */ > > bl _rtld_bind /* Call the binder */ > >+ mov sp, r5 /* Restore the old stack pointer */ > > > > str r0, [r4] /* save address in GOT */ > > mov ip, r0 /* save new address */ > > > >- ldmia sp!,{r0-r4,sl,fp,lr} /* restore the stack */ > >+ ldmia sp!,{r0-r5,sl,fp,lr} /* restore the stack */ > > mov pc, ip /* jump to the new address */ > > > > > -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."