File-layout.html 11 KB

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