aout.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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: aout</title>
  21. <meta name="description" content="Untitled Document: aout">
  22. <meta name="keywords" content="Untitled Document: aout">
  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="BFD-back-ends.html#BFD-back-ends" rel="up" title="BFD back ends">
  31. <link href="coff.html#coff" rel="next" title="coff">
  32. <link href="What-to-Put-Where.html#What-to-Put-Where" rel="prev" title="What to Put Where">
  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="aout"></a>
  64. <div class="header">
  65. <p>
  66. Next: <a href="coff.html#coff" accesskey="n" rel="next">coff</a>, Previous: <a href="What-to-Put-Where.html#What-to-Put-Where" accesskey="p" rel="prev">What to Put Where</a>, Up: <a href="BFD-back-ends.html#BFD-back-ends" accesskey="u" rel="up">BFD back ends</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="a_002eout-backends"></a>
  70. <h3 class="section">3.2 a.out backends</h3>
  71. <p><strong>Description</strong><br>
  72. BFD supports a number of different flavours of a.out format,
  73. though the major differences are only the sizes of the
  74. structures on disk, and the shape of the relocation
  75. information.
  76. </p>
  77. <p>The support is split into a basic support file <samp>aoutx.h</samp>
  78. and other files which derive functions from the base. One
  79. derivation file is <samp>aoutf1.h</samp> (for a.out flavour 1), and
  80. adds to the basic a.out functions support for sun3, sun4, 386
  81. and 29k a.out files, to create a target jump vector for a
  82. specific target.
  83. </p>
  84. <p>This information is further split out into more specific files
  85. for each machine, including <samp>sunos.c</samp> for sun3 and sun4,
  86. <samp>newsos3.c</samp> for the Sony NEWS, and <samp>demo64.c</samp> for a
  87. demonstration of a 64 bit a.out format.
  88. </p>
  89. <p>The base file <samp>aoutx.h</samp> defines general mechanisms for
  90. reading and writing records to and from disk and various
  91. other methods which BFD requires. It is included by
  92. <samp>aout32.c</samp> and <samp>aout64.c</samp> to form the names
  93. <code>aout_32_swap_exec_header_in</code>, <code>aout_64_swap_exec_header_in</code>, etc.
  94. </p>
  95. <p>As an example, this is what goes on to make the back end for a
  96. sun4, from <samp>aout32.c</samp>:
  97. </p>
  98. <div class="example">
  99. <pre class="example"> #define ARCH_SIZE 32
  100. #include &quot;aoutx.h&quot;
  101. </pre></div>
  102. <p>Which exports names:
  103. </p>
  104. <div class="example">
  105. <pre class="example"> ...
  106. aout_32_canonicalize_reloc
  107. aout_32_find_nearest_line
  108. aout_32_get_lineno
  109. aout_32_get_reloc_upper_bound
  110. ...
  111. </pre></div>
  112. <p>from <samp>sunos.c</samp>:
  113. </p>
  114. <div class="example">
  115. <pre class="example"> #define TARGET_NAME &quot;a.out-sunos-big&quot;
  116. #define VECNAME sparc_aout_sunos_be_vec
  117. #include &quot;aoutf1.h&quot;
  118. </pre></div>
  119. <p>requires all the names from <samp>aout32.c</samp>, and produces the jump vector
  120. </p>
  121. <div class="example">
  122. <pre class="example"> sparc_aout_sunos_be_vec
  123. </pre></div>
  124. <p>The file <samp>host-aout.c</samp> is a special case. It is for a large set
  125. of hosts that use &ldquo;more or less standard&rdquo; a.out files, and
  126. for which cross-debugging is not interesting. It uses the
  127. standard 32-bit a.out support routines, but determines the
  128. file offsets and addresses of the text, data, and BSS
  129. sections, the machine architecture and machine type, and the
  130. entry point address, in a host-dependent manner. Once these
  131. values have been determined, generic code is used to handle
  132. the object file.
  133. </p>
  134. <p>When porting it to run on a new system, you must supply:
  135. </p>
  136. <div class="example">
  137. <pre class="example"> HOST_PAGE_SIZE
  138. HOST_SEGMENT_SIZE
  139. HOST_MACHINE_ARCH (optional)
  140. HOST_MACHINE_MACHINE (optional)
  141. HOST_TEXT_START_ADDR
  142. HOST_STACK_END_ADDR
  143. </pre></div>
  144. <p>in the file <samp>../include/sys/h-<var>XXX</var>.h</samp> (for your host). These
  145. values, plus the structures and macros defined in <samp>a.out.h</samp> on
  146. your host system, will produce a BFD target that will access
  147. ordinary a.out files on your host. To configure a new machine
  148. to use <samp>host-aout.c</samp>, specify:
  149. </p>
  150. <div class="example">
  151. <pre class="example"> TDEFAULTS = -DDEFAULT_VECTOR=host_aout_big_vec
  152. TDEPFILES= host-aout.o trad-core.o
  153. </pre></div>
  154. <p>in the <samp>config/<var>XXX</var>.mt</samp> file, and modify <samp>configure.ac</samp>
  155. to use the
  156. <samp><var>XXX</var>.mt</samp> file (by setting &quot;<code>bfd_target=XXX</code>&quot;) when your
  157. configuration is selected.
  158. </p>
  159. <a name="Relocations-2"></a>
  160. <h4 class="subsection">3.2.1 Relocations</h4>
  161. <p><strong>Description</strong><br>
  162. The file <samp>aoutx.h</samp> provides for both the <em>standard</em>
  163. and <em>extended</em> forms of a.out relocation records.
  164. </p>
  165. <p>The standard records contain only an
  166. address, a symbol index, and a type field. The extended records
  167. (used on 29ks and sparcs) also have a full integer for an
  168. addend.
  169. </p>
  170. <a name="Internal-entry-points"></a>
  171. <h4 class="subsection">3.2.2 Internal entry points</h4>
  172. <p><strong>Description</strong><br>
  173. <samp>aoutx.h</samp> exports several routines for accessing the
  174. contents of an a.out file, which are gathered and exported in
  175. turn by various format specific files (eg sunos.c).
  176. </p>
  177. <a name="index-aout_005fsize_005fswap_005fexec_005fheader_005fin"></a>
  178. <a name="aout_005fsize_005fswap_005fexec_005fheader_005fin"></a>
  179. <h4 class="subsubsection">3.2.2.1 <code>aout_<var>size</var>_swap_exec_header_in</code></h4>
  180. <p><strong>Synopsis</strong>
  181. </p><div class="example">
  182. <pre class="example">void aout_<var>size</var>_swap_exec_header_in,
  183. (bfd *abfd,
  184. struct external_exec *bytes,
  185. struct internal_exec *execp);
  186. </pre></div>
  187. <p><strong>Description</strong><br>
  188. Swap the information in an executable header <var>raw_bytes</var> taken
  189. from a raw byte stream memory image into the internal exec header
  190. structure <var>execp</var>.
  191. </p>
  192. <a name="index-aout_005fsize_005fswap_005fexec_005fheader_005fout"></a>
  193. <a name="aout_005fsize_005fswap_005fexec_005fheader_005fout"></a>
  194. <h4 class="subsubsection">3.2.2.2 <code>aout_<var>size</var>_swap_exec_header_out</code></h4>
  195. <p><strong>Synopsis</strong>
  196. </p><div class="example">
  197. <pre class="example">void aout_<var>size</var>_swap_exec_header_out
  198. (bfd *abfd,
  199. struct internal_exec *execp,
  200. struct external_exec *raw_bytes);
  201. </pre></div>
  202. <p><strong>Description</strong><br>
  203. Swap the information in an internal exec header structure
  204. <var>execp</var> into the buffer <var>raw_bytes</var> ready for writing to disk.
  205. </p>
  206. <a name="index-aout_005fsize_005fsome_005faout_005fobject_005fp"></a>
  207. <a name="aout_005fsize_005fsome_005faout_005fobject_005fp"></a>
  208. <h4 class="subsubsection">3.2.2.3 <code>aout_<var>size</var>_some_aout_object_p</code></h4>
  209. <p><strong>Synopsis</strong>
  210. </p><div class="example">
  211. <pre class="example">const bfd_target *aout_<var>size</var>_some_aout_object_p
  212. (bfd *abfd,
  213. struct internal_exec *execp,
  214. const bfd_target *(*callback_to_real_object_p) (bfd *));
  215. </pre></div>
  216. <p><strong>Description</strong><br>
  217. Some a.out variant thinks that the file open in <var>abfd</var>
  218. checking is an a.out file. Do some more checking, and set up
  219. for access if it really is. Call back to the calling
  220. environment&rsquo;s &quot;finish up&quot; function just before returning, to
  221. handle any last-minute setup.
  222. </p>
  223. <a name="index-aout_005fsize_005fmkobject"></a>
  224. <a name="aout_005fsize_005fmkobject"></a>
  225. <h4 class="subsubsection">3.2.2.4 <code>aout_<var>size</var>_mkobject</code></h4>
  226. <p><strong>Synopsis</strong>
  227. </p><div class="example">
  228. <pre class="example">bfd_boolean aout_<var>size</var>_mkobject, (bfd *abfd);
  229. </pre></div>
  230. <p><strong>Description</strong><br>
  231. Initialize BFD <var>abfd</var> for use with a.out files.
  232. </p>
  233. <a name="index-aout_005fsize_005fmachine_005ftype"></a>
  234. <a name="aout_005fsize_005fmachine_005ftype"></a>
  235. <h4 class="subsubsection">3.2.2.5 <code>aout_<var>size</var>_machine_type</code></h4>
  236. <p><strong>Synopsis</strong>
  237. </p><div class="example">
  238. <pre class="example">enum machine_type aout_<var>size</var>_machine_type
  239. (enum bfd_architecture arch,
  240. unsigned long machine,
  241. bfd_boolean *unknown);
  242. </pre></div>
  243. <p><strong>Description</strong><br>
  244. Keep track of machine architecture and machine type for
  245. a.out&rsquo;s. Return the <code>machine_type</code> for a particular
  246. architecture and machine, or <code>M_UNKNOWN</code> if that exact architecture
  247. and machine can&rsquo;t be represented in a.out format.
  248. </p>
  249. <p>If the architecture is understood, machine type 0 (default)
  250. is always understood.
  251. </p>
  252. <a name="index-aout_005fsize_005fset_005farch_005fmach"></a>
  253. <a name="aout_005fsize_005fset_005farch_005fmach"></a>
  254. <h4 class="subsubsection">3.2.2.6 <code>aout_<var>size</var>_set_arch_mach</code></h4>
  255. <p><strong>Synopsis</strong>
  256. </p><div class="example">
  257. <pre class="example">bfd_boolean aout_<var>size</var>_set_arch_mach,
  258. (bfd *,
  259. enum bfd_architecture arch,
  260. unsigned long machine);
  261. </pre></div>
  262. <p><strong>Description</strong><br>
  263. Set the architecture and the machine of the BFD <var>abfd</var> to the
  264. values <var>arch</var> and <var>machine</var>. Verify that <var>abfd</var>&rsquo;s format
  265. can support the architecture required.
  266. </p>
  267. <a name="index-aout_005fsize_005fnew_005fsection_005fhook"></a>
  268. <a name="aout_005fsize_005fnew_005fsection_005fhook"></a>
  269. <h4 class="subsubsection">3.2.2.7 <code>aout_<var>size</var>_new_section_hook</code></h4>
  270. <p><strong>Synopsis</strong>
  271. </p><div class="example">
  272. <pre class="example">bfd_boolean aout_<var>size</var>_new_section_hook,
  273. (bfd *abfd,
  274. asection *newsect);
  275. </pre></div>
  276. <p><strong>Description</strong><br>
  277. Called by the BFD in response to a <code>bfd_make_section</code>
  278. request.
  279. </p>
  280. <hr>
  281. <div class="header">
  282. <p>
  283. Next: <a href="coff.html#coff" accesskey="n" rel="next">coff</a>, Previous: <a href="What-to-Put-Where.html#What-to-Put-Where" accesskey="p" rel="prev">What to Put Where</a>, Up: <a href="BFD-back-ends.html#BFD-back-ends" accesskey="u" rel="up">BFD back ends</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>
  284. </div>
  285. </body>
  286. </html>