107 lines
5.9 KiB
HTML
107 lines
5.9 KiB
HTML
|
<html lang="en">
|
||
|
<head>
|
||
|
<title>Output Section Data - 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="Input-Section.html#Input-Section" title="Input Section">
|
||
|
<link rel="next" href="Output-Section-Keywords.html#Output-Section-Keywords" title="Output Section Keywords">
|
||
|
<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-Data"></a>
|
||
|
<p>
|
||
|
Next: <a rel="next" accesskey="n" href="Output-Section-Keywords.html#Output-Section-Keywords">Output Section Keywords</a>,
|
||
|
Previous: <a rel="previous" accesskey="p" href="Input-Section.html#Input-Section">Input Section</a>,
|
||
|
Up: <a rel="up" accesskey="u" href="SECTIONS.html#SECTIONS">SECTIONS</a>
|
||
|
<hr>
|
||
|
</div>
|
||
|
|
||
|
<h4 class="subsection">3.6.5 Output Section Data</h4>
|
||
|
|
||
|
<p><a name="index-data-475"></a><a name="index-section-data-476"></a><a name="index-output-section-data-477"></a><a name="index-BYTE_0028_0040var_007bexpression_007d_0029-478"></a><a name="index-SHORT_0028_0040var_007bexpression_007d_0029-479"></a><a name="index-LONG_0028_0040var_007bexpression_007d_0029-480"></a><a name="index-QUAD_0028_0040var_007bexpression_007d_0029-481"></a><a name="index-SQUAD_0028_0040var_007bexpression_007d_0029-482"></a>You can include explicit bytes of data in an output section by using
|
||
|
<code>BYTE</code>, <code>SHORT</code>, <code>LONG</code>, <code>QUAD</code>, or <code>SQUAD</code> as
|
||
|
an output section command. Each keyword is followed by an expression in
|
||
|
parentheses providing the value to store (see <a href="Expressions.html#Expressions">Expressions</a>). The
|
||
|
value of the expression is stored at the current value of the location
|
||
|
counter.
|
||
|
|
||
|
<p>The <code>BYTE</code>, <code>SHORT</code>, <code>LONG</code>, and <code>QUAD</code> commands
|
||
|
store one, two, four, and eight bytes (respectively). After storing the
|
||
|
bytes, the location counter is incremented by the number of bytes
|
||
|
stored.
|
||
|
|
||
|
<p>For example, this will store the byte 1 followed by the four byte value
|
||
|
of the symbol ‘<samp><span class="samp">addr</span></samp>’:
|
||
|
<pre class="smallexample"> BYTE(1)
|
||
|
LONG(addr)
|
||
|
</pre>
|
||
|
<p>When using a 64 bit host or target, <code>QUAD</code> and <code>SQUAD</code> are the
|
||
|
same; they both store an 8 byte, or 64 bit, value. When both host and
|
||
|
target are 32 bits, an expression is computed as 32 bits. In this case
|
||
|
<code>QUAD</code> stores a 32 bit value zero extended to 64 bits, and
|
||
|
<code>SQUAD</code> stores a 32 bit value sign extended to 64 bits.
|
||
|
|
||
|
<p>If the object file format of the output file has an explicit endianness,
|
||
|
which is the normal case, the value will be stored in that endianness.
|
||
|
When the object file format does not have an explicit endianness, as is
|
||
|
true of, for example, S-records, the value will be stored in the
|
||
|
endianness of the first input object file.
|
||
|
|
||
|
<p>Note—these commands only work inside a section description and not
|
||
|
between them, so the following will produce an error from the linker:
|
||
|
<pre class="smallexample"> SECTIONS { .text : { *(.text) } LONG(1) .data : { *(.data) } }</pre>
|
||
|
<p>whereas this will work:
|
||
|
<pre class="smallexample"> SECTIONS { .text : { *(.text) ; LONG(1) } .data : { *(.data) } }</pre>
|
||
|
<p><a name="index-FILL_0028_0040var_007bexpression_007d_0029-483"></a><a name="index-holes_002c-filling-484"></a><a name="index-unspecified-memory-485"></a>You may use the <code>FILL</code> command to set the fill pattern for the
|
||
|
current section. It is followed by an expression in parentheses. Any
|
||
|
otherwise unspecified regions of memory within the section (for example,
|
||
|
gaps left due to the required alignment of input sections) are filled
|
||
|
with the value of the expression, repeated as
|
||
|
necessary. A <code>FILL</code> statement covers memory locations after the
|
||
|
point at which it occurs in the section definition; by including more
|
||
|
than one <code>FILL</code> statement, you can have different fill patterns in
|
||
|
different parts of an output section.
|
||
|
|
||
|
<p>This example shows how to fill unspecified regions of memory with the
|
||
|
value ‘<samp><span class="samp">0x90</span></samp>’:
|
||
|
<pre class="smallexample"> FILL(0x90909090)
|
||
|
</pre>
|
||
|
<p>The <code>FILL</code> command is similar to the ‘<samp><span class="samp">=</span><var>fillexp</var></samp>’ output
|
||
|
section attribute, but it only affects the
|
||
|
part of the section following the <code>FILL</code> command, rather than the
|
||
|
entire section. If both are used, the <code>FILL</code> command takes
|
||
|
precedence. See <a href="Output-Section-Fill.html#Output-Section-Fill">Output Section Fill</a>, for details on the fill
|
||
|
expression.
|
||
|
|
||
|
</body></html>
|
||
|
|