1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- This file documents the GNU linker LD
4(GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29))
5version 2.36.1.
6
7Copyright (C) 1991-2021 Free Software Foundation, Inc.
8
9Permission is granted to copy, distribute and/or modify this document
10under the terms of the GNU Free Documentation License, Version 1.3
11or any later version published by the Free Software Foundation;
12with no Invariant Sections, with no Front-Cover Texts, and with no
13Back-Cover Texts.  A copy of the license is included in the
14section entitled "GNU Free Documentation License". -->
15<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
16<head>
17<title>LD: Basic Script Concepts</title>
18
19<meta name="description" content="LD: Basic Script Concepts">
20<meta name="keywords" content="LD: Basic Script Concepts">
21<meta name="resource-type" content="document">
22<meta name="distribution" content="global">
23<meta name="Generator" content="makeinfo">
24<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
25<link href="index.html#Top" rel="start" title="Top">
26<link href="LD-Index.html#LD-Index" rel="index" title="LD Index">
27<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
28<link href="Scripts.html#Scripts" rel="up" title="Scripts">
29<link href="Script-Format.html#Script-Format" rel="next" title="Script Format">
30<link href="Scripts.html#Scripts" rel="previous" title="Scripts">
31<style type="text/css">
32<!--
33a.summary-letter {text-decoration: none}
34blockquote.smallquotation {font-size: smaller}
35div.display {margin-left: 3.2em}
36div.example {margin-left: 3.2em}
37div.indentedblock {margin-left: 3.2em}
38div.lisp {margin-left: 3.2em}
39div.smalldisplay {margin-left: 3.2em}
40div.smallexample {margin-left: 3.2em}
41div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
42div.smalllisp {margin-left: 3.2em}
43kbd {font-style:oblique}
44pre.display {font-family: inherit}
45pre.format {font-family: inherit}
46pre.menu-comment {font-family: serif}
47pre.menu-preformatted {font-family: serif}
48pre.smalldisplay {font-family: inherit; font-size: smaller}
49pre.smallexample {font-size: smaller}
50pre.smallformat {font-family: inherit; font-size: smaller}
51pre.smalllisp {font-size: smaller}
52span.nocodebreak {white-space:nowrap}
53span.nolinebreak {white-space:nowrap}
54span.roman {font-family:serif; font-weight:normal}
55span.sansserif {font-family:sans-serif; font-weight:normal}
56ul.no-bullet {list-style: none}
57-->
58</style>
59
60
61</head>
62
63<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
64<a name="Basic-Script-Concepts"></a>
65<div class="header">
66<p>
67Next: <a href="Script-Format.html#Script-Format" accesskey="n" rel="next">Script Format</a>, Up: <a href="Scripts.html#Scripts" accesskey="u" rel="up">Scripts</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="LD-Index.html#LD-Index" title="Index" rel="index">Index</a>]</p>
68</div>
69<hr>
70<a name="Basic-Linker-Script-Concepts"></a>
71<h3 class="section">3.1 Basic Linker Script Concepts</h3>
72<a name="index-linker-script-concepts"></a>
73<p>We need to define some basic concepts and vocabulary in order to
74describe the linker script language.
75</p>
76<p>The linker combines input files into a single output file.  The output
77file and each input file are in a special data format known as an
78<em>object file format</em>.  Each file is called an <em>object file</em>.
79The output file is often called an <em>executable</em>, but for our
80purposes we will also call it an object file.  Each object file has,
81among other things, a list of <em>sections</em>.  We sometimes refer to a
82section in an input file as an <em>input section</em>; similarly, a section
83in the output file is an <em>output section</em>.
84</p>
85<p>Each section in an object file has a name and a size.  Most sections
86also have an associated block of data, known as the <em>section
87contents</em>.  A section may be marked as <em>loadable</em>, which means that
88the contents should be loaded into memory when the output file is run.
89A section with no contents may be <em>allocatable</em>, which means that an
90area in memory should be set aside, but nothing in particular should be
91loaded there (in some cases this memory must be zeroed out).  A section
92which is neither loadable nor allocatable typically contains some sort
93of debugging information.
94</p>
95<p>Every loadable or allocatable output section has two addresses.  The
96first is the <em>VMA</em>, or virtual memory address.  This is the address
97the section will have when the output file is run.  The second is the
98<em>LMA</em>, or load memory address.  This is the address at which the
99section will be loaded.  In most cases the two addresses will be the
100same.  An example of when they might be different is when a data section
101is loaded into ROM, and then copied into RAM when the program starts up
102(this technique is often used to initialize global variables in a ROM
103based system).  In this case the ROM address would be the LMA, and the
104RAM address would be the VMA.
105</p>
106<p>You can see the sections in an object file by using the <code>objdump</code>
107program with the &lsquo;<samp>-h</samp>&rsquo; option.
108</p>
109<p>Every object file also has a list of <em>symbols</em>, known as the
110<em>symbol table</em>.  A symbol may be defined or undefined.  Each symbol
111has a name, and each defined symbol has an address, among other
112information.  If you compile a C or C++ program into an object file, you
113will get a defined symbol for every defined function and global or
114static variable.  Every undefined function or global variable which is
115referenced in the input file will become an undefined symbol.
116</p>
117<p>You can see the symbols in an object file by using the <code>nm</code>
118program, or by using the <code>objdump</code> program with the &lsquo;<samp>-t</samp>&rsquo;
119option.
120</p>
121<hr>
122<div class="header">
123<p>
124Next: <a href="Script-Format.html#Script-Format" accesskey="n" rel="next">Script Format</a>, Up: <a href="Scripts.html#Scripts" accesskey="u" rel="up">Scripts</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="LD-Index.html#LD-Index" title="Index" rel="index">Index</a>]</p>
125</div>
126
127
128
129</body>
130</html>
131