Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

250 lines
11KB

  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>File layout (Untitled Document)</title>
  22. <meta name="description" content="File layout (Untitled Document)">
  23. <meta name="keywords" content="File layout (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="Symbol_002dtable.html#Symbol_002dtable" rel="next" title="Symbol-table">
  32. <link href="mmo.html#mmo" rel="prev" title="mmo">
  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="File-layout"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Symbol_002dtable.html#Symbol_002dtable" accesskey="n" rel="next">Symbol-table</a>, Previous: <a href="mmo.html#mmo" accesskey="p" rel="prev">mmo</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="File-layout-2"></a>
  69. <h4 class="subsection">3.5.1 File layout</h4>
  70. <p>The mmo file contents is not partitioned into named sections as
  71. with e.g. ELF. Memory areas is formed by specifying the
  72. location of the data that follows. Only the memory area
  73. &lsquo;<samp>0x0000&hellip;00</samp>&rsquo; to &lsquo;<samp>0x01ff&hellip;ff</samp>&rsquo; is executable, so
  74. it is used for code (and constants) and the area
  75. &lsquo;<samp>0x2000&hellip;00</samp>&rsquo; to &lsquo;<samp>0x20ff&hellip;ff</samp>&rsquo; is used for
  76. writable data. See <a href="mmo-section-mapping.html#mmo-section-mapping">mmo section mapping</a>.
  77. </p>
  78. <p>There is provision for specifying &ldquo;special data&rdquo; of 65536
  79. different types. We use type 80 (decimal), arbitrarily chosen the
  80. same as the ELF <code>e_machine</code> number for MMIX, filling it with
  81. section information normally found in ELF objects. See <a href="mmo-section-mapping.html#mmo-section-mapping">mmo section mapping</a>.
  82. </p>
  83. <p>Contents is entered as 32-bit words, xor:ed over previous
  84. contents, always zero-initialized. A word that starts with the
  85. byte &lsquo;<samp>0x98</samp>&rsquo; forms a command called a &lsquo;<samp>lopcode</samp>&rsquo;, where
  86. the next byte distinguished between the thirteen lopcodes. The
  87. two remaining bytes, called the &lsquo;<samp>Y</samp>&rsquo; and &lsquo;<samp>Z</samp>&rsquo; fields, or
  88. the &lsquo;<samp>YZ</samp>&rsquo; field (a 16-bit big-endian number), are used for
  89. various purposes different for each lopcode. As documented in
  90. <a href="http://mmix.cs.hm.edu/doc/mmixal.pdf">http://mmix.cs.hm.edu/doc/mmixal.pdf</a>,
  91. the lopcodes are:
  92. </p>
  93. <dl compact="compact">
  94. <dt><code>lop_quote</code></dt>
  95. <dd><p>0x98000001. The next word is contents, regardless of whether it
  96. starts with 0x98 or not.
  97. </p>
  98. </dd>
  99. <dt><code>lop_loc</code></dt>
  100. <dd><p>0x9801YYZZ, where &lsquo;<samp>Z</samp>&rsquo; is 1 or 2. This is a location
  101. directive, setting the location for the next data to the next
  102. 32-bit word (for <em>Z = 1</em>) or 64-bit word (for <em>Z = 2</em>),
  103. plus <em>Y * 2^56</em>. Normally &lsquo;<samp>Y</samp>&rsquo; is 0 for the text segment
  104. and 2 for the data segment. Beware that the low bits of non-
  105. tetrabyte-aligned values are silently discarded when being
  106. automatically incremented and when storing contents (in contrast
  107. to e.g. its use as current location when followed by lop_fixo
  108. et al before the next possibly-quoted tetrabyte contents).
  109. </p>
  110. </dd>
  111. <dt><code>lop_skip</code></dt>
  112. <dd><p>0x9802YYZZ. Increase the current location by &lsquo;<samp>YZ</samp>&rsquo; bytes.
  113. </p>
  114. </dd>
  115. <dt><code>lop_fixo</code></dt>
  116. <dd><p>0x9803YYZZ, where &lsquo;<samp>Z</samp>&rsquo; is 1 or 2. Store the current location
  117. as 64 bits into the location pointed to by the next 32-bit
  118. (<em>Z = 1</em>) or 64-bit (<em>Z = 2</em>) word, plus <em>Y *
  119. 2^56</em>.
  120. </p>
  121. </dd>
  122. <dt><code>lop_fixr</code></dt>
  123. <dd><p>0x9804YYZZ. &lsquo;<samp>YZ</samp>&rsquo; is stored into the current location plus
  124. <em>2 - 4 * YZ</em>.
  125. </p>
  126. </dd>
  127. <dt><code>lop_fixrx</code></dt>
  128. <dd><p>0x980500ZZ. &lsquo;<samp>Z</samp>&rsquo; is 16 or 24. A value &lsquo;<samp>L</samp>&rsquo; derived from
  129. the following 32-bit word are used in a manner similar to
  130. &lsquo;<samp>YZ</samp>&rsquo; in lop_fixr: it is xor:ed into the current location
  131. minus <em>4 * L</em>. The first byte of the word is 0 or 1. If it
  132. is 1, then <em>L = (<var>lowest 24 bits of word</var>) - 2^Z</em>, if 0,
  133. then <em>L = (<var>lowest 24 bits of word</var>)</em>.
  134. </p>
  135. </dd>
  136. <dt><code>lop_file</code></dt>
  137. <dd><p>0x9806YYZZ. &lsquo;<samp>Y</samp>&rsquo; is the file number, &lsquo;<samp>Z</samp>&rsquo; is count of
  138. 32-bit words. Set the file number to &lsquo;<samp>Y</samp>&rsquo; and the line
  139. counter to 0. The next <em>Z * 4</em> bytes contain the file name,
  140. padded with zeros if the count is not a multiple of four. The
  141. same &lsquo;<samp>Y</samp>&rsquo; may occur multiple times, but &lsquo;<samp>Z</samp>&rsquo; must be 0 for
  142. all but the first occurrence.
  143. </p>
  144. </dd>
  145. <dt><code>lop_line</code></dt>
  146. <dd><p>0x9807YYZZ. &lsquo;<samp>YZ</samp>&rsquo; is the line number. Together with
  147. lop_file, it forms the source location for the next 32-bit word.
  148. Note that for each non-lopcode 32-bit word, line numbers are
  149. assumed incremented by one.
  150. </p>
  151. </dd>
  152. <dt><code>lop_spec</code></dt>
  153. <dd><p>0x9808YYZZ. &lsquo;<samp>YZ</samp>&rsquo; is the type number. Data until the next
  154. lopcode other than lop_quote forms special data of type &lsquo;<samp>YZ</samp>&rsquo;.
  155. See <a href="mmo-section-mapping.html#mmo-section-mapping">mmo section mapping</a>.
  156. </p>
  157. <p>Other types than 80, (or type 80 with a content that does not
  158. parse) is stored in sections named <code>.MMIX.spec_data.<var>n</var></code>
  159. where <var>n</var> is the &lsquo;<samp>YZ</samp>&rsquo;-type. The flags for such a
  160. sections say not to allocate or load the data. The vma is 0.
  161. Contents of multiple occurrences of special data <var>n</var> is
  162. concatenated to the data of the previous lop_spec <var>n</var>s. The
  163. location in data or code at which the lop_spec occurred is lost.
  164. </p>
  165. </dd>
  166. <dt><code>lop_pre</code></dt>
  167. <dd><p>0x980901ZZ. The first lopcode in a file. The &lsquo;<samp>Z</samp>&rsquo; field forms the
  168. length of header information in 32-bit words, where the first word
  169. tells the time in seconds since &lsquo;<samp>00:00:00 GMT Jan 1 1970</samp>&rsquo;.
  170. </p>
  171. </dd>
  172. <dt><code>lop_post</code></dt>
  173. <dd><p>0x980a00ZZ. <em>Z &gt; 32</em>. This lopcode follows after all
  174. content-generating lopcodes in a program. The &lsquo;<samp>Z</samp>&rsquo; field
  175. denotes the value of &lsquo;<samp>rG</samp>&rsquo; at the beginning of the program.
  176. The following <em>256 - Z</em> big-endian 64-bit words are loaded
  177. into global registers &lsquo;<samp>$G</samp>&rsquo; &hellip; &lsquo;<samp>$255</samp>&rsquo;.
  178. </p>
  179. </dd>
  180. <dt><code>lop_stab</code></dt>
  181. <dd><p>0x980b0000. The next-to-last lopcode in a program. Must follow
  182. immediately after the lop_post lopcode and its data. After this
  183. lopcode follows all symbols in a compressed format
  184. (see <a href="Symbol_002dtable.html#Symbol_002dtable">Symbol-table</a>).
  185. </p>
  186. </dd>
  187. <dt><code>lop_end</code></dt>
  188. <dd><p>0x980cYYZZ. The last lopcode in a program. It must follow the
  189. lop_stab lopcode and its data. The &lsquo;<samp>YZ</samp>&rsquo; field contains the
  190. number of 32-bit words of symbol table information after the
  191. preceding lop_stab lopcode.
  192. </p></dd>
  193. </dl>
  194. <p>Note that the lopcode &quot;fixups&quot;; <code>lop_fixr</code>, <code>lop_fixrx</code> and
  195. <code>lop_fixo</code> are not generated by BFD, but are handled. They are
  196. generated by <code>mmixal</code>.
  197. </p>
  198. <p>This trivial one-label, one-instruction file:
  199. </p>
  200. <div class="example">
  201. <pre class="example"> :Main TRAP 1,2,3
  202. </pre></div>
  203. <p>can be represented this way in mmo:
  204. </p>
  205. <div class="example">
  206. <pre class="example"> 0x98090101 - lop_pre, one 32-bit word with timestamp.
  207. &lt;timestamp&gt;
  208. 0x98010002 - lop_loc, text segment, using a 64-bit address.
  209. Note that mmixal does not emit this for the file above.
  210. 0x00000000 - Address, high 32 bits.
  211. 0x00000000 - Address, low 32 bits.
  212. 0x98060002 - lop_file, 2 32-bit words for file-name.
  213. 0x74657374 - &quot;test&quot;
  214. 0x2e730000 - &quot;.s\0\0&quot;
  215. 0x98070001 - lop_line, line 1.
  216. 0x00010203 - TRAP 1,2,3
  217. 0x980a00ff - lop_post, setting $255 to 0.
  218. 0x00000000
  219. 0x00000000
  220. 0x980b0000 - lop_stab for &quot;:Main&quot; = 0, serial 1.
  221. 0x203a4040 See <a href="Symbol_002dtable.html#Symbol_002dtable">Symbol-table</a>.
  222. 0x10404020
  223. 0x4d206120
  224. 0x69016e00
  225. 0x81000000
  226. 0x980c0005 - lop_end; symbol table contained five 32-bit words.
  227. </pre></div>
  228. <hr>
  229. <div class="header">
  230. <p>
  231. Next: <a href="Symbol_002dtable.html#Symbol_002dtable" accesskey="n" rel="next">Symbol-table</a>, Previous: <a href="mmo.html#mmo" accesskey="p" rel="prev">mmo</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>
  232. </div>
  233. </body>
  234. </html>