143 lines
7.0 KiB
HTML
143 lines
7.0 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
|
<html>
|
||
|
<!-- Copyright (C) 1992-2017 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: Statics</title>
|
||
|
|
||
|
<meta name="description" content="STABS: Statics">
|
||
|
<meta name="keywords" content="STABS: Statics">
|
||
|
<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="Based-Variables.html#Based-Variables" rel="next" title="Based Variables">
|
||
|
<link href="Common-Blocks.html#Common-Blocks" rel="prev" title="Common Blocks">
|
||
|
<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="Statics"></a>
|
||
|
<div class="header">
|
||
|
<p>
|
||
|
Next: <a href="Based-Variables.html#Based-Variables" accesskey="n" rel="next">Based Variables</a>, Previous: <a href="Common-Blocks.html#Common-Blocks" accesskey="p" rel="prev">Common Blocks</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="Static-Variables"></a>
|
||
|
<h3 class="section">4.5 Static Variables</h3>
|
||
|
|
||
|
<p>Initialized static variables are represented by the ‘<samp>S</samp>’ and
|
||
|
‘<samp>V</samp>’ symbol descriptors. ‘<samp>S</samp>’ means file scope static, and
|
||
|
‘<samp>V</samp>’ means procedure scope static. One exception: in XCOFF, IBM’s
|
||
|
xlc compiler always uses ‘<samp>V</samp>’, and whether it is file scope or not
|
||
|
is distinguished by whether the stab is located within a function.
|
||
|
</p>
|
||
|
<a name="index-N_005fSTSYM"></a>
|
||
|
<a name="index-N_005fLCSYM"></a>
|
||
|
<a name="index-N_005fFUN_002c-for-variables"></a>
|
||
|
<a name="index-N_005fROSYM"></a>
|
||
|
<p>In a.out files, <code>N_STSYM</code> means the data section, <code>N_FUN</code>
|
||
|
means the text section, and <code>N_LCSYM</code> means the bss section. For
|
||
|
those systems with a read-only data section separate from the text
|
||
|
section (Solaris), <code>N_ROSYM</code> means the read-only data section.
|
||
|
</p>
|
||
|
<p>For example, the source lines:
|
||
|
</p>
|
||
|
<div class="example">
|
||
|
<pre class="example">static const int var_const = 5;
|
||
|
static int var_init = 2;
|
||
|
static int var_noinit;
|
||
|
</pre></div>
|
||
|
|
||
|
<p>yield the following stabs:
|
||
|
</p>
|
||
|
<div class="example">
|
||
|
<pre class="example">.stabs "var_const:S1",36,0,0,_var_const # <span class="roman">36 is N_FUN</span>
|
||
|
…
|
||
|
.stabs "var_init:S1",38,0,0,_var_init # <span class="roman">38 is N_STSYM</span>
|
||
|
…
|
||
|
.stabs "var_noinit:S1",40,0,0,_var_noinit # <span class="roman">40 is N_LCSYM</span>
|
||
|
</pre></div>
|
||
|
|
||
|
<a name="index-C_005fSTSYM"></a>
|
||
|
<a name="index-C_005fBSTAT"></a>
|
||
|
<a name="index-C_005fESTAT"></a>
|
||
|
<p>In XCOFF files, the stab type need not indicate the section;
|
||
|
<code>C_STSYM</code> can be used for all statics. Also, each static variable
|
||
|
is enclosed in a static block. A <code>C_BSTAT</code> (emitted with a
|
||
|
‘<samp>.bs</samp>’ assembler directive) symbol begins the static block; its
|
||
|
value is the symbol number of the csect symbol whose value is the
|
||
|
address of the static block, its section is the section of the variables
|
||
|
in that static block, and its name is ‘<samp>.bs</samp>’. A <code>C_ESTAT</code>
|
||
|
(emitted with a ‘<samp>.es</samp>’ assembler directive) symbol ends the static
|
||
|
block; its name is ‘<samp>.es</samp>’ and its value and section are ignored.
|
||
|
</p>
|
||
|
<p>In ECOFF files, the storage class is used to specify the section, so the
|
||
|
stab type need not indicate the section.
|
||
|
</p>
|
||
|
<p>In ELF files, for the SunPRO compiler version 2.0.1, symbol descriptor
|
||
|
‘<samp>S</samp>’ means that the address is absolute (the linker relocates it)
|
||
|
and symbol descriptor ‘<samp>V</samp>’ means that the address is relative to the
|
||
|
start of the relevant section for that compilation unit. SunPRO has
|
||
|
plans to have the linker stop relocating stabs; I suspect that their the
|
||
|
debugger gets the address from the corresponding ELF (not stab) symbol.
|
||
|
I’m not sure how to find which symbol of that name is the right one.
|
||
|
The clean way to do all this would be to have the value of a symbol
|
||
|
descriptor ‘<samp>S</samp>’ symbol be an offset relative to the start of the
|
||
|
file, just like everything else, but that introduces obvious
|
||
|
compatibility problems. For more information on linker stab relocation,
|
||
|
See <a href="ELF-Linker-Relocation.html#ELF-Linker-Relocation">ELF Linker Relocation</a>.
|
||
|
</p>
|
||
|
<hr>
|
||
|
<div class="header">
|
||
|
<p>
|
||
|
Next: <a href="Based-Variables.html#Based-Variables" accesskey="n" rel="next">Based Variables</a>, Previous: <a href="Common-Blocks.html#Common-Blocks" accesskey="p" rel="prev">Common Blocks</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>
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|