无效返回输入(无效) { 字符数组[30]; 获取(数组); printf("%s\n", 数组); }
在 gcc 中编译后,该函数转换为以下汇编代码:
推%ebp mov %esp,%ebp 低于 $0x28,%esp 移动 %gs:0x14,%eax mov %eax,-0x4(%ebp) xor %eax,%eax lea -0x22(%ebp),%eax mov %eax,(%esp) 拨打 0x8048374 lea -0x22(%ebp),%eax mov %eax,(%esp) 呼叫 0x80483a4 mov -0x4(%ebp),%eax 异或 %gs:0x14,%eax 0x80484ac 拨打 0x8048394 离开 ret
我不明白两行:
移动 %gs:0x14,%eax 异或 %gs:0x14,%eax
什么是%gs,这两行到底是做什么的?
这是编译命令:
cc -c -mpreferred-stack-boundary=2 -ggdb file.c