1  Intro

  Every link is controlled by a linker script.

  The main purpose of the linker script is to describe how the sections in the input files should be mapped into the output file, and to control the memory layout of the output file.

  The linker always uses a linker script. If you do not supply one yourself, the linker will use a default script that is compiled into the linker executable. You can use the `--verbose' command line option to display the default linker script. Certain command line options, such as `-r' or `-N', will affect the default linker script.

  You may supply your own linker script by using the `-T' command line option. When you do this, your linker script will replace the default linker script.

2  Basic concepts

  The linker combines input files into a single output file. The output file and each input file are in a special data format known as an object file format. Each file is called an object file. The output file is often called an executable, but for our purposes we will also call it an object file. Each object file has, among other things, a list of sections. We sometimes refer to a section in an input file as an input section; similarly, a section in the output file is an output section.

  Each section in an object file has a name and a size. Most sections also have an associated block of data, known as the section contents. A section may be marked as loadable, which mean that the contents should be loaded into memory when the output file is run. A section with no contents may be allocatable, which means that an area in memory should be set aside, but nothing in particular should be loaded there (in some cases this memory must be zeroed out). A section which is neither loadable nor allocatable typically contains some sort of debugging information.

  Every loadable or allocatable output section has two addresses. The first is the VMA, or virtual memory address. This is the address the section will have when the output file is run. The second is the LMA, or load memory address. This is the address at which the section will be loaded. In most cases the two addresses will be the same. An example of when they might be different is when a data section is loaded into ROM, and then copied into RAM when the program starts up (this technique is often used to initialize global variables in a ROM based system). In this case the ROM address would be the LMA, and the RAM address would be the VMA.

  Every object file also has a list of symbols, known as the symbol table. A symbol may be defined or undefined. Each symbol has a name, and each defined symbol has an address, among other information. If you compile a C or C++ program into an object file, you will get a defined symbol for every defined function and global or static variable. Every undefined function or global variable which is referenced in the input file will become an undefined symbol.

最新文章

  1. sublime text 3 license 2016.05
  2. jQuery WipeTouch
  3. Json&Razor&控制器
  4. ruby -- 问题解决(三)编码错误导致无法显示(1)
  5. yarn 集群部署,遇到的问题小结
  6. mysql存储过程controller的not found造成混乱的解决办法
  7. 【POJ】2318 TOYS ——计算几何+二分
  8. ActiveX控件在IE中不响应Backspace消息
  9. HihoCoder1338 A Game (区间DP)
  10. concurrent.futures进行并发编程
  11. detail
  12. CSS实现背景透明,文字不透明(兼容所有浏览器)
  13. python 多线程操作数据库
  14. RF的特征子集选取策略(spark ml)
  15. 第21章 RTX 低功耗之睡眠模式
  16. centos6.4安装 jupyter-notebook
  17. 科学计算三维可视化---Mayavi可视化实例
  18. MacOS Sierra允许运行任何来源的程序
  19. 【Git】Git与GitHub 入门【转】
  20. ovn-kubernetes安装指南

热门文章

  1. dojo 九 effects dojo/_base/fx 和 dojo/fx
  2. 怎样在Ubuntu系统安装可用的QQ
  3. vmware装redhat该光盘无法被挂载
  4. Sencha CMD 4- 安装与首次使用
  5. HDU 4324 (拓扑排序) Triangle LOVE
  6. 漫游Kafka入门篇之简单介绍
  7. 【转】Windows Server 2008 以上服务器配置SMTP
  8. 【英语】Bingo口语笔记(39) - Get系列
  9. HDU 4750
  10. Be quiet