📄 output-section-address.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%20Address">Output Section Address</a>,
Next:<a rel="next" accesskey="n" href="Input-Section.html#Input%20Section">Input Section</a>,
Previous:<a rel="previous" accesskey="p" href="Output-Section-Name.html#Output%20Section%20Name">Output Section Name</a>,
Up:<a rel="up" accesskey="u" href="SECTIONS.html#SECTIONS">SECTIONS</a>
<hr><br>
</div>
<h4 class="subsection">Output section address</h4>
<p>The <var>address</var> is an expression for the VMA (the virtual memory
address) of the output section. If you do not provide <var>address</var>,
the linker will set it based on <var>region</var> if present, or otherwise
based on the current value of the location counter.
<p>If you provide <var>address</var>, the address of the output section will be
set to precisely that. If you provide neither <var>address</var> nor
<var>region</var>, then the address of the output section will be set to the
current value of the location counter aligned to the alignment
requirements of the output section. The alignment requirement of the
output section is the strictest alignment of any input section contained
within the output section.
<p>For example,
<pre class="smallexample"> .text . : { *(.text) }
</pre>
<p>and
<pre class="smallexample"> .text : { *(.text) }
</pre>
<p>are subtly different. The first will set the address of the
<code>.text</code> 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 a <code>.text</code> input
section.
<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>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.
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -