Internal.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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: Internal</title>
  21. <meta name="description" content="Untitled Document: Internal">
  22. <meta name="keywords" content="Untitled Document: Internal">
  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-front-end.html#BFD-front-end" rel="up" title="BFD front end">
  31. <link href="File-Caching.html#File-Caching" rel="next" title="File Caching">
  32. <link href="Opening-and-Closing.html#Opening-and-Closing" rel="prev" title="Opening and Closing">
  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="Internal"></a>
  64. <div class="header">
  65. <p>
  66. Next: <a href="File-Caching.html#File-Caching" accesskey="n" rel="next">File Caching</a>, Previous: <a href="Opening-and-Closing.html#Opening-and-Closing" accesskey="p" rel="prev">Opening and Closing</a>, Up: <a href="BFD-front-end.html#BFD-front-end" accesskey="u" rel="up">BFD front end</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="Implementation-details"></a>
  70. <h3 class="section">2.15 Implementation details</h3>
  71. <a name="Internal-functions"></a>
  72. <h4 class="subsection">2.15.1 Internal functions</h4>
  73. <p><strong>Description</strong><br>
  74. These routines are used within BFD.
  75. They are not intended for export, but are documented here for
  76. completeness.
  77. </p>
  78. <a name="index-bfd_005fwrite_005fbigendian_005f4byte_005fint"></a>
  79. <a name="bfd_005fwrite_005fbigendian_005f4byte_005fint"></a>
  80. <h4 class="subsubsection">2.15.1.1 <code>bfd_write_bigendian_4byte_int</code></h4>
  81. <p><strong>Synopsis</strong>
  82. </p><div class="example">
  83. <pre class="example">bfd_boolean bfd_write_bigendian_4byte_int (bfd *, unsigned int);
  84. </pre></div>
  85. <p><strong>Description</strong><br>
  86. Write a 4 byte integer <var>i</var> to the output BFD <var>abfd</var>, in big
  87. endian order regardless of what else is going on. This is useful in
  88. archives.
  89. </p>
  90. <a name="index-bfd_005fput_005fsize"></a>
  91. <a name="bfd_005fput_005fsize"></a>
  92. <h4 class="subsubsection">2.15.1.2 <code>bfd_put_size</code></h4>
  93. <a name="index-bfd_005fget_005fsize-1"></a>
  94. <a name="bfd_005fget_005fsize-1"></a>
  95. <h4 class="subsubsection">2.15.1.3 <code>bfd_get_size</code></h4>
  96. <p><strong>Description</strong><br>
  97. These macros as used for reading and writing raw data in
  98. sections; each access (except for bytes) is vectored through
  99. the target format of the BFD and mangled accordingly. The
  100. mangling performs any necessary endian translations and
  101. removes alignment restrictions. Note that types accepted and
  102. returned by these macros are identical so they can be swapped
  103. around in macros&mdash;for example, <samp>libaout.h</samp> defines <code>GET_WORD</code>
  104. to either <code>bfd_get_32</code> or <code>bfd_get_64</code>.
  105. </p>
  106. <p>In the put routines, <var>val</var> must be a <code>bfd_vma</code>. If we are on a
  107. system without prototypes, the caller is responsible for making
  108. sure that is true, with a cast if necessary. We don&rsquo;t cast
  109. them in the macro definitions because that would prevent <code>lint</code>
  110. or <code>gcc -Wall</code> from detecting sins such as passing a pointer.
  111. To detect calling these with less than a <code>bfd_vma</code>, use
  112. <code>gcc -Wconversion</code> on a host with 64 bit <code>bfd_vma</code>&rsquo;s.
  113. </p><div class="example">
  114. <pre class="example">
  115. /* Byte swapping macros for user section data. */
  116. #define bfd_put_8(abfd, val, ptr) \
  117. ((void) (*((unsigned char *) (ptr)) = (val) &amp; 0xff))
  118. #define bfd_put_signed_8 \
  119. bfd_put_8
  120. #define bfd_get_8(abfd, ptr) \
  121. (*(const unsigned char *) (ptr) &amp; 0xff)
  122. #define bfd_get_signed_8(abfd, ptr) \
  123. (((*(const unsigned char *) (ptr) &amp; 0xff) ^ 0x80) - 0x80)
  124. #define bfd_put_16(abfd, val, ptr) \
  125. BFD_SEND (abfd, bfd_putx16, ((val),(ptr)))
  126. #define bfd_put_signed_16 \
  127. bfd_put_16
  128. #define bfd_get_16(abfd, ptr) \
  129. BFD_SEND (abfd, bfd_getx16, (ptr))
  130. #define bfd_get_signed_16(abfd, ptr) \
  131. BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
  132. #define bfd_put_32(abfd, val, ptr) \
  133. BFD_SEND (abfd, bfd_putx32, ((val),(ptr)))
  134. #define bfd_put_signed_32 \
  135. bfd_put_32
  136. #define bfd_get_32(abfd, ptr) \
  137. BFD_SEND (abfd, bfd_getx32, (ptr))
  138. #define bfd_get_signed_32(abfd, ptr) \
  139. BFD_SEND (abfd, bfd_getx_signed_32, (ptr))
  140. #define bfd_put_64(abfd, val, ptr) \
  141. BFD_SEND (abfd, bfd_putx64, ((val), (ptr)))
  142. #define bfd_put_signed_64 \
  143. bfd_put_64
  144. #define bfd_get_64(abfd, ptr) \
  145. BFD_SEND (abfd, bfd_getx64, (ptr))
  146. #define bfd_get_signed_64(abfd, ptr) \
  147. BFD_SEND (abfd, bfd_getx_signed_64, (ptr))
  148. #define bfd_get(bits, abfd, ptr) \
  149. ((bits) == 8 ? (bfd_vma) bfd_get_8 (abfd, ptr) \
  150. : (bits) == 16 ? bfd_get_16 (abfd, ptr) \
  151. : (bits) == 32 ? bfd_get_32 (abfd, ptr) \
  152. : (bits) == 64 ? bfd_get_64 (abfd, ptr) \
  153. : (abort (), (bfd_vma) - 1))
  154. #define bfd_put(bits, abfd, val, ptr) \
  155. ((bits) == 8 ? bfd_put_8 (abfd, val, ptr) \
  156. : (bits) == 16 ? bfd_put_16 (abfd, val, ptr) \
  157. : (bits) == 32 ? bfd_put_32 (abfd, val, ptr) \
  158. : (bits) == 64 ? bfd_put_64 (abfd, val, ptr) \
  159. : (abort (), (void) 0))
  160. </pre></div>
  161. <a name="index-bfd_005fh_005fput_005fsize"></a>
  162. <a name="bfd_005fh_005fput_005fsize"></a>
  163. <h4 class="subsubsection">2.15.1.4 <code>bfd_h_put_size</code></h4>
  164. <p><strong>Description</strong><br>
  165. These macros have the same function as their <code>bfd_get_x</code>
  166. brethren, except that they are used for removing information
  167. for the header records of object files. Believe it or not,
  168. some object files keep their header records in big endian
  169. order and their data in little endian order.
  170. </p><div class="example">
  171. <pre class="example">
  172. /* Byte swapping macros for file header data. */
  173. #define bfd_h_put_8(abfd, val, ptr) \
  174. bfd_put_8 (abfd, val, ptr)
  175. #define bfd_h_put_signed_8(abfd, val, ptr) \
  176. bfd_put_8 (abfd, val, ptr)
  177. #define bfd_h_get_8(abfd, ptr) \
  178. bfd_get_8 (abfd, ptr)
  179. #define bfd_h_get_signed_8(abfd, ptr) \
  180. bfd_get_signed_8 (abfd, ptr)
  181. #define bfd_h_put_16(abfd, val, ptr) \
  182. BFD_SEND (abfd, bfd_h_putx16, (val, ptr))
  183. #define bfd_h_put_signed_16 \
  184. bfd_h_put_16
  185. #define bfd_h_get_16(abfd, ptr) \
  186. BFD_SEND (abfd, bfd_h_getx16, (ptr))
  187. #define bfd_h_get_signed_16(abfd, ptr) \
  188. BFD_SEND (abfd, bfd_h_getx_signed_16, (ptr))
  189. #define bfd_h_put_32(abfd, val, ptr) \
  190. BFD_SEND (abfd, bfd_h_putx32, (val, ptr))
  191. #define bfd_h_put_signed_32 \
  192. bfd_h_put_32
  193. #define bfd_h_get_32(abfd, ptr) \
  194. BFD_SEND (abfd, bfd_h_getx32, (ptr))
  195. #define bfd_h_get_signed_32(abfd, ptr) \
  196. BFD_SEND (abfd, bfd_h_getx_signed_32, (ptr))
  197. #define bfd_h_put_64(abfd, val, ptr) \
  198. BFD_SEND (abfd, bfd_h_putx64, (val, ptr))
  199. #define bfd_h_put_signed_64 \
  200. bfd_h_put_64
  201. #define bfd_h_get_64(abfd, ptr) \
  202. BFD_SEND (abfd, bfd_h_getx64, (ptr))
  203. #define bfd_h_get_signed_64(abfd, ptr) \
  204. BFD_SEND (abfd, bfd_h_getx_signed_64, (ptr))
  205. /* Aliases for the above, which should eventually go away. */
  206. #define H_PUT_64 bfd_h_put_64
  207. #define H_PUT_32 bfd_h_put_32
  208. #define H_PUT_16 bfd_h_put_16
  209. #define H_PUT_8 bfd_h_put_8
  210. #define H_PUT_S64 bfd_h_put_signed_64
  211. #define H_PUT_S32 bfd_h_put_signed_32
  212. #define H_PUT_S16 bfd_h_put_signed_16
  213. #define H_PUT_S8 bfd_h_put_signed_8
  214. #define H_GET_64 bfd_h_get_64
  215. #define H_GET_32 bfd_h_get_32
  216. #define H_GET_16 bfd_h_get_16
  217. #define H_GET_8 bfd_h_get_8
  218. #define H_GET_S64 bfd_h_get_signed_64
  219. #define H_GET_S32 bfd_h_get_signed_32
  220. #define H_GET_S16 bfd_h_get_signed_16
  221. #define H_GET_S8 bfd_h_get_signed_8
  222. </pre></div>
  223. <a name="index-bfd_005flog2"></a>
  224. <a name="bfd_005flog2"></a>
  225. <h4 class="subsubsection">2.15.1.5 <code>bfd_log2</code></h4>
  226. <p><strong>Synopsis</strong>
  227. </p><div class="example">
  228. <pre class="example">unsigned int bfd_log2 (bfd_vma x);
  229. </pre></div>
  230. <p><strong>Description</strong><br>
  231. Return the log base 2 of the value supplied, rounded up. E.g., an
  232. <var>x</var> of 1025 returns 11. A <var>x</var> of 0 returns 0.
  233. </p>
  234. <hr>
  235. <div class="header">
  236. <p>
  237. Next: <a href="File-Caching.html#File-Caching" accesskey="n" rel="next">File Caching</a>, Previous: <a href="Opening-and-Closing.html#Opening-and-Closing" accesskey="p" rel="prev">Opening and Closing</a>, Up: <a href="BFD-front-end.html#BFD-front-end" accesskey="u" rel="up">BFD front end</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>
  238. </div>
  239. </body>
  240. </html>