<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.8">
<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">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
@import url("../raisonance.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>
</head>
<body>
<div class="node">
<p>
<a name="MIPS-Object"></a>
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">8.20.2 MIPS ECOFF object code</h4>

<p><a name="index-ECOFF-sections-1156"></a><a name="index-MIPS-ECOFF-sections-1157"></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-1158"></a><a name="index-g_t_0040code_007bgp_007d-register_002c-MIPS-1159"></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> `<samp><span class="samp">-G</span></samp>' 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 `<samp><span class="samp">-G 0</span></samp>' 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, `<samp><span class="samp">.extern sym,4</span></samp>' 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>

