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=
"Statics">Statics
</a>,
13 Next:
<a rel=
"next" accesskey=
"n" href=
"Based-Variables.html#Based%20Variables">Based Variables
</a>,
14 Previous:
<a rel=
"previous" accesskey=
"p" href=
"Common-Blocks.html#Common%20Blocks">Common Blocks
</a>,
15 Up:
<a rel=
"up" accesskey=
"u" href=
"Variables.html#Variables">Variables
</a>
19 <h3 class=
"section">Static Variables
</h3>
21 <p>Initialized static variables are represented by the
<code>S
</code> and
22 <code>V
</code> symbol descriptors.
<code>S
</code> means file scope static, and
23 <code>V
</code> means procedure scope static. One exception: in XCOFF, IBM's
24 xlc compiler always uses
<code>V
</code>, and whether it is file scope or not
25 is distinguished by whether the stab is located within a function.
27 <p>In a.out files,
<code>N_STSYM
</code> means the data section,
<code>N_FUN
</code>
28 means the text section, and
<code>N_LCSYM
</code> means the bss section. For
29 those systems with a read-only data section separate from the text
30 section (Solaris),
<code>N_ROSYM
</code> means the read-only data section.
32 <p>For example, the source lines:
34 <pre class=
"example"> static const int var_const =
5;
35 static int var_init =
2;
36 static int var_noinit;
39 <p>yield the following stabs:
41 <pre class=
"example"> .stabs
"var_const:S1",
36,
0,
0,_var_const #
36 is N_FUN
43 .stabs
"var_init:S1",
38,
0,
0,_var_init #
38 is N_STSYM
45 .stabs
"var_noinit:S1",
40,
0,
0,_var_noinit #
40 is N_LCSYM
48 <p>In XCOFF files, the stab type need not indicate the section;
49 <code>C_STSYM
</code> can be used for all statics. Also, each static variable
50 is enclosed in a static block. A
<code>C_BSTAT
</code> (emitted with a
51 <code>.bs
</code> assembler directive) symbol begins the static block; its
52 value is the symbol number of the csect symbol whose value is the
53 address of the static block, its section is the section of the variables
54 in that static block, and its name is
<code>.bs
</code>. A
<code>C_ESTAT
</code>
55 (emitted with a
<code>.es
</code> assembler directive) symbol ends the static
56 block; its name is
<code>.es
</code> and its value and section are ignored.
58 <p>In ECOFF files, the storage class is used to specify the section, so the
59 stab type need not indicate the section.
61 <p>In ELF files, for the SunPRO compiler version
2.0.1, symbol descriptor
62 <code>S
</code> means that the address is absolute (the linker relocates it)
63 and symbol descriptor
<code>V
</code> means that the address is relative to the
64 start of the relevant section for that compilation unit. SunPRO has
65 plans to have the linker stop relocating stabs; I suspect that their the
66 debugger gets the address from the corresponding ELF (not stab) symbol.
67 I'm not sure how to find which symbol of that name is the right one.
68 The clean way to do all this would be to have a the value of a symbol
69 descriptor
<code>S
</code> symbol be an offset relative to the start of the
70 file, just like everything else, but that introduces obvious
71 compatibility problems. For more information on linker stab relocation,
72 See
<a href=
"ELF-Linker-Relocation.html#ELF%20Linker%20Relocation">ELF Linker Relocation
</a>.