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.

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