106 lines
4.6 KiB
HTML
106 lines
4.6 KiB
HTML
<html lang="en">
|
|
<head>
|
|
<title>Output Section Address - Untitled</title>
|
|
<meta http-equiv="Content-Type" content="text/html">
|
|
<meta name="description" content="Untitled">
|
|
<meta name="generator" content="makeinfo 4.13">
|
|
<link title="Top" rel="start" href="index.html#Top">
|
|
<link rel="up" href="SECTIONS.html#SECTIONS" title="SECTIONS">
|
|
<link rel="prev" href="Output-Section-Name.html#Output-Section-Name" title="Output Section Name">
|
|
<link rel="next" href="Input-Section.html#Input-Section" title="Input Section">
|
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
|
<!--
|
|
This file documents the GNU linker LD
|
|
(GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10))
|
|
version 2.33.1.
|
|
|
|
Copyright (C) 1991-2019 Free Software Foundation, Inc.
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3
|
|
or any later version published by the Free Software Foundation;
|
|
with no Invariant Sections, with no Front-Cover Texts, and with no
|
|
Back-Cover Texts. A copy of the license is included in the
|
|
section entitled ``GNU Free Documentation License''.-->
|
|
<meta http-equiv="Content-Style-Type" content="text/css">
|
|
<style type="text/css"><!--
|
|
pre.display { font-family:inherit }
|
|
pre.format { font-family:inherit }
|
|
pre.smalldisplay { font-family:inherit; font-size:smaller }
|
|
pre.smallformat { font-family:inherit; font-size:smaller }
|
|
pre.smallexample { font-size:smaller }
|
|
pre.smalllisp { font-size:smaller }
|
|
span.sc { font-variant:small-caps }
|
|
span.roman { font-family:serif; font-weight:normal; }
|
|
span.sansserif { font-family:sans-serif; font-weight:normal; }
|
|
--></style>
|
|
</head>
|
|
<body>
|
|
<div class="node">
|
|
<a name="Output-Section-Address"></a>
|
|
<p>
|
|
Next: <a rel="next" accesskey="n" href="Input-Section.html#Input-Section">Input Section</a>,
|
|
Previous: <a rel="previous" accesskey="p" href="Output-Section-Name.html#Output-Section-Name">Output Section Name</a>,
|
|
Up: <a rel="up" accesskey="u" href="SECTIONS.html#SECTIONS">SECTIONS</a>
|
|
<hr>
|
|
</div>
|
|
|
|
<h4 class="subsection">3.6.3 Output Section Address</h4>
|
|
|
|
<p><a name="index-address_002c-section-453"></a><a name="index-section-address-454"></a>The <var>address</var> is an expression for the VMA (the virtual memory
|
|
address) of the output section. This address is optional, but if it
|
|
is provided then the output address will be set exactly as specified.
|
|
|
|
<p>If the output address is not specified then one will be chosen for the
|
|
section, based on the heuristic below. This address will be adjusted
|
|
to fit the alignment requirement of the output section. The
|
|
alignment requirement is the strictest alignment of any input section
|
|
contained within the output section.
|
|
|
|
<p>The output section address heuristic is as follows:
|
|
|
|
<ul>
|
|
<li>If an output memory <var>region</var> is set for the section then it
|
|
is added to this region and its address will be the next free address
|
|
in that region.
|
|
|
|
<li>If the MEMORY command has been used to create a list of memory
|
|
regions then the first region which has attributes compatible with the
|
|
section is selected to contain it. The section's output address will
|
|
be the next free address in that region; <a href="MEMORY.html#MEMORY">MEMORY</a>.
|
|
|
|
<li>If no memory regions were specified, or none match the section then
|
|
the output address will be based on the current value of the location
|
|
counter.
|
|
</ul>
|
|
|
|
<p class="noindent">For example:
|
|
|
|
<pre class="smallexample"> .text . : { *(.text) }
|
|
</pre>
|
|
<p class="noindent">and
|
|
|
|
<pre class="smallexample"> .text : { *(.text) }
|
|
</pre>
|
|
<p class="noindent">are subtly different. The first will set the address of the
|
|
‘<samp><span class="samp">.text</span></samp>’ output section to the current value of the location
|
|
counter. The second will set it to the current value of the location
|
|
counter aligned to the strictest alignment of any of the ‘<samp><span class="samp">.text</span></samp>’
|
|
input sections.
|
|
|
|
<p>The <var>address</var> may be an arbitrary expression; <a href="Expressions.html#Expressions">Expressions</a>.
|
|
For example, if you want to align the section on a 0x10 byte boundary,
|
|
so that the lowest four bits of the section address are zero, you could
|
|
do something like this:
|
|
<pre class="smallexample"> .text ALIGN(0x10) : { *(.text) }
|
|
</pre>
|
|
<p class="noindent">This works because <code>ALIGN</code> returns the current location counter
|
|
aligned upward to the specified value.
|
|
|
|
<p>Specifying <var>address</var> for a section will change the value of the
|
|
location counter, provided that the section is non-empty. (Empty
|
|
sections are ignored).
|
|
|
|
</body></html>
|
|
|