⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 output-section-data.html

📁 gcc手册
💻 HTML
字号:
<html lang="en">

<head>

<title>Untitled</title>

<meta http-equiv="Content-Type" content="text/html">

<meta name="description" content="Untitled">

<meta name="generator" content="makeinfo 4.3">

<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">

</head>

<body>

<div class="node">

<p>

Node:<a name="Output%20Section%20Data">Output Section Data</a>,

Next:<a rel="next" accesskey="n" href="Output-Section-Keywords.html#Output%20Section%20Keywords">Output Section Keywords</a>,

Previous:<a rel="previous" accesskey="p" href="Input-Section.html#Input%20Section">Input Section</a>,

Up:<a rel="up" accesskey="u" href="SECTIONS.html#SECTIONS">SECTIONS</a>

<hr><br>

</div>



<h4 class="subsection">Output section data</h4>



   <p>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 <code>addr</code>:

<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>

   whereas this will work:

<pre class="smallexample">     SECTIONS { .text : { *(.text) ; LONG(1) } .data : { *(.data) } } </pre>



   <p>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 <code>0x90</code>:

<pre class="smallexample">     FILL(0x90909090)

     </pre>



   <p>The <code>FILL</code> command is similar to the <code>=</code><var>fillexp</var><code></code> 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%20Section%20Fill">Output Section Fill</a>, for details on the fill

expression.



   </body></html>



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -