4 <meta http-equiv=
"Content-Type" content=
"text/html">
5 <meta name=
"description" content=
"STABS">
6 <meta name=
"generator" content=
"makeinfo 4.3">
7 <link href=
"http://www.gnu.org/software/texinfo/" rel=
"generator-home">
12 Node:
<a name=
"Global%20Variables">Global Variables
</a>,
13 Next:
<a rel=
"next" accesskey=
"n" href=
"Register-Variables.html#Register%20Variables">Register Variables
</a>,
14 Previous:
<a rel=
"previous" accesskey=
"p" href=
"Stack-Variables.html#Stack%20Variables">Stack Variables
</a>,
15 Up:
<a rel=
"up" accesskey=
"u" href=
"Variables.html#Variables">Variables
</a>
19 <h3 class=
"section">Global Variables
</h3>
21 <p>A variable whose scope is not specific to just one source file is
22 represented by the
<code>G
</code> symbol descriptor. These stabs use the
23 <code>N_GSYM
</code> stab type (C_GSYM for XCOFF). The type information for
24 the stab (see
<a href=
"String-Field.html#String%20Field">String Field
</a>) gives the type of the variable.
26 <p>For example, the following source code:
28 <pre class=
"example"> char g_foo = 'c';
31 <p>yields the following assembly code:
33 <pre class=
"example"> .stabs
"g_foo:G2",
32,
0,
0,
0 #
32 is N_GSYM
40 <p>The address of the variable represented by the
<code>N_GSYM
</code> is not
41 contained in the
<code>N_GSYM
</code> stab. The debugger gets this information
42 from the external symbol for the global variable. In the example above,
43 the
<code>.global _g_foo
</code> and
<code>_g_foo:
</code> lines tell the assembler to
44 produce an external symbol.
46 <p>Some compilers, like GCC, output
<code>N_GSYM
</code> stabs only once, where
47 the variable is defined. Other compilers, like SunOS4 /bin/cc, output a
48 <code>N_GSYM
</code> stab for each compilation unit which references the