Re: What is the purpose of %fs?



Josef Moellers wrote:
> While trying to analyse a problem with snmpd, I stumbled across
> instructions in the tls/libc that reference %fs. Where could I find
> information about the contents of that segment?
>
> I've single-stepped through a small printf("Hello, world")-program but
> have found no instruction which populates this segment, yet it seems to
> exist and contains data.

It provides an addressing space for thread-local storage ("TLS").
See __NR_set_thread_area, __NR_get_thread_area in /usr/include/asm/unistd.h
and the code for clone() in the glibc sources in
glibc-2.3.5/sysdeps/unix/sysv/linux/i386/clone.S .
Note that clone() takes 7 arguments as glibc routine,
but only 5 as a system call. One of the arguments is
the address to use for the base of %fs (or %gs, depending on machine.)
Note that glibc considers this to be none of your business.

--
.



Relevant Pages

  • Re: Off Topic: use delete to destroy primitive/object types but memory is not freed
    ... Each C pointer is a descriptor that names an address ... upon loading a segment register. ... Part requires that the compiler emit instructions whose sole ...
    (comp.lang.c)
  • Re: What is the purpose of %fs?
    ... instructions in the tls/libc that reference %fs. ... Where could I find information about the contents of that segment? ... It does crash at a different location where it reads from an already freed location. ...
    (comp.os.linux.development.system)
  • Re: Which assembler can handle the BIG stuff ?
    ... How can I quote out of context when I gave the context? ... the fact that the 68000 processor does have memory segmentation issues. ... >segments that the Segment Loader loads into and out of memory. ... >PC-relative instructions. ...
    (alt.lang.asm)
  • Re: C++: 64 bit performance vs. 32 bit
    ... Several IA-32 instructions are deprecated in AMD64. ... AAD-ASCII Adjust Before Division ... LDS-Load DS Segment Register ... POP DS-Pop Stack into DS Segment ...
    (comp.arch)
  • Re: Which assembler can handle the BIG stuff ?
    ... >>PC-relative instructions. ... you don't know the meaning of the term "segment". ... > We use jump tables to jump, not to call pointers, but ... > That is except with idiot ASM programmers in this newsgroup who don't know any ...
    (alt.lang.asm)