易截截图软件、单文件、免安装、纯绿色、仅160KB

Linux下GCC编程四个过程(2)


2)编译阶段
(Compiling)
第二步进行的是编译阶段,在这个阶段中,Gcc首先要检查代码的规范性、是否有语法错误等,以确定代码的实际要做的工作,在检查无误后,Gcc把代码翻译成汇编语言。用户可以使用”-S”选项来进行查看,该选项只进行编译而不进行汇编,生成汇编代码。
选项 -S
用法:[root]# gcc –S hello.i –o hello.s
作用:将预处理输出文件hello.i汇编成hello.s文件。
[root@richard hello-gcc]# ls
hello.c  hello.i  hello.s
如下为hello.s汇编代码
[root@richard hello-gcc]# vi hello.s
.file   "hello.c"
.section    .rodata
.LC0:
.string "hello world!\r\n"
.text
.globl main
.type   main,@function
main:
pushl   %ebp
movl    %esp, %ebp
subl    $8, %esp
andl    $-16, %esp
movl    $0, %eax
subl    %eax, %esp
subl    $12, %esp
pushl   $.LC0
call    printf
addl    $16, %esp
movl    $0, %eax
leave
ret
.Lfe1:
.size   main,.Lfe1-main
.ident  "GCC: (GNU) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)"
3)汇编阶段(Assembling)
汇编阶段是把编译阶段生成的”.s”文件转成二进制目标代码.
选项 -c
用法:[root]# gcc –c hello.s –o hello.o
作用:将汇编输出文件test.s编译输出test.o文件。
[root]# gcc -c hello.s -o hello.o
[root]# ls
hello.c  hello.i  hello.o  hello.s


相关文档:

Linux中常用的C\C++头文件

1、  一些头文件的作用:
<assert.h>:ANSI C。提供断言,assert(表达式)
<glib.h>:GCC。GTK,GNOME的基础库,提供很多有用的函数,如有数据结构操作函数。使用glib只需要包含<glib.h>
<dirent.h>:GCC。文件夹操作函数。struct dirent,struct DIR,opendir(),closedir(),readdir(),readdi ......

Linux获取当前时间

1. Linux下与时间有关的结构体
        struct timeval
       {  
           int tv_sec;  
          &nbs ......

Linux下rz/sz安装及使用方法

1)    工具说明
在SecureCRT这样的ssh登录软件里, 通过在Linux界面里输入rz/sz命令来上传/下载文件. 对于RHEL5, rz/sz默认没有安装所以需要手工安装.
sz: 将选定的文件发送(send)到本地机器;
rz:运行该命令会弹出一个文件选择窗口, 从本地选择文件上传到服务器(receive).
下载安装包lrzsz-0.12.20.tar. ......

Linux Kernel Linked List Explained

参见:http://isis.poly.edu/kulesh/stuff/src/klist/
Introduction:
Linux kernel is mostly written in the C language. Unlike many other languages C does not have
a good collection of data structures built into it or supported by a collection of standard libraries.
Therefore, you're probably excited ......

Linux 信号(简略笔记)

    一、概要
      详细介绍:http://www.ibm.com/developerworks/cn/linux/l-ipc/part2/index1.html
       信号是UNIX和Linux系统响应结条件而产生的一个事件。接收到信号的进程会相应地采取一些行动。
    (1) 在系统 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号