Date: Sun, 8 Apr 2012 18:36:45 -0700 From: Juli Mallett <jmallett@FreeBSD.org> To: Andrew Turner <andrew@fubar.geek.nz> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234014 - head/lib/libc/arm/gen Message-ID: <CACVs6=8SW9PhZaxc4KRnVyo5p6NyhdD09_cAowLCbgczDqBsVg@mail.gmail.com> In-Reply-To: <20120408164521.55aecdd1@fubar.geek.nz> References: <201204080436.q384aRXS093116@svn.freebsd.org> <20120408164521.55aecdd1@fubar.geek.nz>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Apr 7, 2012 at 21:45, Andrew Turner <andrew@fubar.geek.nz> wrote: > On Sun, 8 Apr 2012 04:36:27 +0000 (UTC) > Andrew Turner <andrew@FreeBSD.org> wrote: > >> Author: andrew >> Date: Sun Apr =C2=A08 04:36:27 2012 >> New Revision: 234014 >> URL: http://svn.freebsd.org/changeset/base/234014 >> >> Log: >> =C2=A0 Unlike other functions __aeabi_read_tp function must preserve >> r1-r3. The currently generated code clobbers r3. Fix this by loading >> ARM_TP_ADDRESS using inline assembly. >> >> =C2=A0 Approved by: =C2=A0 =C2=A0 =C2=A0 =C2=A0imp (mentor) > > This fixes thread local storage on ARM in cases when the compiler loads > the offset of the variable in r3 before calling __aeabi_read_tp as has > been observed when the variable is in a shared library. I don't believe this is safe unless you specify __attribute__ ((__naked__)) in the declaration =E2=80=94 currently the compiler is free t= o clobber registers that the calling convention/ABI allows it to clobber. I don't see the benefit of implementing this in C over using an assembly file, that said, although GCC does have this attribute precisely to allow one to write assembly in a C source file without having to worry about unexpected behavior. How do you know GCC won't allocate r2 to be used as a temporary in between the assembly and the return? I tried to raise this concern on IRC previously, but hopefully it's clearer= now. Thanks, Juli.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACVs6=8SW9PhZaxc4KRnVyo5p6NyhdD09_cAowLCbgczDqBsVg>