%fs base in x86-64

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello, I am developing a small kernel for a research project and I
intend to make it compatible with linux binaries.
I can't find information (neither in google or linux sources) about
how linux treats ths thread local storage.

In this small sample program:

#include <stdio.h>
__thread a = 5;
int main()
{
	printf("%u\n", a);
	return 0;
}

this is the assembly code of the printf call in main:
  400558:	64 8b 14 25 fc ff ff 	mov    %fs:0xfffffffffffffffc,%edx
  40055f:	ff
  400560:	b8 6c 06 40 00       	mov    $0x40066c,%eax
  400565:	89 d6                	mov    %edx,%esi
  400567:	48 89 c7             	mov    %rax,%rdi
  40056a:	b8 00 00 00 00       	mov    $0x0,%eax
  40056f:	e8 dc fe ff ff       	callq  400450 <printf@plt>

Where does the fs segment points to? How linux sets up the virtual
memory for TLS?
Or, at least, where do I find this information? Or where this is done
in linux source?

I get the following with readelf:

  Type           Offset                  VirtAddr                      PhysAddr
                 FileSiz                      MemSiz
 Flags  Align

  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
                 0x0000000000000714 0x0000000000000714  R E    200000
  LOAD           0x0000000000000e14 0x0000000000600e14 0x0000000000600e14
                 0x000000000000020c 0x000000000000021c  RW     200000

  TLS         0x0000000000000e14 0x0000000000600e14 0x0000000000600e14
                 0x0000000000000004 0x0000000000000004  R      4

Thanks in advance

-- 
Eduardo Henrique Molina da Cruz
Bacharelado em Ciência da Computação
Universidade Estadual de Maringá

"Ciência da computação tem tanto a ver com o computador como a
Astronomia com o telescópio, a Biologia com o microscópio, ou a
Química com os tubos de ensaio. A Ciência não estuda ferramentas, mas
o que fazemos e o que descobrimos com elas." (Edsger Dijkstra)
--
To unsubscribe from this list: send the line "unsubscribe linux-x86_64" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux ia64]     [Linux Kernel]     [DCCP]     [Linux ARM]     [Yosemite News]     [Linux SCSI]     [Linux Hams]
  Powered by Linux