From where i stand,

        there are two programmig languages in the world,

            which is C lang and the other.

 

编译(compile)

  • 预处理(也称预编译,Preprocessing)
  • 编译(Compilation)
  • 汇编 (Assembly)
  • 连接(Linking)

GCC参考

gcc - GNU project C and C++ compiler

If you only want some of the stages of compilation, you can use -x (or filename suffixes) to tell gcc where to start, and one of the options -c, -S, or -E to say where gcc is to stop. Note that some combinations (for example, -x cpp-output -E) instruct gcc to do nothing at all.

  • -E Stop after the preprocessing stage; do not run the compiler proper.
  • -S Stop after the stage of compilation proper; do not assemble.
  • -c Compile or assemble the source files, but do not link.
  • -o targetfile Place output in file targetfile.



 [root@standby gcc]# date +%F_%H:%M:%S
--29_23::
[root@standby gcc]# pwd
/data/gcc
[root@standby gcc]# ll
total
-rw-r--r-- root root Nov : hello.c
[root@standby gcc]# cat hello.c
#include <stdio.h>
int main(void)
{
printf("Hello World!\n");
return ;
}
[root@standby gcc]#
[root@standby gcc]# file hello.c
hello.c: ASCII C program text
[root@standby gcc]#

预处理/Preprocessing

'删除注释和";"、进行宏替换、将头文件插入进来、条件编译等'
 [root@standby gcc]# gcc -E hello.c -o hello.i
[root@standby gcc]# ll
total
-rw-r--r-- root root Nov : hello.c
-rw-r--r-- root root Nov : hello.i
[root@standby gcc]# file hello.i
hello.i: ASCII C program text
[root@standby gcc]#

编译/Compilation

'生成汇编代码'
 [root@standby gcc]# gcc -S hello.i -o hello.s
[root@standby gcc]# ll
total
-rw-r--r-- root root Nov : hello.c
-rw-r--r-- root root Nov : hello.i
-rw-r--r-- root root Nov : hello.s
[root@standby gcc]# file hello.s
hello.s: ASCII assembler program text
[root@standby gcc]#

汇编/Assembly

'生成目标文件'
 [root@standby gcc]# gcc -c hello.s -o hello.o
[root@standby gcc]# ll
total
-rw-r--r-- root root Nov : hello.c
-rw-r--r-- root root Nov : hello.i
-rw-r--r-- root root Nov : hello.o
-rw-r--r-- root root Nov : hello.s
[root@standby gcc]# file hello.o
hello.o: ELF -bit LSB relocatable, x86-, version (SYSV), not stripped
[root@standby gcc]#

连接/Linking

'生成可执行文件'
 [root@standby gcc]# gcc hello.o -o helloworld
