1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<!-- Copyright (C) 1992-2021 Free Software Foundation, Inc. 4Contributed by Cygnus Support. Written by Julia Menapace, Jim Kingdon, 5and David MacKenzie. 6 7Permission is granted to copy, distribute and/or modify this document 8under the terms of the GNU Free Documentation License, Version 1.3 or 9any later version published by the Free Software Foundation; with no 10Invariant Sections, with no Front-Cover Texts, and with no Back-Cover 11Texts. A copy of the license is included in the section entitled "GNU 12Free Documentation License". --> 13<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ --> 14<head> 15<title>STABS: Stack Variables</title> 16 17<meta name="description" content="STABS: Stack Variables"> 18<meta name="keywords" content="STABS: Stack Variables"> 19<meta name="resource-type" content="document"> 20<meta name="distribution" content="global"> 21<meta name="Generator" content="makeinfo"> 22<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 23<link href="index.html#Top" rel="start" title="Top"> 24<link href="Symbol-Types-Index.html#Symbol-Types-Index" rel="index" title="Symbol Types Index"> 25<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> 26<link href="Variables.html#Variables" rel="up" title="Variables"> 27<link href="Global-Variables.html#Global-Variables" rel="next" title="Global Variables"> 28<link href="Variables.html#Variables" rel="previous" title="Variables"> 29<style type="text/css"> 30<!-- 31a.summary-letter {text-decoration: none} 32blockquote.smallquotation {font-size: smaller} 33div.display {margin-left: 3.2em} 34div.example {margin-left: 3.2em} 35div.indentedblock {margin-left: 3.2em} 36div.lisp {margin-left: 3.2em} 37div.smalldisplay {margin-left: 3.2em} 38div.smallexample {margin-left: 3.2em} 39div.smallindentedblock {margin-left: 3.2em; font-size: smaller} 40div.smalllisp {margin-left: 3.2em} 41kbd {font-style:oblique} 42pre.display {font-family: inherit} 43pre.format {font-family: inherit} 44pre.menu-comment {font-family: serif} 45pre.menu-preformatted {font-family: serif} 46pre.smalldisplay {font-family: inherit; font-size: smaller} 47pre.smallexample {font-size: smaller} 48pre.smallformat {font-family: inherit; font-size: smaller} 49pre.smalllisp {font-size: smaller} 50span.nocodebreak {white-space:nowrap} 51span.nolinebreak {white-space:nowrap} 52span.roman {font-family:serif; font-weight:normal} 53span.sansserif {font-family:sans-serif; font-weight:normal} 54ul.no-bullet {list-style: none} 55--> 56</style> 57 58 59</head> 60 61<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> 62<a name="Stack-Variables"></a> 63<div class="header"> 64<p> 65Next: <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> 66</div> 67<hr> 68<a name="Automatic-Variables-Allocated-on-the-Stack"></a> 69<h3 class="section">4.1 Automatic Variables Allocated on the Stack</h3> 70 71<p>If a variable’s scope is local to a function and its lifetime is only as 72long as that function executes (C calls such variables 73<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. 74</p> 75<a name="index-N_005fLSYM_002c-for-stack-variables"></a> 76<a name="index-C_005fLSYM"></a> 77<p>Each variable allocated on the stack has a stab with the symbol 78descriptor omitted. Since type information should begin with a digit, 79‘<samp>-</samp>’, or ‘<samp>(</samp>’, only those characters precluded from being used 80for symbol descriptors. However, the Acorn RISC machine (ARM) is said 81to get this wrong: it puts out a mere type definition here, without the 82preceding ‘<samp><var>type-number</var>=</samp>’. This is a bad idea; there is no 83guarantee that type descriptors are distinct from symbol descriptors. 84Stabs for stack variables use the <code>N_LSYM</code> stab type, or 85<code>C_LSYM</code> for XCOFF. 86</p> 87<p>The value of the stab is the offset of the variable within the 88local variables. On most machines this is an offset from the frame 89pointer and is negative. The location of the stab specifies which block 90it is defined in; see <a href="Block-Structure.html#Block-Structure">Block Structure</a>. 91</p> 92<p>For example, the following C code: 93</p> 94<div class="example"> 95<pre class="example">int 96main () 97{ 98 int x; 99} 100</pre></div> 101 102<p>produces the following stabs: 103</p> 104<div class="example"> 105<pre class="example">.stabs "main:F1",36,0,0,_main # <span class="roman">36 is N_FUN</span> 106.stabs "x:1",128,0,0,-12 # <span class="roman">128 is N_LSYM</span> 107.stabn 192,0,0,LBB2 # <span class="roman">192 is N_LBRAC</span> 108.stabn 224,0,0,LBE2 # <span class="roman">224 is N_RBRAC</span> 109</pre></div> 110 111<p>See <a href="Procedures.html#Procedures">Procedures</a> for more information on the <code>N_FUN</code> stab, and 112<a href="Block-Structure.html#Block-Structure">Block Structure</a> for more information on the <code>N_LBRAC</code> and 113<code>N_RBRAC</code> stabs. 114</p> 115 116 117 118</body> 119</html> 120