浅析C语言编程中的数组越界问题

2020-01-06 13:51:08刘景俊
  • movl %esp, %ebp  subl $40, %esp 
  • movl $0, -24(%ebp)  movl $0, -20(%ebp) 
  • movl $0, -16(%ebp)  movl $0, -12(%ebp) 
  • movl $0, -8(%ebp)  movl $1, -24(%ebp) 
  • movl $2, -20(%ebp)  movl $3, -16(%ebp) 
  • movl $1, -4(%ebp)  movl $0, -4(%ebp) 
  • jmp .L2  .L3: 
  • movl -4(%ebp), %edx  movl -4(%ebp), %eax 
  • movl %eax, -24(%ebp,%edx,4)  addl $1, -4(%ebp) 
  • .L2:  cmpl $9, -4(%ebp) 
  • jle .L3  movl $.LC0, (%esp) 
  • call puts  leave 
  • ret  .size f, .-f ;用以计算函数f的大小 
  • .section .rodata  .LC1: 
  • .string "ok"  .text 
  • .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 
  • movl $3, (%esp)  call f 
  • movl $.LC1, (%esp)  call puts 
  • addl $4, %esp  popl %ecx 
  • popl %ebp  leal -4(%ecx), %esp 
  • ret  .size main, .-main 
  • .ident "GCC: (GNU) 4.1.2 20070115 (SUSE Linux)" ;说明是用什么工具编译的  .section .note.GNU-stack,"",@progbits