Re: cvs commit: src/lib/libc/gen tls.c src/lib/libc/i386/gen Mak

看板DFBSD_commit作者時間21年前 (2005/04/13 02:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串4/4 (看更多)
On Wed, Mar 30, 2005 at 04:32:45AM +0200, Joerg Sonnenberger wrote: > On Tue, Mar 29, 2005 at 06:25:58PM -0800, Matthew Dillon wrote: > > > > : > > :On Tue, Mar 29, 2005 at 11:26:20AM -0800, Joerg Sonnenberger wrote: > > :> joerg 2005/03/29 11:26:20 PST > > :> > > :> Added files: > > :> sys/i386/include tls.h > > : > > :I'm open for any advice how to teach GCC to create correct assembly > > :for the #if'd out sections. > > : > > :Joerg > > > > As far as GAS is concerned, it's a memory effective address (remove > > the %gs: prefix and it becomes clear). So: > > > > __asm __volatile ("movl %%gs:%1,%0" : "=r" (self) : > > "m" (((struct tls_tcb *)0)->self)); > > That's what I initialy thought too. The problem is that the above statement > is assembled to: > .LC0: > .long 0 /* value of ((struct tls_tcb *)0)->self */ > > main: > ... > movl %gs:.LC0,%eax > > which is clearly something different. No, __asm __volatile ("movl %%gs:%1,%0" : "=r" (self) : "m" (((struct tls_tcb *)0)->tcb_pthread)); properly assembles to movl %gs:8, %eax whereas __asm __volatile ("movl %%gs:%1,%0" : "=r" (self) : "m" __offsetof(struct tls_tcb, tcb_pthread)); doesn't. "m" expects a memory operand, but __offsetof() returns the address of a structure member whose base address is zero casted to size_t(which is clearly not a memory reference). It seems to me that if the constraint "m" is given a non-memory operand, gcc sets up a temporary storage(.LC0 above) and store the operand to that location for consistency.
文章代碼(AID): #12N0qJ00 (DFBSD_commit)
文章代碼(AID): #12N0qJ00 (DFBSD_commit)