[root@standby gcc]# ll
total
-rw-r--r-- root root Nov : hello.c
-rw-r--r-- root root Nov : hello.i
-rw-r--r-- root root Nov : hello.o
-rw-r--r-- root root Nov : hello.s
-rwxr-xr-x root root Nov : helloworld
[root@standby gcc]# file helloworld
helloworld: ELF -bit LSB executable, x86-, version (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6., not stripped
[root@standby gcc]#
[root@standby gcc]# ./helloworld
Hello World!
[root@standby gcc]#



汇编代码

 [root@standby gcc]# cat hello.s
.file "hello.c"
.section .rodata
.LC0:
.string "Hello World!"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset
.cfi_offset , -
movq %rsp, %rbp
.cfi_def_cfa_register
movl $.LC0, %edi
call puts
movl $, %eax
leave
.cfi_def_cfa ,
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (GNU) 4.4.7 20120313 (Red Hat 4.4.7-17)"
.section .note.GNU-stack,"",@progbits
[root@standby gcc]#

C 编译过程浅析的更多相关文章

  1. C程序编译过程浅析

    前几天看了<程序员的自我修养——链接.装载与库>中的第二章“编译和链接”,主要根据其中的内容简单总结一下C程序编译的过程吧. 我现在一般都是用gcc,所以自然以GCC编译hellworld ...

  2. C程序编译过程浅析(转)

    前几天看了<程序员的自我修养——链接.装载与库>中的第二章“编译和链接”,主要根据其中的内容简单总结一下C程序编译的过程吧. 我现在一般都是用gcc,所以自然以GCC编译hellworld ...

  3. C程序编译过程浅析【转】

    转自:http://blog.csdn.net/koudaidai/article/details/8092647 前几天看了<程序员的自我修养——链接.装载与库>中的第二章“编译和链接” ...

  4. OpenJDK源码研究笔记(十一):浅析Javac编译过程中的抽象语法树(IfElse,While,Switch等语句的抽象和封装)

    浅析OpenJDK源码编译器Javac的语法树包com.sun.source.tree. 抽象语法树,是编译原理中的经典问题,有点难,本文只是随便写写. 0.赋值语句 public interface ...

  5. Linux入门——开机启动过程浅析

    Linux开机启动过程浅析 Introduction 开机启动过程分为以下6个步骤,分别是BIOS, MBR, GRUB, Kernel, Init, RunLevel, RunDefinition ...

  6. GCC编译流程浅析

    GCC-GCC编译流程浅析 序言 对于大多数程序员而言,大家都知道gcc是什么,但是如果不接触到linux平台下的开发,鲜有人真正了解gcc的编译流程,因为windows+IDE的开发模式简直是一条龙 ...

  7. Android工程的编译过程

    现在很多人想对Android工程的编译和打包进行自动化,比如建立每日构建系统.自动生成发布文件等等.这些都需要我们对Android工程的编译和打包有一个深入的理解,至少要知道它的每一步都做了什么,需要 ...

  8. GCC编译过程

    以下是C程序一般的编译过程: gcc的编译流程分为四个步骤,分别为:· 预处理(Pre-Processing) 对C语言进行预处理,生成*.i文件.· 编译(Compiling) 将上一步生成的*.i ...

  9. Linux系统GCC常用命令和GCC编译过程描述

    前言: GCC 原名为 GNU C 语言编译器(GNU C Compiler),因为它原本只能处理 C语言.GCC 很快地扩展,变得可处理 C++.后来又 扩展能够支持更多编程语言,如Fortran. ...

随机推荐

  1. DispatcherServlet源码分析

    一.客户端发送请求的总体过程 DispatcherServlet是SpringMVC的入口,DispatcherServlet其实也是一个Servlet.服务器处理客户端请求的步骤如下: 1.客户端发 ...

  2. Jquery ajax 表单.serialize() 和serializeArray()序列化$.param()

    .serialize() 方法创建以标准 URL 编码表示的文本字符串.它的操作对象是代表表单元素集合的 jQuery 对象. 表单元素有几种类型: <form> <div>& ...

  3. shell of leetcode

    1.Tenth Line How would you print just the 10th line of a file? For example, assume that file.txt has ...

  4. 设计模式笔记:策略模式(Strategy)

    1. 策略模式简介 1.1 定义 策略是为达到某一目的而采取的手段或方法,策略模式的本质是目标与手段的分离,手段不同而最终达成的目标一致.客户只关心目标而不在意具体的实现方法,实现方法要根据具体的环境 ...

  5. 在使用ADOQuery删除数据时的处理 [问题点数:100分,结帖人isdxsc]

    在使用ADOQuery删除数据时的,希望在他的事件BeforeDelete进行一些判断,符合要求的进行删除,不符合要求的终止这个删除行为,请问应该用什么语句呢?还有个比较奇怪的现象也一起请教:DBGr ...

  6. JavaScript——DOM树的增查改删总结

    对HTML DOM的操作是前端JavaScript编程时必备的技能,本文是我自己对DOM树操作的总结,主要是方法的罗列,原理性的讲述较少,适合大家用于理清思路或是温习 一.什么是HTML DOM? 是 ...

  7. 云时代的IT运维面临将会有哪些变化

    导读 每一次IT系统的转型,运维系统和业务保障都是最艰难的部分.在当前企业IT系统向云架构转型的时刻,运维系统再一次面临着新的挑战.所以在数据中心运维的时候,运维人员应该注意哪些问题? 在云计算时代, ...

  8. const,static,volatile关键字的作用

    const关键字: 1.欲阻止一个变量被改变,可使用const,在定义该const变量时,需先初始化,以后就没有机会改变他了: 2.对指针而言,可以指定指针本身为const,也可以指定指针所指的数据为 ...

  9. asp.net 的三种开发模式

    一, Web Pages 是三种创建 ASP.NET 网站和 Web 应用程序的编程模式中的一种. 其他两种编程模式是 Web Forms 和 MVC(Model View Controller 模型 ...

  10. BZOJ4828 AHOI/HNOI2017大佬(动态规划+bfs)

    注意到怼大佬的操作至多只能进行两次.我们逐步简化问题. 首先令f[i][j]表示第i天结束后自信值为j时至多有多少天可以进行非防御操作(即恢复自信值之外的操作).这个dp非常显然.由于最终只需要保证存 ...