$ gcc -S hello.c
/* hello.s */  movl -60(%ebp), %eax  andl $3, %eax  movl -60(%ebp), %edx  movl %edx, %ecx  shrl $2, %ecx  leal -56(%ebp), %edi  movl -12(%ebp), %esi #APP  0: rep; movsl  movl %eax,%ecx 1: rep; movsb 2: .section .fixup,"ax" 3: lea 0(%eax,%ecx,4),%ecx  jmp 2b .previous .section __ex_table,"a"  .align 4  .long 0b,3b  .long 1b,2b .previous #NO_APP  movl %ecx, %eax 
 
  从上面通过gcc生成的汇编程序中,我们可以很容易的找到访问用户地址空间的指令,也就是程序中的标号为0和1的两条语句。而程序中伪操作.section的作用就是定义了.fixup和__ex_table这样的两个段,那么这两段在可执行程序中又是如何安排的呢?下面就通过objdump给读者一个直观的概念: 
$ objdump --section-headers hello hello: file format elf32-i386
Sections: 
Idx Name     Size   VMA    LMA    File off Algn  0 .interp    00000013 080480f4 080480f4 000000f4 2**0  CONTENTS, ALLOC, LOAD, READONLY, DATA  ………………………………  9 .init     00000018 080482e0 080482e0 000002e0 2**2  CONTENTS, ALLOC, LOAD, READONLY, CODE  10 .plt     00000070 080482f8 080482f8 000002f8 2**2  CONTENTS, ALLOC, LOAD, READONLY, CODE  11 .text     000001c0 08048370 08048370 00000370 2**4  CONTENTS, ALLOC, LOAD, READONLY, CODE  12 .fixup    00000009 08048530 08048530 00000530 2**0  CONTENTS, ALLOC, LOAD, READONLY, CODE  13 .fini     0000001e 0804853c 0804853c 0000053c 2**2  CONTENTS, ALLOC, LOAD, READONLY, CODE 
 
		    
                       
		      
		      
		   |