在x86-64架构中,两个寄存器具有特殊用途:FS和GS.在linux 2.6.*中,FS寄存器似乎用于存储线程本地信息.
我写了一段C代码,我已经拆解了它,并阅读了寄存器以了解程序在汇编中的工作原理.
int test(char *this){
char sum_buf[6];
strncpy(sum_buf,this,32);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我一直在研究的代码是测试功能.当我反汇编输出我的测试功能时,我得到...
0x00000000004005c0 <+12>: mov %fs:0x28,%rax
=> 0x00000000004005c9 <+21>: mov %rax,-0x8(%rbp)
... stuff ..
0x00000000004005f0 <+60>: xor %fs:0x28,%rdx
0x00000000004005f9 <+69>: je 0x400600 <test+76>
0x00000000004005fb <+71>: callq 0x4004a0 <__stack_chk_fail@plt>
0x0000000000400600 <+76>: leaveq
0x0000000000400601 <+77>: retq
Run Code Online (Sandbox Code Playgroud)
我想知道的mov %fs:0x28,%rax是真正在做什么?