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.

118 lines
5.0KB

  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>Unions (STABS)</title>
  16. <meta name="description" content="Unions (STABS)">
  17. <meta name="keywords" content="Unions (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="Types.html#Types" rel="up" title="Types">
  25. <link href="Function-Types.html#Function-Types" rel="next" title="Function Types">
  26. <link href="Typedefs.html#Typedefs" rel="prev" title="Typedefs">
  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="Unions"></a>
  57. <div class="header">
  58. <p>
  59. Next: <a href="Function-Types.html#Function-Types" accesskey="n" rel="next">Function Types</a>, Previous: <a href="Typedefs.html#Typedefs" accesskey="p" rel="prev">Typedefs</a>, Up: <a href="Types.html#Types" accesskey="u" rel="up">Types</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="Unions-1"></a>
  63. <h3 class="section">5.10 Unions</h3>
  64. <div class="example">
  65. <pre class="example">union u_tag {
  66. int u_int;
  67. float u_float;
  68. char* u_char;
  69. } an_u;
  70. </pre></div>
  71. <p>This code generates a stab for a union tag and a stab for a union
  72. variable. Both use the <code>N_LSYM</code> stab type. If a union variable is
  73. scoped locally to the procedure in which it is defined, its stab is
  74. located immediately preceding the <code>N_LBRAC</code> for the procedure&rsquo;s block
  75. start.
  76. </p>
  77. <p>The stab for the union tag, however, is located preceding the code for
  78. the procedure in which it is defined. The stab type is <code>N_LSYM</code>. This
  79. would seem to imply that the union type is file scope, like the struct
  80. type <code>s_tag</code>. This is not true. The contents and position of the stab
  81. for <code>u_type</code> do not convey any information about its procedure local
  82. scope.
  83. </p>
  84. <div class="smallexample">
  85. <pre class="smallexample"># <span class="roman">128 is N_LSYM</span>
  86. .stabs &quot;u_tag:T23=u4u_int:1,0,32;u_float:12,0,32;u_char:21,0,32;;&quot;,
  87. 128,0,0,0
  88. </pre></div>
  89. <p>The symbol descriptor &lsquo;<samp>T</samp>&rsquo;, following the &lsquo;<samp>name:</samp>&rsquo; means that
  90. the stab describes an enumeration, structure, or union tag. The type
  91. descriptor &lsquo;<samp>u</samp>&rsquo;, following the &lsquo;<samp>23=</samp>&rsquo; of the type definition,
  92. narrows it down to a union type definition. Following the &lsquo;<samp>u</samp>&rsquo; is
  93. the number of bytes in the union. After that is a list of union element
  94. descriptions. Their format is &lsquo;<samp><var>name</var>:<var>type</var>, <var>bit
  95. offset into the union</var>, <var>number of bytes for the element</var>;</samp>&rsquo;.
  96. </p>
  97. <p>The stab for the union variable is:
  98. </p>
  99. <div class="example">
  100. <pre class="example">.stabs &quot;an_u:23&quot;,128,0,0,-20 # <span class="roman">128 is N_LSYM</span>
  101. </pre></div>
  102. <p>&lsquo;<samp>-20</samp>&rsquo; specifies where the variable is stored (see <a href="Stack-Variables.html#Stack-Variables">Stack Variables</a>).
  103. </p>
  104. </body>
  105. </html>