当前位置:网站首页>编译与链接
编译与链接
2022-07-29 04:06:00 【echo_zcc】
一、编译流程

二、预处理
C语言编译器在对源代码编译之前的一步操作。
| 功能 | 作用 |
|---|---|
| 头文件展开 | 将程序中所用的头文件用其内容替换头文件名 |
| 宏替换 | 扫描程序中的符号,将其替换成宏所定义的内容 |
| 去注释 | 去掉程序中的注释 |
| 条件编译 | 筛选掉条件编译中的伪命令 |
三、编译
编译的过程实质上是把高级语言翻译成机器语言的过程。
- 词法、语法、语义分析。在确认所有指令都符合规则后,将其翻译成等价的汇编代码。
- 代码优化。删除公共表达式,循环优化、复写传播、无用赋值的删除。
- 目标代码优化。利用机器的各个硬件寄存器存放的相关变量的值,以减少对内存的访问次数。
四、汇编
汇编过程就是将编译后生成的汇编语言代码翻译成目标机器指令的过程。
汇编目标文件中所存放的也就是与源程序等效的目标的机器语言代码。目标文件由段组成。通常一个目标文件中至少有两个段。
| 段名 | 作用 |
|---|---|
| 代码段 | 程序的指令 |
| 数据段 | 程序中要用到的各种全局变量或静态的数据 |
五、链接
链接的功能是完成文件中各种调用的函数以及库的连接,并将它们一起打包合并形成可执行文件。
- 符号决议
确定所使用的变量要有其唯一的定义。 - 重定位
通过链接器将不同的目标文件中的数据和代码重新分配内存地址,使得CPU能从内存中找到指令。
边栏推荐
- 路西法98-生活记录ing
- The output comparison function of Tim is introduced in detail through PWM breathing lamp and PWM controlled DC motor
- Ssl== certificate related concepts
- Opensql quick learning
- SQL语句 关于字段转换怎么写
- [原理] 横向渗透的几种方式
- View partition table format
- Asp.net MVC中文件夹中的控制器如何跳转到根目录的控制器中?
- Lua language (stm32+2g/4g module) and C language (stm32+esp8266) methods of extracting relevant data from strings - collation
- Array as function parameter -- pointer constant / constant pointer
猜你喜欢

Ma Zhixing entered the mass production of front loading, starting with the self-developed domain controller?

OA项目之会议通知(查询&是否参会&反馈详情)

rman不标记过期备份

面试必备!TCP协议经典十五连问!

华为天才少年稚晖君做了一把模块化机械键盘,引起极客圈地震,网友:这才是真正的客制化...

数据挖掘——关联分析例题代码实现(下)

Big manufacturers finally can't stand "adding one second", and companies such as Microsoft, Google meta propose to abolish leap seconds

2021 sist summer camp experience + record post of School of information, Shanghai University of science and technology

【BGP】小型实验

Simple cases of inner connection and left connection
随机推荐
Extended operator of new features in ES6
一文学透MySQL表的创建和约束
Asp. Net MVC, how can the controller in the folder jump to the controller in the root directory?
Deconstruction assignment of new features of ES6
Const char* and char*, string constants
mmdetection初步使用
LCA 板子
How to execute insert into select from job in SQL client
MySQL Part 3
Three tier architecture of enterprise network
初识C语言(3)
JS cookie usage
OA项目之会议通知(查询&是否参会&反馈详情)
[BGP] small scale experiment
3. Solve pychart's error unresolved reference 'selenium' unresolved reference 'webdriver‘
[原理] 横向渗透的几种方式
Data mining -- Introduction to the basis of association analysis (Part 1)
C语言实现三子棋游戏(详解)
Rhel8 patch package production
The structure pointer must be initialized, and the pointer must also be initialized