blob: 5de3a79667831be90f88a590056497261fee5a4b [file] [log] [blame]
<html lang="en">
<head>
<title>MIPS Object - Using as</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Using as">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="MIPS_002dDependent.html#MIPS_002dDependent" title="MIPS-Dependent">
<link rel="prev" href="MIPS-Opts.html#MIPS-Opts" title="MIPS Opts">
<link rel="next" href="MIPS-Stabs.html#MIPS-Stabs" title="MIPS Stabs">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This file documents the GNU Assembler "as".
Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, with no Front-Cover Texts, and with no
Back-Cover Texts. A copy of the license is included in the
section entitled ``GNU Free Documentation License''.
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
<link rel="stylesheet" type="text/css" href="../cs.css">
</head>
<body>
<div class="node">
<a name="MIPS-Object"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="MIPS-Stabs.html#MIPS-Stabs">MIPS Stabs</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="MIPS-Opts.html#MIPS-Opts">MIPS Opts</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="MIPS_002dDependent.html#MIPS_002dDependent">MIPS-Dependent</a>
<hr>
</div>
<h4 class="subsection">9.24.2 MIPS ECOFF object code</h4>
<p><a name="index-ECOFF-sections-1266"></a><a name="index-MIPS-ECOFF-sections-1267"></a>Assembling for a <span class="sc">mips</span> <span class="sc">ecoff</span> target supports some additional sections
besides the usual <code>.text</code>, <code>.data</code> and <code>.bss</code>. The
additional sections are <code>.rdata</code>, used for read-only data,
<code>.sdata</code>, used for small data, and <code>.sbss</code>, used for small
common objects.
<p><a name="index-small-objects_002c-MIPS-ECOFF-1268"></a><a name="index-g_t_0040code_007bgp_007d-register_002c-MIPS-1269"></a>When assembling for <span class="sc">ecoff</span>, the assembler uses the <code>$gp</code> (<code>$28</code>)
register to form the address of a &ldquo;small object&rdquo;. Any object in the
<code>.sdata</code> or <code>.sbss</code> sections is considered &ldquo;small&rdquo; in this sense.
For external objects, or for objects in the <code>.bss</code> section, you can use
the <code>gcc</code> &lsquo;<samp><span class="samp">-G</span></samp>&rsquo; option to control the size of objects addressed via
<code>$gp</code>; the default value is 8, meaning that a reference to any object
eight bytes or smaller uses <code>$gp</code>. Passing &lsquo;<samp><span class="samp">-G 0</span></samp>&rsquo; to
<code>as</code> prevents it from using the <code>$gp</code> register on the basis
of object size (but the assembler uses <code>$gp</code> for objects in <code>.sdata</code>
or <code>sbss</code> in any case). The size of an object in the <code>.bss</code> section
is set by the <code>.comm</code> or <code>.lcomm</code> directive that defines it. The
size of an external object may be set with the <code>.extern</code> directive. For
example, &lsquo;<samp><span class="samp">.extern sym,4</span></samp>&rsquo; declares that the object at <code>sym</code> is 4 bytes
in length, whie leaving <code>sym</code> otherwise undefined.
<p>Using small <span class="sc">ecoff</span> objects requires linker support, and assumes that the
<code>$gp</code> register is correctly initialized (normally done automatically by
the startup code). <span class="sc">mips</span> <span class="sc">ecoff</span> assembly code must not modify the
<code>$gp</code> register.
</body></html>