代码: 全选
#include <stdio.h>
void return_input (void){
char array[10];
gets (array);
printf("%s\n", array);
}
int main()
{
return_input();
return 0;
}
用GCC反汇编后的代码:
代码: 全选
.file "test11.c"
.text
.globl return_input
.type return_input, @function
return_input:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
movl %gs:20, %eax //这个%gs:20值是什么,希望能详细解释下
movl %eax, -4(%ebp)
xorl %eax, %eax
leal -14(%ebp), %eax
movl %eax, (%esp)
call gets
leal -14(%ebp), %eax
movl %eax, (%esp)
call puts
movl -4(%ebp), %eax
xorl %gs:20, %eax
je .L3
call __stack_chk_fail
.L3:
leave
ret
.size return_input, .-return_input
.globl main
.type main, @function
main:
leal 4(%esp), %ecx
andl $-16, %esp
pushl -4(%ecx)
pushl %ebp
movl %esp, %ebp
pushl %ecx
subl $4, %esp
call return_input
movl $0, %eax
addl $4, %esp
popl %ecx
popl %ebp
leal -4(%ecx), %esp
ret
.size main, .-main
.ident "GCC: (GNU) 4.2.3 (Ubuntu 4.2.3-2ubuntu7)"
.section .note.GNU-stack,"",@progbits