相关疑难解决方法(0)

什么是装配中的%gs

void return_input (void)
{ 
   char array[30]; 

   gets (array); 
   printf("%s\n", array); 
}

在gcc中编译后,此函数将转换为以下汇编代码:

push   %ebp
mov    %esp,%ebp
sub    $0x28,%esp
mov    %gs:0x14,%eax
mov    %eax,-0x4(%ebp)
xor    %eax,%eax
lea    -0x22(%ebp),%eax
mov    %eax,(%esp)
call   0x8048374 
lea    -0x22(%ebp),%eax
mov    %eax,(%esp)
call   0x80483a4 
mov    -0x4(%ebp),%eax
xor    %gs:0x14,%eax
je     0x80484ac 
call   0x8048394 
leave  
ret  

我不明白两行:

mov    %gs:0x14,%eax
xor    %gs:0x14,%eax

什么是%gs,这两条线到底是做什么的?

这是编译命令:

cc -c -mpreferred-stack-boundary=2 -ggdb file.c

linux x86 assembly

15
推荐指数
2
解决办法
2万
查看次数

标签 统计

assembly ×1

linux ×1

x86 ×1