1<html lang="en"> 2<head> 3<title>Output Section Data - Untitled</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Untitled"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="SECTIONS.html#SECTIONS" title="SECTIONS"> 9<link rel="prev" href="Input-Section.html#Input-Section" title="Input Section"> 10<link rel="next" href="Output-Section-Keywords.html#Output-Section-Keywords" title="Output Section Keywords"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<!-- 13This file documents the GNU linker LD 14(Sourcery CodeBench Lite 2011.09-69) 15version 2.21.53. 16 17Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 182001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. 19 20Permission is granted to copy, distribute and/or modify this document 21under the terms of the GNU Free Documentation License, Version 1.3 22or any later version published by the Free Software Foundation; 23with no Invariant Sections, with no Front-Cover Texts, and with no 24Back-Cover Texts. A copy of the license is included in the 25section entitled ``GNU Free Documentation License''.--> 26<meta http-equiv="Content-Style-Type" content="text/css"> 27<style type="text/css"><!-- 28 pre.display { font-family:inherit } 29 pre.format { font-family:inherit } 30 pre.smalldisplay { font-family:inherit; font-size:smaller } 31 pre.smallformat { font-family:inherit; font-size:smaller } 32 pre.smallexample { font-size:smaller } 33 pre.smalllisp { font-size:smaller } 34 span.sc { font-variant:small-caps } 35 span.roman { font-family:serif; font-weight:normal; } 36 span.sansserif { font-family:sans-serif; font-weight:normal; } 37--></style> 38<link rel="stylesheet" type="text/css" href="../cs.css"> 39</head> 40<body> 41<div class="node"> 42<a name="Output-Section-Data"></a> 43<p> 44Next: <a rel="next" accesskey="n" href="Output-Section-Keywords.html#Output-Section-Keywords">Output Section Keywords</a>, 45Previous: <a rel="previous" accesskey="p" href="Input-Section.html#Input-Section">Input Section</a>, 46Up: <a rel="up" accesskey="u" href="SECTIONS.html#SECTIONS">SECTIONS</a> 47<hr> 48</div> 49 50<h4 class="subsection">3.6.5 Output Section Data</h4> 51 52<p><a name="index-data-423"></a><a name="index-section-data-424"></a><a name="index-output-section-data-425"></a><a name="index-BYTE_0028_0040var_007bexpression_007d_0029-426"></a><a name="index-SHORT_0028_0040var_007bexpression_007d_0029-427"></a><a name="index-LONG_0028_0040var_007bexpression_007d_0029-428"></a><a name="index-QUAD_0028_0040var_007bexpression_007d_0029-429"></a><a name="index-SQUAD_0028_0040var_007bexpression_007d_0029-430"></a>You can include explicit bytes of data in an output section by using 53<code>BYTE</code>, <code>SHORT</code>, <code>LONG</code>, <code>QUAD</code>, or <code>SQUAD</code> as 54an output section command. Each keyword is followed by an expression in 55parentheses providing the value to store (see <a href="Expressions.html#Expressions">Expressions</a>). The 56value of the expression is stored at the current value of the location 57counter. 58 59 <p>The <code>BYTE</code>, <code>SHORT</code>, <code>LONG</code>, and <code>QUAD</code> commands 60store one, two, four, and eight bytes (respectively). After storing the 61bytes, the location counter is incremented by the number of bytes 62stored. 63 64 <p>For example, this will store the byte 1 followed by the four byte value 65of the symbol ‘<samp><span class="samp">addr</span></samp>’: 66<pre class="smallexample"> BYTE(1) 67 LONG(addr) 68</pre> 69 <p>When using a 64 bit host or target, <code>QUAD</code> and <code>SQUAD</code> are the 70same; they both store an 8 byte, or 64 bit, value. When both host and 71target are 32 bits, an expression is computed as 32 bits. In this case 72<code>QUAD</code> stores a 32 bit value zero extended to 64 bits, and 73<code>SQUAD</code> stores a 32 bit value sign extended to 64 bits. 74 75 <p>If the object file format of the output file has an explicit endianness, 76which is the normal case, the value will be stored in that endianness. 77When the object file format does not have an explicit endianness, as is 78true of, for example, S-records, the value will be stored in the 79endianness of the first input object file. 80 81 <p>Note—these commands only work inside a section description and not 82between them, so the following will produce an error from the linker: 83<pre class="smallexample"> SECTIONS { .text : { *(.text) } LONG(1) .data : { *(.data) } }</pre> 84 <p>whereas this will work: 85<pre class="smallexample"> SECTIONS { .text : { *(.text) ; LONG(1) } .data : { *(.data) } }</pre> 86 <p><a name="index-FILL_0028_0040var_007bexpression_007d_0029-431"></a><a name="index-holes_002c-filling-432"></a><a name="index-unspecified-memory-433"></a>You may use the <code>FILL</code> command to set the fill pattern for the 87current section. It is followed by an expression in parentheses. Any 88otherwise unspecified regions of memory within the section (for example, 89gaps left due to the required alignment of input sections) are filled 90with the value of the expression, repeated as 91necessary. A <code>FILL</code> statement covers memory locations after the 92point at which it occurs in the section definition; by including more 93than one <code>FILL</code> statement, you can have different fill patterns in 94different parts of an output section. 95 96 <p>This example shows how to fill unspecified regions of memory with the 97value ‘<samp><span class="samp">0x90</span></samp>’: 98<pre class="smallexample"> FILL(0x90909090) 99</pre> 100 <p>The <code>FILL</code> command is similar to the ‘<samp><span class="samp">=</span><var>fillexp</var></samp>’ output 101section attribute, but it only affects the 102part of the section following the <code>FILL</code> command, rather than the 103entire section. If both are used, the <code>FILL</code> command takes 104precedence. See <a href="Output-Section-Fill.html#Output-Section-Fill">Output Section Fill</a>, for details on the fill 105expression. 106 107 </body></html> 108 109