On Tue, Oct 31, 2017 at 11:43 AM, <melodyhu...@gmail.com> wrote: > > I have one question about tls field in the m struct. > > I see fs:0FFFFFFFFFFFFFFF8h is storing the pointer to current g which is the > first element in tls field. > > In the m struct. tls is an six elements pointer array. I see the last five > has 0 value in it. I wonder what are these 5 elements storing as design?
This is driven mainly by 386 GNU/Linux, on which we pass the address of the m's tls field to the set_thread_area system call. We the %gs segment selector to point to &m->tls[4], and then we want to make system calls via 0x10(%gs), or at least we used to before https://golang.org/issue/14476. The dynamic linker stores the vdso helper at 0x10(%gs), so we need to set the length of the tls array to 6 to make sure there is room for that. But I don't recall why we set the segment selector to the address of the 4th element. It may have something to do with Darwin. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.