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.

189 lines
7.6KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- This file documents the BFD library.
  4. Copyright (C) 1991-2020 Free Software Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this document
  6. under the terms of the GNU Free Documentation License, Version 1.3 or
  7. any later version published by the Free Software Foundation; with the
  8. Invariant Sections being "GNU General Public License" and "Funding
  9. Free Software", the Front-Cover texts being (a) (see below), and with
  10. the Back-Cover Texts being (b) (see below). A copy of the license is
  11. included in the section entitled "GNU Free Documentation License".
  12. (a) The FSF's Front-Cover Text is:
  13. A GNU Manual
  14. (b) The FSF's Back-Cover Text is:
  15. You have freedom to copy and modify this GNU Manual, like GNU
  16. software. Copies published by the Free Software Foundation raise
  17. funds for GNU development. -->
  18. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  19. <head>
  20. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  21. <title>Symbol-table (Untitled Document)</title>
  22. <meta name="description" content="Symbol-table (Untitled Document)">
  23. <meta name="keywords" content="Symbol-table (Untitled Document)">
  24. <meta name="resource-type" content="document">
  25. <meta name="distribution" content="global">
  26. <meta name="Generator" content="makeinfo">
  27. <link href="index.html#Top" rel="start" title="Top">
  28. <link href="BFD-Index.html#BFD-Index" rel="index" title="BFD Index">
  29. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  30. <link href="mmo.html#mmo" rel="up" title="mmo">
  31. <link href="mmo-section-mapping.html#mmo-section-mapping" rel="next" title="mmo section mapping">
  32. <link href="File-layout.html#File-layout" rel="prev" title="File layout">
  33. <style type="text/css">
  34. <!--
  35. a.summary-letter {text-decoration: none}
  36. blockquote.indentedblock {margin-right: 0em}
  37. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  38. blockquote.smallquotation {font-size: smaller}
  39. div.display {margin-left: 3.2em}
  40. div.example {margin-left: 3.2em}
  41. div.lisp {margin-left: 3.2em}
  42. div.smalldisplay {margin-left: 3.2em}
  43. div.smallexample {margin-left: 3.2em}
  44. div.smalllisp {margin-left: 3.2em}
  45. kbd {font-style: oblique}
  46. pre.display {font-family: inherit}
  47. pre.format {font-family: inherit}
  48. pre.menu-comment {font-family: serif}
  49. pre.menu-preformatted {font-family: serif}
  50. pre.smalldisplay {font-family: inherit; font-size: smaller}
  51. pre.smallexample {font-size: smaller}
  52. pre.smallformat {font-family: inherit; font-size: smaller}
  53. pre.smalllisp {font-size: smaller}
  54. span.nolinebreak {white-space: nowrap}
  55. span.roman {font-family: initial; font-weight: normal}
  56. span.sansserif {font-family: sans-serif; font-weight: normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en">
  62. <a name="Symbol_002dtable"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="mmo-section-mapping.html#mmo-section-mapping" accesskey="n" rel="next">mmo section mapping</a>, Previous: <a href="File-layout.html#File-layout" accesskey="p" rel="prev">File layout</a>, Up: <a href="mmo.html#mmo" accesskey="u" rel="up">mmo</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="BFD-Index.html#BFD-Index" title="Index" rel="index">Index</a>]</p>
  66. </div>
  67. <hr>
  68. <a name="Symbol-table-format"></a>
  69. <h4 class="subsection">3.5.2 Symbol table format</h4>
  70. <p>From mmixal.w (or really, the generated mmixal.tex) in the
  71. MMIXware package which also contains the <code>mmix</code> simulator:
  72. &ldquo;Symbols are stored and retrieved by means of a &lsquo;<samp>ternary
  73. search trie</samp>&rsquo;, following ideas of Bentley and Sedgewick. (See
  74. ACM&ndash;SIAM Symp. on Discrete Algorithms &lsquo;<samp>8</samp>&rsquo; (1997), 360&ndash;369;
  75. R.Sedgewick, &lsquo;<samp>Algorithms in C</samp>&rsquo; (Reading, Mass.
  76. Addison&ndash;Wesley, 1998), &lsquo;<samp>15.4</samp>&rsquo;.) Each trie node stores a
  77. character, and there are branches to subtries for the cases where
  78. a given character is less than, equal to, or greater than the
  79. character in the trie. There also is a pointer to a symbol table
  80. entry if a symbol ends at the current node.&rdquo;
  81. </p>
  82. <p>So it&rsquo;s a tree encoded as a stream of bytes. The stream of bytes
  83. acts on a single virtual global symbol, adding and removing
  84. characters and signalling complete symbol points. Here, we read
  85. the stream and create symbols at the completion points.
  86. </p>
  87. <p>First, there&rsquo;s a control byte <code>m</code>. If any of the listed bits
  88. in <code>m</code> is nonzero, we execute what stands at the right, in
  89. the listed order:
  90. </p>
  91. <div class="example">
  92. <pre class="example"> (MMO3_LEFT)
  93. 0x40 - Traverse left trie.
  94. (Read a new command byte and recurse.)
  95. (MMO3_SYMBITS)
  96. 0x2f - Read the next byte as a character and store it in the
  97. current character position; increment character position.
  98. Test the bits of <code>m</code>:
  99. (MMO3_WCHAR)
  100. 0x80 - The character is 16-bit (so read another byte,
  101. merge into current character.
  102. (MMO3_TYPEBITS)
  103. 0xf - We have a complete symbol; parse the type, value
  104. and serial number and do what should be done
  105. with a symbol. The type and length information
  106. is in j = (m &amp; 0xf).
  107. (MMO3_REGQUAL_BITS)
  108. j == 0xf: A register variable. The following
  109. byte tells which register.
  110. j &lt;= 8: An absolute symbol. Read j bytes as the
  111. big-endian number the symbol equals.
  112. A j = 2 with two zero bytes denotes an
  113. unknown symbol.
  114. j &gt; 8: As with j &lt;= 8, but add (0x20 &lt;&lt; 56)
  115. to the value in the following j - 8
  116. bytes.
  117. Then comes the serial number, as a variant of
  118. uleb128, but better named ubeb128:
  119. Read bytes and shift the previous value left 7
  120. (multiply by 128). Add in the new byte, repeat
  121. until a byte has bit 7 set. The serial number
  122. is the computed value minus 128.
  123. (MMO3_MIDDLE)
  124. 0x20 - Traverse middle trie. (Read a new command byte
  125. and recurse.) Decrement character position.
  126. (MMO3_RIGHT)
  127. 0x10 - Traverse right trie. (Read a new command byte and
  128. recurse.)
  129. </pre></div>
  130. <p>Let&rsquo;s look again at the <code>lop_stab</code> for the trivial file
  131. (see <a href="File-layout.html#File-layout">File layout</a>).
  132. </p>
  133. <div class="example">
  134. <pre class="example"> 0x980b0000 - lop_stab for &quot;:Main&quot; = 0, serial 1.
  135. 0x203a4040
  136. 0x10404020
  137. 0x4d206120
  138. 0x69016e00
  139. 0x81000000
  140. </pre></div>
  141. <p>This forms the trivial trie (note that the path between &ldquo;:&rdquo; and
  142. &ldquo;M&rdquo; is redundant):
  143. </p>
  144. <div class="example">
  145. <pre class="example"> 203a &quot;:&quot;
  146. 40 /
  147. 40 /
  148. 10 \
  149. 40 /
  150. 40 /
  151. 204d &quot;M&quot;
  152. 2061 &quot;a&quot;
  153. 2069 &quot;i&quot;
  154. 016e &quot;n&quot; is the last character in a full symbol, and
  155. with a value represented in one byte.
  156. 00 The value is 0.
  157. 81 The serial number is 1.
  158. </pre></div>
  159. <hr>
  160. <div class="header">
  161. <p>
  162. Next: <a href="mmo-section-mapping.html#mmo-section-mapping" accesskey="n" rel="next">mmo section mapping</a>, Previous: <a href="File-layout.html#File-layout" accesskey="p" rel="prev">File layout</a>, Up: <a href="mmo.html#mmo" accesskey="u" rel="up">mmo</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="BFD-Index.html#BFD-Index" title="Index" rel="index">Index</a>]</p>
  163. </div>
  164. </body>
  165. </html>