Linker scripts之Intro
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.
Linker scripts之Intro的更多相关文章
- Linker scripts之MEMORY
1 MEMORY command The MEMORY command describes the location and size of blocks of memory in the targe ...
- Linker scripts之SECTIONS
1 Purpose The linker script describes how the sections in the input files should be mapped into the ...
- openMSP430之Custom linker script
The use of the -mmcu switch is of course NOT mandatory. It is simply a convenient way to use the pre ...
- linux内核的makefile.txt讲解
linux内核的linux-3.6.5\Documentation\kbuild\makefiles.txt Linux Kernel Makefiles This document describe ...
- Linux内核Makefile文件(翻译自内核手册)
--译自Linux3.9.5 Kernel Makefiles(内核目录documention/kbuild/makefiles.txt) kbuild(kernel build) 内核编译器 Thi ...
- Linux Kernel的Makefile与Kconfig文件的语法
https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt Introduction ------------ The c ...
- kbuild-(directory)
-INDEX - this file: info on the kernel build process kbuild.txt - developer information on kbuild kc ...
- Linux Kernel Makefiles Kbuild en
来自Linux kernel docs,顺便整理了一下排版 Linux Kernel Makefiles This document describes the Linux kernel Makefi ...
- LPC18xx LPC43xx LPC4370 Bootrom USB DFU FPB - Flash Patch and Breakpoint Unit
What is the difference between a Bootrom vs bootloader on ARM systems Bootrom Bootrom (or Boot ROM) ...
随机推荐
- How to fix broken packages?(转)
Try Code: sudo apt-get update to update your package list.Then Code: sudo apt-get autoclean to clean ...
- svn服务器及客户端安装使用
一.服务器安装: 1.yum install subversion 2.输入rpm -ql subversion查看安装位置,如下图: 我们知道svn在bin目录下生成了几个二进制文件. 输入 ...
- asp.net mvc4使用百度ueditor编辑器
原文 http://www.cnblogs.com/flykai/p/3285307.html 已测试 相当不错 前言 配置.net mvc4项目使用ueditor编辑器,在配置过程中遇见了好 ...
- 8.cadence.CIS[原创]
一.CIS数据库配置 ------ ---------------------------- --------------- ------------------ ---- 二.CIS放置元件 --- ...
- sql, plsql 总结
/* *====================================== basic sql ========================================== */ - ...
- 3D volume texture和cube map
cube map texture可以理解为6个面的纸盒, sample的时候使用vector射线型的sample. volume texture可以理解是一摞2D texture,sample的时候用 ...
- 初步窥探Git
码农之路恒久远,学习向上是真谛啊!在学习的过程中,相信大家或多或少都接触到Git这个东东.它到底是什么呢,有什么作用呢,为什么它会那么火呢?带着这些一连串的疑问,决心去揭开它的庐山真面目. 在软件开发 ...
- UVa 1149 (贪心) Bin Packing
首先对物品按重量从小到大排序排序. 因为每个背包最多装两个物品,所以直觉上是最轻的和最重的放一起最节省空间. 考虑最轻的物品i和最重的物品j,如果ij可以放在一个包里那就放在一起. 否则的话,j只能自 ...
- UVa 11134 (区间上的贪心) Fabled Rooks
这道题真是WA得我心力交瘁,好讨厌的感觉啊! 简直木有写题解的心情了 题意: n×n的棋盘里,放置n个车,使得任意两车不同行且不同列,且第i个车必须放在给定的第i个矩形范围内.输出一种方案,即每个车的 ...
- 51nod1295 XOR key
第一次写可持久化trie指针版我... //Null 的正确姿势终于学会啦qaq... #include<cstdio> #include<cstring> #include& ...