On Fri, Nov 02, 2007 at 11:09:33PM -0700, Ian Lance Taylor wrote:
> skaller <[EMAIL PROTECTED]> writes:
> 
> > > As I said before, the register is only stolen for code which actually
> > > uses TLS.
> > 
> > So scanning that document, for x86_64, fs is used in startup
> > code, presumably if, and only if, there is a linker section
> > containing __thread variables?
> 
> Yes.

Well, at least on Linux given that libc uses it heavily internally and
also libpthread implementation uses that register (though different
area outside of what is used for __thread vars) for thread control
structure, this is "always".  On x86_64 %fs is simply part of ABI,
reserved register for implementation (similarly %gs on i386, other arches
usually have one or several registers reserved for implementation as well).
You can use another segment register, which is free for use by apps
(%gs on x86_64, %fs on i386) in your app, though of course note that for
changing it you need a syscall, so its use certainly isn't free.

        Jakub

Reply via email to