linux – 什么是汇编中的%gs
发布时间:2021-01-24 09:05:11 所属栏目:Linux 来源:互联网
导读:void return_input (void){ char array[30]; gets (array); printf(%sn, array); } 在gcc中编译之后,此函数将转换为以下程序集代码: push %ebpmov %esp,%ebpsub $0x28,%espmov %gs:0x14,%eaxmov %
void return_input (void) { char array[30]; gets (array); printf("%sn",array); } 在gcc中编译之后,此函数将转换为以下程序集代码: push %ebp mov %esp,%ebp sub $0x28,%esp mov %gs:0x14,%eax mov %eax,-0x4(%ebp) xor %eax,%eax lea -0x22(%ebp),(%esp) call 0x8048374 lea -0x22(%ebp),(%esp) call 0x80483a4 mov -0x4(%ebp),%eax xor %gs:0x14,%eax je 0x80484ac call 0x8048394 leave ret 我不明白两行: mov %gs:0x14,%eax 什么是%gs,这两行究竟是什么呢? 这是编译命令: cc -c -mpreferred-stack-boundary=2 -ggdb file.c 解决方法GS是一个段寄存器,其在linux中的使用可以在 here上读取(它基本上用于每个进程数据).mov %gs:0x14,%eax 该代码用于验证堆栈没有爆炸或已被证实,使用存储在GS 0x14中的金丝雀值,参见this. (编辑:4S站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读