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: Output Section Data</title> 18 19<meta name="description" content="LD: Output Section Data"> 20<meta name="keywords" content="LD: Output Section Data"> 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="SECTIONS.html#SECTIONS" rel="up" title="SECTIONS"> 29<link href="Output-Section-Keywords.html#Output-Section-Keywords" rel="next" title="Output Section Keywords"> 30<link href="Input-Section-Example.html#Input-Section-Example" rel="previous" title="Input Section Example"> 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="Output-Section-Data"></a> 65<div class="header"> 66<p> 67Next: <a href="Output-Section-Keywords.html#Output-Section-Keywords" accesskey="n" rel="next">Output Section Keywords</a>, Previous: <a href="Input-Section.html#Input-Section" accesskey="p" rel="previous">Input Section</a>, Up: <a href="SECTIONS.html#SECTIONS" accesskey="u" rel="up">SECTIONS</a> [<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="Output-Section-Data-1"></a> 71<h4 class="subsection">3.6.5 Output Section Data</h4> 72<a name="index-data"></a> 73<a name="index-section-data"></a> 74<a name="index-output-section-data"></a> 75<a name="index-BYTE_0028expression_0029"></a> 76<a name="index-SHORT_0028expression_0029"></a> 77<a name="index-LONG_0028expression_0029"></a> 78<a name="index-QUAD_0028expression_0029"></a> 79<a name="index-SQUAD_0028expression_0029"></a> 80<p>You can include explicit bytes of data in an output section by using 81<code>BYTE</code>, <code>SHORT</code>, <code>LONG</code>, <code>QUAD</code>, or <code>SQUAD</code> as 82an output section command. Each keyword is followed by an expression in 83parentheses providing the value to store (see <a href="Expressions.html#Expressions">Expressions</a>). The 84value of the expression is stored at the current value of the location 85counter. 86</p> 87<p>The <code>BYTE</code>, <code>SHORT</code>, <code>LONG</code>, and <code>QUAD</code> commands 88store one, two, four, and eight bytes (respectively). After storing the 89bytes, the location counter is incremented by the number of bytes 90stored. 91</p> 92<p>For example, this will store the byte 1 followed by the four byte value 93of the symbol ‘<samp>addr</samp>’: 94</p><div class="smallexample"> 95<pre class="smallexample">BYTE(1) 96LONG(addr) 97</pre></div> 98 99<p>When using a 64 bit host or target, <code>QUAD</code> and <code>SQUAD</code> are the 100same; they both store an 8 byte, or 64 bit, value. When both host and 101target are 32 bits, an expression is computed as 32 bits. In this case 102<code>QUAD</code> stores a 32 bit value zero extended to 64 bits, and 103<code>SQUAD</code> stores a 32 bit value sign extended to 64 bits. 104</p> 105<p>If the object file format of the output file has an explicit endianness, 106which is the normal case, the value will be stored in that endianness. 107When the object file format does not have an explicit endianness, as is 108true of, for example, S-records, the value will be stored in the 109endianness of the first input object file. 110</p> 111<p>Note—these commands only work inside a section description and not 112between them, so the following will produce an error from the linker: 113</p><div class="smallexample"> 114<pre class="smallexample">SECTIONS { .text : { *(.text) } LONG(1) .data : { *(.data) } } </pre></div> 115<p>whereas this will work: 116</p><div class="smallexample"> 117<pre class="smallexample">SECTIONS { .text : { *(.text) ; LONG(1) } .data : { *(.data) } } </pre></div> 118 119<a name="index-FILL_0028expression_0029"></a> 120<a name="index-holes_002c-filling"></a> 121<a name="index-unspecified-memory"></a> 122<p>You may use the <code>FILL</code> command to set the fill pattern for the 123current section. It is followed by an expression in parentheses. Any 124otherwise unspecified regions of memory within the section (for example, 125gaps left due to the required alignment of input sections) are filled 126with the value of the expression, repeated as 127necessary. A <code>FILL</code> statement covers memory locations after the 128point at which it occurs in the section definition; by including more 129than one <code>FILL</code> statement, you can have different fill patterns in 130different parts of an output section. 131</p> 132<p>This example shows how to fill unspecified regions of memory with the 133value ‘<samp>0x90</samp>’: 134</p><div class="smallexample"> 135<pre class="smallexample">FILL(0x90909090) 136</pre></div> 137 138<p>The <code>FILL</code> command is similar to the ‘<samp>=<var>fillexp</var></samp>’ output 139section attribute, but it only affects the 140part of the section following the <code>FILL</code> command, rather than the 141entire section. If both are used, the <code>FILL</code> command takes 142precedence. See <a href="Output-Section-Fill.html#Output-Section-Fill">Output Section Fill</a>, for details on the fill 143expression. 144</p> 145<hr> 146<div class="header"> 147<p> 148Next: <a href="Output-Section-Keywords.html#Output-Section-Keywords" accesskey="n" rel="next">Output Section Keywords</a>, Previous: <a href="Input-Section.html#Input-Section" accesskey="p" rel="previous">Input Section</a>, Up: <a href="SECTIONS.html#SECTIONS" accesskey="u" rel="up">SECTIONS</a> [<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> 149</div> 150 151 152 153</body> 154</html> 155