You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 satır
6.9KB

  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-2020 Free Software Foundation, Inc.
  4. Contributed by Cygnus Support. Written by Julia Menapace, Jim Kingdon,
  5. and David MacKenzie.
  6. Permission is granted to copy, distribute and/or modify this document
  7. under the terms of the GNU Free Documentation License, Version 1.3 or
  8. any later version published by the Free Software Foundation; with no
  9. Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
  10. Texts. A copy of the license is included in the section entitled "GNU
  11. Free Documentation License". -->
  12. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  15. <title>Statics (STABS)</title>
  16. <meta name="description" content="Statics (STABS)">
  17. <meta name="keywords" content="Statics (STABS)">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <link href="index.html#Top" rel="start" title="Top">
  22. <link href="Symbol-Types-Index.html#Symbol-Types-Index" rel="index" title="Symbol Types Index">
  23. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  24. <link href="Variables.html#Variables" rel="up" title="Variables">
  25. <link href="Based-Variables.html#Based-Variables" rel="next" title="Based Variables">
  26. <link href="Common-Blocks.html#Common-Blocks" rel="prev" title="Common Blocks">
  27. <style type="text/css">
  28. <!--
  29. a.summary-letter {text-decoration: none}
  30. blockquote.indentedblock {margin-right: 0em}
  31. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  32. blockquote.smallquotation {font-size: smaller}
  33. div.display {margin-left: 3.2em}
  34. div.example {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smalllisp {margin-left: 3.2em}
  39. kbd {font-style: oblique}
  40. pre.display {font-family: inherit}
  41. pre.format {font-family: inherit}
  42. pre.menu-comment {font-family: serif}
  43. pre.menu-preformatted {font-family: serif}
  44. pre.smalldisplay {font-family: inherit; font-size: smaller}
  45. pre.smallexample {font-size: smaller}
  46. pre.smallformat {font-family: inherit; font-size: smaller}
  47. pre.smalllisp {font-size: smaller}
  48. span.nolinebreak {white-space: nowrap}
  49. span.roman {font-family: initial; font-weight: normal}
  50. span.sansserif {font-family: sans-serif; font-weight: normal}
  51. ul.no-bullet {list-style: none}
  52. -->
  53. </style>
  54. </head>
  55. <body lang="en">
  56. <a name="Statics"></a>
  57. <div class="header">
  58. <p>
  59. 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> &nbsp; [<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>
  60. </div>
  61. <hr>
  62. <a name="Static-Variables"></a>
  63. <h3 class="section">4.5 Static Variables</h3>
  64. <p>Initialized static variables are represented by the &lsquo;<samp>S</samp>&rsquo; and
  65. &lsquo;<samp>V</samp>&rsquo; symbol descriptors. &lsquo;<samp>S</samp>&rsquo; means file scope static, and
  66. &lsquo;<samp>V</samp>&rsquo; means procedure scope static. One exception: in XCOFF, IBM&rsquo;s
  67. xlc compiler always uses &lsquo;<samp>V</samp>&rsquo;, and whether it is file scope or not
  68. is distinguished by whether the stab is located within a function.
  69. </p>
  70. <a name="index-N_005fSTSYM"></a>
  71. <a name="index-N_005fLCSYM"></a>
  72. <a name="index-N_005fFUN_002c-for-variables"></a>
  73. <a name="index-N_005fROSYM"></a>
  74. <p>In a.out files, <code>N_STSYM</code> means the data section, <code>N_FUN</code>
  75. means the text section, and <code>N_LCSYM</code> means the bss section. For
  76. those systems with a read-only data section separate from the text
  77. section (Solaris), <code>N_ROSYM</code> means the read-only data section.
  78. </p>
  79. <p>For example, the source lines:
  80. </p>
  81. <div class="example">
  82. <pre class="example">static const int var_const = 5;
  83. static int var_init = 2;
  84. static int var_noinit;
  85. </pre></div>
  86. <p>yield the following stabs:
  87. </p>
  88. <div class="example">
  89. <pre class="example">.stabs &quot;var_const:S1&quot;,36,0,0,_var_const # <span class="roman">36 is N_FUN</span>
  90. &hellip;
  91. .stabs &quot;var_init:S1&quot;,38,0,0,_var_init # <span class="roman">38 is N_STSYM</span>
  92. &hellip;
  93. .stabs &quot;var_noinit:S1&quot;,40,0,0,_var_noinit # <span class="roman">40 is N_LCSYM</span>
  94. </pre></div>
  95. <a name="index-C_005fSTSYM"></a>
  96. <a name="index-C_005fBSTAT"></a>
  97. <a name="index-C_005fESTAT"></a>
  98. <p>In XCOFF files, the stab type need not indicate the section;
  99. <code>C_STSYM</code> can be used for all statics. Also, each static variable
  100. is enclosed in a static block. A <code>C_BSTAT</code> (emitted with a
  101. &lsquo;<samp>.bs</samp>&rsquo; assembler directive) symbol begins the static block; its
  102. value is the symbol number of the csect symbol whose value is the
  103. address of the static block, its section is the section of the variables
  104. in that static block, and its name is &lsquo;<samp>.bs</samp>&rsquo;. A <code>C_ESTAT</code>
  105. (emitted with a &lsquo;<samp>.es</samp>&rsquo; assembler directive) symbol ends the static
  106. block; its name is &lsquo;<samp>.es</samp>&rsquo; and its value and section are ignored.
  107. </p>
  108. <p>In ECOFF files, the storage class is used to specify the section, so the
  109. stab type need not indicate the section.
  110. </p>
  111. <p>In ELF files, for the SunPRO compiler version 2.0.1, symbol descriptor
  112. &lsquo;<samp>S</samp>&rsquo; means that the address is absolute (the linker relocates it)
  113. and symbol descriptor &lsquo;<samp>V</samp>&rsquo; means that the address is relative to the
  114. start of the relevant section for that compilation unit. SunPRO has
  115. plans to have the linker stop relocating stabs; I suspect that their the
  116. debugger gets the address from the corresponding ELF (not stab) symbol.
  117. I&rsquo;m not sure how to find which symbol of that name is the right one.
  118. The clean way to do all this would be to have the value of a symbol
  119. descriptor &lsquo;<samp>S</samp>&rsquo; symbol be an offset relative to the start of the
  120. file, just like everything else, but that introduces obvious
  121. compatibility problems. For more information on linker stab relocation,
  122. See <a href="ELF-Linker-Relocation.html#ELF-Linker-Relocation">ELF Linker Relocation</a>.
  123. </p>
  124. <hr>
  125. <div class="header">
  126. <p>
  127. 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> &nbsp; [<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>
  128. </div>
  129. </body>
  130. </html>