📄 section.html
字号:
<html lang="en">
<head>
<title>Using as</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Using as">
<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="Section">Section</a>,
Next:<a rel="next" accesskey="n" href="Set.html#Set">Set</a>,
Previous:<a rel="previous" accesskey="p" href="Scl.html#Scl">Scl</a>,
Up:<a rel="up" accesskey="u" href="Pseudo-Ops.html#Pseudo%20Ops">Pseudo Ops</a>
<hr><br>
</div>
<h3 class="section"><code>.section </code><var>name</var><code></code> (COFF version)</h3>
<p>Use the <code>.section</code> directive to assemble the following code into a section
named <var>name</var>.
<p>This directive is only supported for targets that actually support arbitrarily
named sections; on <code>a.out</code> targets, for example, it is not accepted, even
with a standard <code>a.out</code> section name.
<p>For COFF targets, the <code>.section</code> directive is used in one of the following
ways:
<pre class="smallexample"> .section <var>name</var>[, "<var>flags</var>"]
.section <var>name</var>[, <var>subsegment</var>]
</pre>
<p>If the optional argument is quoted, it is taken as flags to use for the
section. Each flag is a single character. The following flags are recognized:
<dl>
<dt><code>b</code>
<dd>bss section (uninitialized data)
<br><dt><code>n</code>
<dd>section is not loaded
<br><dt><code>w</code>
<dd>writable section
<br><dt><code>d</code>
<dd>data section
<br><dt><code>r</code>
<dd>read-only section
<br><dt><code>x</code>
<dd>executable section
<br><dt><code>s</code>
<dd>shared section (meaningful for PE targets)
<br><dt><code>a</code>
<dd>ignored. (For compatibility with the ELF version)
</dl>
<p>If no flags are specified, the default flags depend upon the section name. If
the section name is not recognized, the default will be for the section to be
loaded and writable. Note the <code>n</code> and <code>w</code> flags remove attributes
from the section, rather than adding them, so if they are used on their own it
will be as if no flags had been specified at all.
<p>If the optional argument to the <code>.section</code> directive is not quoted, it is
taken as a subsegment number (see <a href="Sub-Sections.html#Sub-Sections">Sub-Sections</a>).
<h3 class="section"><code>.section </code><var>name</var><code></code> (ELF version)</h3>
<p>This is one of the ELF section stack manipulation directives. The others are
<code>.subsection</code> (see <a href="SubSection.html#SubSection">SubSection</a>), <code>.pushsection</code>
(see <a href="PushSection.html#PushSection">PushSection</a>), <code>.popsection</code> (see <a href="PopSection.html#PopSection">PopSection</a>), and
<code>.previous</code> (see <a href="Previous.html#Previous">Previous</a>).
<p>For ELF targets, the <code>.section</code> directive is used like this:
<pre class="smallexample"> .section <var>name</var> [, "<var>flags</var>"[, @<var>type</var>[, @<var>entsize</var>]]]
</pre>
<p>The optional <var>flags</var> argument is a quoted string which may contain any
combination of the following characters:
<dl>
<dt><code>a</code>
<dd>section is allocatable
<br><dt><code>w</code>
<dd>section is writable
<br><dt><code>x</code>
<dd>section is executable
<br><dt><code>M</code>
<dd>section is mergeable
<br><dt><code>S</code>
<dd>section contains zero terminated strings
</dl>
<p>The optional <var>type</var> argument may contain one of the following constants:
<dl>
<dt><code>@progbits</code>
<dd>section contains data
<br><dt><code>@nobits</code>
<dd>section does not contain data (i.e., section only occupies space)
</dl>
<p>If <var>flags</var> contains <code>M</code> flag, <var>type</var> argument must be specified
as well as <var>entsize</var> argument. Sections with <code>M</code> flag but not
<code>S</code> flag must contain fixed size constants, each <var>entsize</var> octets
long. Sections with both <code>M</code> and <code>S</code> must contain zero terminated
strings where each character is <var>entsize</var> bytes long. The linker may remove
duplicates within sections with the same name, same entity size and same flags.
<p>If no flags are specified, the default flags depend upon the section name. If
the section name is not recognized, the default will be for the section to have
none of the above flags: it will not be allocated in memory, nor writable, nor
executable. The section will contain data.
<p>For ELF targets, the assembler supports another type of <code>.section</code>
directive for compatibility with the Solaris assembler:
<pre class="smallexample"> .section "<var>name</var>"[, <var>flags</var>...]
</pre>
<p>Note that the section name is quoted. There may be a sequence of comma
separated flags:
<dl>
<dt><code>#alloc</code>
<dd>section is allocatable
<br><dt><code>#write</code>
<dd>section is writable
<br><dt><code>#execinstr</code>
<dd>section is executable
</dl>
<p>This directive replaces the current section and subsection. The replaced
section and subsection are pushed onto the section stack. See the contents of
the gas testsuite directory <code>gas/testsuite/gas/elf</code> for some examples of
how this directive and the other section stack directives work.
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -