| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
| <html> | |
| <!-- Copyright (C) 1992-2015 Free Software Foundation, Inc. | |
| Contributed by Cygnus Support. Written by Julia Menapace, Jim Kingdon, | |
| and David MacKenzie. | |
| 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". --> | |
| <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ --> | |
| <head> | |
| <title>STABS: Stack Variables</title> | |
| <meta name="description" content="STABS: Stack Variables"> | |
| <meta name="keywords" content="STABS: Stack Variables"> | |
| <meta name="resource-type" content="document"> | |
| <meta name="distribution" content="global"> | |
| <meta name="Generator" content="makeinfo"> | |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
| <link href="index.html#Top" rel="start" title="Top"> | |
| <link href="Symbol-Types-Index.html#Symbol-Types-Index" rel="index" title="Symbol Types Index"> | |
| <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> | |
| <link href="Variables.html#Variables" rel="up" title="Variables"> | |
| <link href="Global-Variables.html#Global-Variables" rel="next" title="Global Variables"> | |
| <link href="Variables.html#Variables" rel="prev" title="Variables"> | |
| <style type="text/css"> | |
| <!-- | |
| a.summary-letter {text-decoration: none} | |
| blockquote.smallquotation {font-size: smaller} | |
| div.display {margin-left: 3.2em} | |
| div.example {margin-left: 3.2em} | |
| div.indentedblock {margin-left: 3.2em} | |
| div.lisp {margin-left: 3.2em} | |
| div.smalldisplay {margin-left: 3.2em} | |
| div.smallexample {margin-left: 3.2em} | |
| div.smallindentedblock {margin-left: 3.2em; font-size: smaller} | |
| div.smalllisp {margin-left: 3.2em} | |
| kbd {font-style:oblique} | |
| pre.display {font-family: inherit} | |
| pre.format {font-family: inherit} | |
| pre.menu-comment {font-family: serif} | |
| pre.menu-preformatted {font-family: serif} | |
| pre.smalldisplay {font-family: inherit; font-size: smaller} | |
| pre.smallexample {font-size: smaller} | |
| pre.smallformat {font-family: inherit; font-size: smaller} | |
| pre.smalllisp {font-size: smaller} | |
| span.nocodebreak {white-space:nowrap} | |
| span.nolinebreak {white-space:nowrap} | |
| span.roman {font-family:serif; font-weight:normal} | |
| span.sansserif {font-family:sans-serif; font-weight:normal} | |
| ul.no-bullet {list-style: none} | |
| --> | |
| </style> | |
| </head> | |
| <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> | |
| <a name="Stack-Variables"></a> | |
| <div class="header"> | |
| <p> | |
| Next: <a href="Global-Variables.html#Global-Variables" accesskey="n" rel="next">Global Variables</a>, Up: <a href="Variables.html#Variables" accesskey="u" rel="up">Variables</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Types-Index.html#Symbol-Types-Index" title="Index" rel="index">Index</a>]</p> | |
| </div> | |
| <hr> | |
| <a name="Automatic-Variables-Allocated-on-the-Stack"></a> | |
| <h3 class="section">4.1 Automatic Variables Allocated on the Stack</h3> | |
| <p>If a variable’s scope is local to a function and its lifetime is only as | |
| long as that function executes (C calls such variables | |
| <em>automatic</em>), it can be allocated in a register (see <a href="Register-Variables.html#Register-Variables">Register Variables</a>) or on the stack. | |
| </p> | |
| <a name="index-N_005fLSYM_002c-for-stack-variables"></a> | |
| <a name="index-C_005fLSYM"></a> | |
| <p>Each variable allocated on the stack has a stab with the symbol | |
| descriptor omitted. Since type information should begin with a digit, | |
| ‘<samp>-</samp>’, or ‘<samp>(</samp>’, only those characters precluded from being used | |
| for symbol descriptors. However, the Acorn RISC machine (ARM) is said | |
| to get this wrong: it puts out a mere type definition here, without the | |
| preceding ‘<samp><var>type-number</var>=</samp>’. This is a bad idea; there is no | |
| guarantee that type descriptors are distinct from symbol descriptors. | |
| Stabs for stack variables use the <code>N_LSYM</code> stab type, or | |
| <code>C_LSYM</code> for XCOFF. | |
| </p> | |
| <p>The value of the stab is the offset of the variable within the | |
| local variables. On most machines this is an offset from the frame | |
| pointer and is negative. The location of the stab specifies which block | |
| it is defined in; see <a href="Block-Structure.html#Block-Structure">Block Structure</a>. | |
| </p> | |
| <p>For example, the following C code: | |
| </p> | |
| <div class="example"> | |
| <pre class="example">int | |
| main () | |
| { | |
| int x; | |
| } | |
| </pre></div> | |
| <p>produces the following stabs: | |
| </p> | |
| <div class="example"> | |
| <pre class="example">.stabs "main:F1",36,0,0,_main # <span class="roman">36 is N_FUN</span> | |
| .stabs "x:1",128,0,0,-12 # <span class="roman">128 is N_LSYM</span> | |
| .stabn 192,0,0,LBB2 # <span class="roman">192 is N_LBRAC</span> | |
| .stabn 224,0,0,LBE2 # <span class="roman">224 is N_RBRAC</span> | |
| </pre></div> | |
| <p>See <a href="Procedures.html#Procedures">Procedures</a> for more information on the <code>N_FUN</code> stab, and | |
| <a href="Block-Structure.html#Block-Structure">Block Structure</a> for more information on the <code>N_LBRAC</code> and | |
| <code>N_RBRAC</code> stabs. | |
| </p> | |
| </body> | |
| </html> |