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的更多相关文章

  1. Linker scripts之MEMORY

    1 MEMORY command The MEMORY command describes the location and size of blocks of memory in the targe ...

  2. Linker scripts之SECTIONS

    1 Purpose The linker script describes how the sections in the input files should be mapped into the ...

  3. 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 ...

  4. linux内核的makefile.txt讲解

    linux内核的linux-3.6.5\Documentation\kbuild\makefiles.txt Linux Kernel Makefiles This document describe ...

  5. Linux内核Makefile文件(翻译自内核手册)

    --译自Linux3.9.5 Kernel Makefiles(内核目录documention/kbuild/makefiles.txt) kbuild(kernel build) 内核编译器 Thi ...

  6. Linux Kernel的Makefile与Kconfig文件的语法

    https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt Introduction ------------ The c ...

  7. kbuild-(directory)

    -INDEX - this file: info on the kernel build process kbuild.txt - developer information on kbuild kc ...

  8. Linux Kernel Makefiles Kbuild en

    来自Linux kernel docs,顺便整理了一下排版 Linux Kernel Makefiles This document describes the Linux kernel Makefi ...

  9. 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) ...

随机推荐

  1. ThinkPad L421 如何禁用触摸板

    控制面板 - 硬件和声音 - 鼠标 . 选中如下图所示的 UltraNav 选项卡. 将 启用 TouchPad 前的 √ 去掉即可. 如果没有 UltraNav 这一选项卡,可至联想官网下载相关驱动 ...

  2. How Uuencoding Works

    做题目学习  https://www.zhihu.com/question/26598476/answer/45396765 http://email.about.com/od/emailbehind ...

  3. java-基础练习题1

    /** 题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,* 假如兔子都不死,问每个月的兔子总数为多少?* 1.程序分析: 兔子的规律为数列1, ...

  4. DNS为什么通常都会设置为14.114.114.114

    114DNS以多个基础电信运营商自用的DNS系统为基础,通过扩展而建成专业的第三方高可靠DNS服务平台,该平台由几百个Intel的高端CPU内核构成,有多条10GE和GE电路直连多个基础电信运营商的核 ...

  5. visual studio 2015常用快捷键

    常用快捷键 技巧 0.0 删除文件中的当前行: Home + Shife-End + Delete 技巧 1.1 避免意外复制一个空白行 工具->选项->文本编辑器->所有语言-&g ...

  6. memcached的LRU删除机制

    1)memcached不会自动清空缓存的值如果add了一个值,但不去get它,那么这个值过期了,它也不会被清空.解释:memcached不自动检测和清空值,它只当你需要get这个值的时候,才检测这个值 ...

  7. Java RGB数组图像合成 ImageCombining (整理)

    /** * Java RGB数组图像合成 ImageCombinning (整理) * * 2016-1-2 深圳 南山平山村 曾剑锋 * * 注意事项: * 1.本程序为java程序,同时感谢您花费 ...

  8. ecshop 改变sitemap.xml的位置

    大家知道ECSHOP默认的sitemap.xml文件是放置在data文件夹中的,但是这不利于GOOGLE的抓取.我们必须把sitemap.xml文件放置在根目录下 在admin/sitemap.php ...

  9. list() and tuple()

    >>> l = list('sdfsdf') >>> l ['s', 'd', 'f', 's', 'd', 'f'] >>> t = tuple ...

  10. Edit Control的Enter响应函数

    Edit Control的Enter响应函数   在dialog中添加edit control ,选择“Multi_Line mode”   MFC Class Wizard中添加Virtual Fu ...