background image

1. 编译环境

   OS: Axianux 1.0
   Compiler: gcc 3..2.3

   Linker: Solaris Link Editors 5.x
   Debug Tool: gdb
   Editor: vi
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

2. 最简 代码分析
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

为简化问题,来分析一下最简的 c 代码生成的汇编代码:

    # vi test1.c  
    int main()
    {
        return 0;
    }   
     编译该程序,产生二进制文件:
    # gcc -o start start.c

file start     

start: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for 
GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped
     start 是一个 ELF 格式 32 位小端(Little Endian)的可执行文件,动态链接
并且符号表没有去除。这正是 Unix/Linux 平台典型的可执行文件格式。

     用 gdb 反汇编可以观察生成的汇编代码:

[wqf@15h166 attack]$ gdb start

GNU gdb Asianux (6.0post-0.20040223.17.1AX)

Copyright 2004 Free Software Foundation, Inc.

GDB is free software, covered by the GNU General Public License, and 
you are welcome to change it and/or distribute copies of it under 
certain conditions.

Type "show copying" to see the conditions.