| <html lang="en"> |
| <head> |
| <title>Global Variables - STABS</title> |
| <meta http-equiv="Content-Type" content="text/html"> |
| <meta name="description" content="STABS"> |
| <meta name="generator" content="makeinfo 4.13"> |
| <link title="Top" rel="start" href="index.html#Top"> |
| <link rel="up" href="Variables.html#Variables" title="Variables"> |
| <link rel="prev" href="Stack-Variables.html#Stack-Variables" title="Stack Variables"> |
| <link rel="next" href="Register-Variables.html#Register-Variables" title="Register Variables"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <!-- |
| Copyright (C) 1992-2019 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''.--> |
| <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> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="Global-Variables"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="Register-Variables.html#Register-Variables">Register Variables</a>, |
| Previous: <a rel="previous" accesskey="p" href="Stack-Variables.html#Stack-Variables">Stack Variables</a>, |
| Up: <a rel="up" accesskey="u" href="Variables.html#Variables">Variables</a> |
| <hr> |
| </div> |
| |
| <h3 class="section">4.2 Global Variables</h3> |
| |
| <p><a name="index-N_005fGSYM-27"></a><a name="index-C_005fGSYM-28"></a><!-- FIXME: verify for sure that it really is C_GSYM on XCOFF --> |
| A variable whose scope is not specific to just one source file is |
| represented by the ‘<samp><span class="samp">G</span></samp>’ symbol descriptor. These stabs use the |
| <code>N_GSYM</code> stab type (C_GSYM for XCOFF). The type information for |
| the stab (see <a href="String-Field.html#String-Field">String Field</a>) gives the type of the variable. |
| |
| <p>For example, the following source code: |
| |
| <pre class="example"> char g_foo = 'c'; |
| </pre> |
| <p class="noindent">yields the following assembly code: |
| |
| <pre class="example"> .stabs "g_foo:G2",32,0,0,0 # <span class="roman">32 is N_GSYM</span> |
| .global _g_foo |
| .data |
| _g_foo: |
| .byte 99 |
| </pre> |
| <p>The address of the variable represented by the <code>N_GSYM</code> is not |
| contained in the <code>N_GSYM</code> stab. The debugger gets this information |
| from the external symbol for the global variable. In the example above, |
| the <code>.global _g_foo</code> and <code>_g_foo:</code> lines tell the assembler to |
| produce an external symbol. |
| |
| <p>Some compilers, like GCC, output <code>N_GSYM</code> stabs only once, where |
| the variable is defined. Other compilers, like SunOS4 /bin/cc, output a |
| <code>N_GSYM</code> stab for each compilation unit which references the |
| variable. |
| |
| </body></html> |
| |