About Gnu Linker1
1 OverView
- ld combines a number of object and archive files, relocates their data and ties up symbol references.
- This version of ld uses the general purpose BFD libraries to operate on object files. This allows ld to read, combine, and write object files in many different formats.
- the gnu linker is more helpful in providing diagnostic information. ld continues executing, allowing you to identify other errors.
2 Linker Command
3 Linker Scripts
3.1 Basic Linker Script Concepts
- object file: 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.
- input section : a section in an input file as an input section.
- output section : a section in the output file is an output section.
- contents : Most sections have an associated block of data, known as the section contents.
- loadable : mean that the contents should be loaded into memory when the output file is run.
- allocatable : 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.
- neither loadable nor allocatable section: contains some sort of debugging information.
- VMA: 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.
- LMA: The second is the LMA, or load memory address. This is the address at which the section will be loaded.
3.2 Linker Scripts Formate
Linker scripts are text files. You write a linker script as a series of commands. Each command is either a keyword, possibly followed by arguments, or an assignment to a symbol.
3.3 Simple Linker Script Example
3.3.1 SECTIONS command
describe the memory layout of the output file. Example as below:
SECTIONS
{
. = 0x10000;
.text : { *(.text) }
. = 0x8000000;
.data : { *(.data) }
.bss : { *(.bss) }
}
- The first line sets the value of the special symbol ‘.’, which is the location counter. If you do not specify the address of an output section in some other way, the address is set from the current value of the location counter. The location counter is then incremented by the size of the output section. At the start of the ‘SECTIONS’ command, the location counter has the value ‘0’.
- The second line defines an output section, ‘.text’. Within the curly braces after the output section name, you list the names of the input sections which should be placed into this output section.
- The ‘*’ is a wildcard which matches any file name. The expression ‘*(.text)’ means all ‘.text’ input sections in all input files.
3.4 Simple Linker Script Commands
3.4.1 Setting the Entry Point
The first instruction to execute in a program is called the entry point.
ENTRY(symbol)
There are several ways to set the entry point.
_ the ‘-e’ entry command-line option;
_ the ENTRY(symbol) command in a linker script;
_ the value of the symbol start, if defined;
_ the address of the first byte of the ‘.text’ section, if present;
_ The address 0.
3.4.2 Commands Dealing with Files
INCLUDE filename - Include the linker script filename at this point.
INPUT(file, file, ...) - directs the linker to include the named files in the link, as though they were named on the command line.
GROUP(file, file, ...) - like INPUT, except that the named files should all be archives, and they are searched repeatedly until no new undefined references are created.
3.4.3 Assign alias names to memory regions
REGION_ALIAS(alias, region)
The REGION_ALIAS function creates an alias name alias for the memory region region.
3.5 Assigning Values to Symbols
About Gnu Linker1的更多相关文章
- 感悟 GNU C 以及将 Vim 打造成 C/C++ 的半自动化 IDE
C 语言在 Linux 系统中的重要性自然是无与伦比.不可替代,所以我写 Linux 江湖系列不可能不提 C 语言.C 语言是我的启蒙语言,感谢 C 语言带领我进入了程序世界.虽然现在不靠它吃饭,但是 ...
- 使用 GCC 和 GNU Binutils 编写能在 x86 实模式运行的 16 位代码
不可否认,这次的标题有点长.之所以把标题写得这么详细,主要是为了搜索引擎能够准确地把确实需要了解 GCC 生成 16 位实模式代码方法的朋友带到我的博客.先说一下背景,编写能在 x86 实模式下运行的 ...
- 在 Linux 中使用 Eclipse 和 Gnu Autotools 管理 C/C++ 项目
在我该系列的之前的所有随笔中,都是采用 Linux 发行版自带的包管理工具(如 apt-get.yum 等)进行软件的安装和卸载,从来没有向大家展示使用源代码自行编译安装软件的方法.但是长期混迹于 U ...
- GNU Readline 库及编程简介
用过 Bash 命令行的一定知道,Bash 有几个特性: TAB 键可以用来命令补全 ↑ 或 ↓ 键可以用来快速输入历史命令 还有一些交互式行编辑快捷键: C-A / C-E 将光标移到行首/行尾 C ...
- GNU Radio Radar Toolbox
GNU Radio Radar Toolbox Install guide Change to any folder in your home directory and enter followin ...
- gnu coreutils-8.25 for win32 static - Beta
gnu.win32-coreutils-8.25.7z 2.7 Mb bc-1.06.tar.gz coreutils-8.25.tar.xz diffutils-3.5.tar.xz gawk-4. ...
- window下搭建c开发环境(GNU环境的安装)
一.在windows平台上安装GNU环境 windows操作系统不自带GNU环境,如果需要开发跨平台的C语言程序,那么需要给windows安装GNU环境 windows下的两款GNU环境:MinGW和 ...
- GNU make使用变量⑤变量的引用、定义等
在 Makefile 中,变量是一个名字(像是 C 语言中的宏),代表一个文本字符串(变量的值).在 Makefile 的目标.依赖.命令中引用变量的地方,变量会被它的值所取代(与 C 语言中宏引用的 ...
- (转)完全用GNU/Linux工作 by 王珢
完全用GNU/Linux工作 王珢 (看完这篇博文,非常喜欢王珢的这篇博客,也我坚定了学gnu/linux的决心,并努力去按照国外的计算机思维模式去学习编程提高自己.看完这篇文章令我热血沸腾 ...
随机推荐
- iOS 九宫格解锁
思路: 1.画9个按钮,通过按钮的选中状态控制按钮. 2.连线通过贝塞尔曲线绘制. 3.校验密码通过给按钮绑定tag值判断. 主要代码: OC版本: // // NineLockView.m // l ...
- oracle 修改用户密码
SYS用户是Oracle中权限最高的用户,而SYSTEM是一个用于数据库管理的用户.在数据库安装完之后,应立即修改SYS,SYSTEM这两个用户的密码,以保证数据库的安全. 安装完之后修改密码方法 c ...
- Mac 安装Python3 facewap环境
参考网上大神的方法 1 官网下载安装 2 下载指定版本的源码cmake安装 3 Mac上使用homebrew进行安装(强烈推荐,主要是前两种的openssl模块我没有搞定链接什么的一直报错,一个个下载 ...
- NewSQL和TiDB入门
TiDB已经在项目中使用,从了解来看,它主要解决的是分布式事务的问题,而我们实际使用场景,却是大数据量下不需要关注分表: 最近实在忙加懒,一直没时间看TiDB的原理.今天看了下PingCAP3篇入门介 ...
- Linux恢复误删除的文件或者目录(转)
linux不像windows有个回收站,使用rm -rf *基本上文件是找不回来的. 那么问题来了: 对于linux下误删的文件,我们是否真的无法通过软件进行恢复呢? 答案当然是否定的,对于误删的文件 ...
- Git入门(安装及基础命令行操作)
一.安装 1.Mac 在Mac中安装Git的方法不止一种.最简单的要数通过Xcode命令行工具.对于Mavericks(10.9)或更高版本的操作系统,当你第一次尝试在终端执行git命令时,系统会自动 ...
- React Lifecycle
React Lifecycle 分为三种: 初始化阶段 状态的更新 销毁 实例化: ReactDom.render 用于将模板转换成HTML语言,并插入DOM节点. 1.getDefaultProps ...
- Codeforces 1105C: Ayoub and Lost Array(递推)
time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: sta ...
- Python中的常用魔术方法介绍
1.__init__ 初始化魔术方法 触发时机:初始化对象时触发(不是实例化触发,但是和实例化在一个操作中) 参数:至少有一个self,接收对象 返回值:无 作用:初始化对象的成员 注意:使用该方式初 ...
- 【[AHOI2005]洗牌 题解
一道好题. 首先是数据范围. 0<N≤10^10 ,0 ≤M≤10^10,且N为偶数 这是这道题的坑点,也是痛点. 10^10表示这这道题必有规律. 那么,first step,我们先探索规律. ...