Opening-and-Closing.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  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: Opening and Closing</title>
  21. <meta name="description" content="Untitled Document: Opening and Closing">
  22. <meta name="keywords" content="Untitled Document: Opening and Closing">
  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="Internal.html#Internal" rel="next" title="Internal">
  32. <link href="Architectures.html#Architectures" rel="prev" title="Architectures">
  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="Opening-and-Closing"></a>
  64. <div class="header">
  65. <p>
  66. Next: <a href="Internal.html#Internal" accesskey="n" rel="next">Internal</a>, Previous: <a href="Architectures.html#Architectures" accesskey="p" rel="prev">Architectures</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. <div class="example">
  70. <pre class="example">/* Set to N to open the next N BFDs using an alternate id space. */
  71. extern unsigned int bfd_use_reserved_id;
  72. </pre></div>
  73. <a name="Opening-and-closing-BFDs"></a>
  74. <h3 class="section">2.14 Opening and closing BFDs</h3>
  75. <a name="Functions-for-opening-and-closing"></a>
  76. <h4 class="subsection">2.14.1 Functions for opening and closing</h4>
  77. <a name="index-bfd_005ffopen"></a>
  78. <a name="bfd_005ffopen"></a>
  79. <h4 class="subsubsection">2.14.1.1 <code>bfd_fopen</code></h4>
  80. <p><strong>Synopsis</strong>
  81. </p><div class="example">
  82. <pre class="example">bfd *bfd_fopen (const char *filename, const char *target,
  83. const char *mode, int fd);
  84. </pre></div>
  85. <p><strong>Description</strong><br>
  86. Open the file <var>filename</var> with the target <var>target</var>.
  87. Return a pointer to the created BFD. If <var>fd</var> is not -1,
  88. then <code>fdopen</code> is used to open the file; otherwise, <code>fopen</code>
  89. is used. <var>mode</var> is passed directly to <code>fopen</code> or
  90. <code>fdopen</code>.
  91. </p>
  92. <p>Calls <code>bfd_find_target</code>, so <var>target</var> is interpreted as by
  93. that function.
  94. </p>
  95. <p>The new BFD is marked as cacheable iff <var>fd</var> is -1.
  96. </p>
  97. <p>If <code>NULL</code> is returned then an error has occured. Possible errors
  98. are <code>bfd_error_no_memory</code>, <code>bfd_error_invalid_target</code> or
  99. <code>system_call</code> error.
  100. </p>
  101. <p>On error, <var>fd</var> is always closed.
  102. </p>
  103. <p>A copy of the <var>filename</var> argument is stored in the newly created
  104. BFD. It can be accessed via the bfd_get_filename() macro.
  105. </p>
  106. <a name="index-bfd_005fopenr"></a>
  107. <a name="bfd_005fopenr"></a>
  108. <h4 class="subsubsection">2.14.1.2 <code>bfd_openr</code></h4>
  109. <p><strong>Synopsis</strong>
  110. </p><div class="example">
  111. <pre class="example">bfd *bfd_openr (const char *filename, const char *target);
  112. </pre></div>
  113. <p><strong>Description</strong><br>
  114. Open the file <var>filename</var> (using <code>fopen</code>) with the target
  115. <var>target</var>. Return a pointer to the created BFD.
  116. </p>
  117. <p>Calls <code>bfd_find_target</code>, so <var>target</var> is interpreted as by
  118. that function.
  119. </p>
  120. <p>If <code>NULL</code> is returned then an error has occured. Possible errors
  121. are <code>bfd_error_no_memory</code>, <code>bfd_error_invalid_target</code> or
  122. <code>system_call</code> error.
  123. </p>
  124. <p>A copy of the <var>filename</var> argument is stored in the newly created
  125. BFD. It can be accessed via the bfd_get_filename() macro.
  126. </p>
  127. <a name="index-bfd_005ffdopenr"></a>
  128. <a name="bfd_005ffdopenr"></a>
  129. <h4 class="subsubsection">2.14.1.3 <code>bfd_fdopenr</code></h4>
  130. <p><strong>Synopsis</strong>
  131. </p><div class="example">
  132. <pre class="example">bfd *bfd_fdopenr (const char *filename, const char *target, int fd);
  133. </pre></div>
  134. <p><strong>Description</strong><br>
  135. <code>bfd_fdopenr</code> is to <code>bfd_fopenr</code> much like <code>fdopen</code> is to
  136. <code>fopen</code>. It opens a BFD on a file already described by the
  137. <var>fd</var> supplied.
  138. </p>
  139. <p>When the file is later <code>bfd_close</code>d, the file descriptor will
  140. be closed. If the caller desires that this file descriptor be
  141. cached by BFD (opened as needed, closed as needed to free
  142. descriptors for other opens), with the supplied <var>fd</var> used as
  143. an initial file descriptor (but subject to closure at any time),
  144. call bfd_set_cacheable(bfd, 1) on the returned BFD. The default
  145. is to assume no caching; the file descriptor will remain open
  146. until <code>bfd_close</code>, and will not be affected by BFD operations
  147. on other files.
  148. </p>
  149. <p>Possible errors are <code>bfd_error_no_memory</code>,
  150. <code>bfd_error_invalid_target</code> and <code>bfd_error_system_call</code>.
  151. </p>
  152. <p>On error, <var>fd</var> is closed.
  153. </p>
  154. <p>A copy of the <var>filename</var> argument is stored in the newly created
  155. BFD. It can be accessed via the bfd_get_filename() macro.
  156. </p>
  157. <a name="index-bfd_005fopenstreamr"></a>
  158. <a name="bfd_005fopenstreamr"></a>
  159. <h4 class="subsubsection">2.14.1.4 <code>bfd_openstreamr</code></h4>
  160. <p><strong>Synopsis</strong>
  161. </p><div class="example">
  162. <pre class="example">bfd *bfd_openstreamr (const char * filename, const char * target, void * stream);
  163. </pre></div>
  164. <p><strong>Description</strong><br>
  165. Open a BFD for read access on an existing stdio stream. When
  166. the BFD is passed to <code>bfd_close</code>, the stream will be closed.
  167. </p>
  168. <p>A copy of the <var>filename</var> argument is stored in the newly created
  169. BFD. It can be accessed via the bfd_get_filename() macro.
  170. </p>
  171. <a name="index-bfd_005fopenr_005fiovec"></a>
  172. <a name="bfd_005fopenr_005fiovec"></a>
  173. <h4 class="subsubsection">2.14.1.5 <code>bfd_openr_iovec</code></h4>
  174. <p><strong>Synopsis</strong>
  175. </p><div class="example">
  176. <pre class="example">bfd *bfd_openr_iovec (const char *filename, const char *target,
  177. void *(*open_func) (struct bfd *nbfd,
  178. void *open_closure),
  179. void *open_closure,
  180. file_ptr (*pread_func) (struct bfd *nbfd,
  181. void *stream,
  182. void *buf,
  183. file_ptr nbytes,
  184. file_ptr offset),
  185. int (*close_func) (struct bfd *nbfd,
  186. void *stream),
  187. int (*stat_func) (struct bfd *abfd,
  188. void *stream,
  189. struct stat *sb));
  190. </pre></div>
  191. <p><strong>Description</strong><br>
  192. Create and return a BFD backed by a read-only <var>stream</var>.
  193. The <var>stream</var> is created using <var>open_func</var>, accessed using
  194. <var>pread_func</var> and destroyed using <var>close_func</var>.
  195. </p>
  196. <p>Calls <code>bfd_find_target</code>, so <var>target</var> is interpreted as by
  197. that function.
  198. </p>
  199. <p>Calls <var>open_func</var> (which can call <code>bfd_zalloc</code> and
  200. <code>bfd_get_filename</code>) to obtain the read-only stream backing
  201. the BFD. <var>open_func</var> either succeeds returning the
  202. non-<code>NULL</code> <var>stream</var>, or fails returning <code>NULL</code>
  203. (setting <code>bfd_error</code>).
  204. </p>
  205. <p>Calls <var>pread_func</var> to request <var>nbytes</var> of data from
  206. <var>stream</var> starting at <var>offset</var> (e.g., via a call to
  207. <code>bfd_read</code>). <var>pread_func</var> either succeeds returning the
  208. number of bytes read (which can be less than <var>nbytes</var> when
  209. end-of-file), or fails returning -1 (setting <code>bfd_error</code>).
  210. </p>
  211. <p>Calls <var>close_func</var> when the BFD is later closed using
  212. <code>bfd_close</code>. <var>close_func</var> either succeeds returning 0, or
  213. fails returning -1 (setting <code>bfd_error</code>).
  214. </p>
  215. <p>Calls <var>stat_func</var> to fill in a stat structure for bfd_stat,
  216. bfd_get_size, and bfd_get_mtime calls. <var>stat_func</var> returns 0
  217. on success, or returns -1 on failure (setting <code>bfd_error</code>).
  218. </p>
  219. <p>If <code>bfd_openr_iovec</code> returns <code>NULL</code> then an error has
  220. occurred. Possible errors are <code>bfd_error_no_memory</code>,
  221. <code>bfd_error_invalid_target</code> and <code>bfd_error_system_call</code>.
  222. </p>
  223. <p>A copy of the <var>filename</var> argument is stored in the newly created
  224. BFD. It can be accessed via the bfd_get_filename() macro.
  225. </p>
  226. <a name="index-bfd_005fopenw"></a>
  227. <a name="bfd_005fopenw"></a>
  228. <h4 class="subsubsection">2.14.1.6 <code>bfd_openw</code></h4>
  229. <p><strong>Synopsis</strong>
  230. </p><div class="example">
  231. <pre class="example">bfd *bfd_openw (const char *filename, const char *target);
  232. </pre></div>
  233. <p><strong>Description</strong><br>
  234. Create a BFD, associated with file <var>filename</var>, using the
  235. file format <var>target</var>, and return a pointer to it.
  236. </p>
  237. <p>Possible errors are <code>bfd_error_system_call</code>, <code>bfd_error_no_memory</code>,
  238. <code>bfd_error_invalid_target</code>.
  239. </p>
  240. <p>A copy of the <var>filename</var> argument is stored in the newly created
  241. BFD. It can be accessed via the bfd_get_filename() macro.
  242. </p>
  243. <a name="index-bfd_005fclose"></a>
  244. <a name="bfd_005fclose"></a>
  245. <h4 class="subsubsection">2.14.1.7 <code>bfd_close</code></h4>
  246. <p><strong>Synopsis</strong>
  247. </p><div class="example">
  248. <pre class="example">bfd_boolean bfd_close (bfd *abfd);
  249. </pre></div>
  250. <p><strong>Description</strong><br>
  251. Close a BFD. If the BFD was open for writing, then pending
  252. operations are completed and the file written out and closed.
  253. If the created file is executable, then <code>chmod</code> is called
  254. to mark it as such.
  255. </p>
  256. <p>All memory attached to the BFD is released.
  257. </p>
  258. <p>The file descriptor associated with the BFD is closed (even
  259. if it was passed in to BFD by <code>bfd_fdopenr</code>).
  260. </p>
  261. <p><strong>Returns</strong><br>
  262. <code>TRUE</code> is returned if all is ok, otherwise <code>FALSE</code>.
  263. </p>
  264. <a name="index-bfd_005fclose_005fall_005fdone"></a>
  265. <a name="bfd_005fclose_005fall_005fdone"></a>
  266. <h4 class="subsubsection">2.14.1.8 <code>bfd_close_all_done</code></h4>
  267. <p><strong>Synopsis</strong>
  268. </p><div class="example">
  269. <pre class="example">bfd_boolean bfd_close_all_done (bfd *);
  270. </pre></div>
  271. <p><strong>Description</strong><br>
  272. Close a BFD. Differs from <code>bfd_close</code> since it does not
  273. complete any pending operations. This routine would be used
  274. if the application had just used BFD for swapping and didn&rsquo;t
  275. want to use any of the writing code.
  276. </p>
  277. <p>If the created file is executable, then <code>chmod</code> is called
  278. to mark it as such.
  279. </p>
  280. <p>All memory attached to the BFD is released.
  281. </p>
  282. <p><strong>Returns</strong><br>
  283. <code>TRUE</code> is returned if all is ok, otherwise <code>FALSE</code>.
  284. </p>
  285. <a name="index-bfd_005fcreate"></a>
  286. <a name="bfd_005fcreate"></a>
  287. <h4 class="subsubsection">2.14.1.9 <code>bfd_create</code></h4>
  288. <p><strong>Synopsis</strong>
  289. </p><div class="example">
  290. <pre class="example">bfd *bfd_create (const char *filename, bfd *templ);
  291. </pre></div>
  292. <p><strong>Description</strong><br>
  293. Create a new BFD in the manner of <code>bfd_openw</code>, but without
  294. opening a file. The new BFD takes the target from the target
  295. used by <var>templ</var>. The format is always set to <code>bfd_object</code>.
  296. </p>
  297. <p>A copy of the <var>filename</var> argument is stored in the newly created
  298. BFD. It can be accessed via the bfd_get_filename() macro.
  299. </p>
  300. <a name="index-bfd_005fmake_005fwritable"></a>
  301. <a name="bfd_005fmake_005fwritable"></a>
  302. <h4 class="subsubsection">2.14.1.10 <code>bfd_make_writable</code></h4>
  303. <p><strong>Synopsis</strong>
  304. </p><div class="example">
  305. <pre class="example">bfd_boolean bfd_make_writable (bfd *abfd);
  306. </pre></div>
  307. <p><strong>Description</strong><br>
  308. Takes a BFD as created by <code>bfd_create</code> and converts it
  309. into one like as returned by <code>bfd_openw</code>. It does this
  310. by converting the BFD to BFD_IN_MEMORY. It&rsquo;s assumed that
  311. you will call <code>bfd_make_readable</code> on this bfd later.
  312. </p>
  313. <p><strong>Returns</strong><br>
  314. <code>TRUE</code> is returned if all is ok, otherwise <code>FALSE</code>.
  315. </p>
  316. <a name="index-bfd_005fmake_005freadable"></a>
  317. <a name="bfd_005fmake_005freadable"></a>
  318. <h4 class="subsubsection">2.14.1.11 <code>bfd_make_readable</code></h4>
  319. <p><strong>Synopsis</strong>
  320. </p><div class="example">
  321. <pre class="example">bfd_boolean bfd_make_readable (bfd *abfd);
  322. </pre></div>
  323. <p><strong>Description</strong><br>
  324. Takes a BFD as created by <code>bfd_create</code> and
  325. <code>bfd_make_writable</code> and converts it into one like as
  326. returned by <code>bfd_openr</code>. It does this by writing the
  327. contents out to the memory buffer, then reversing the
  328. direction.
  329. </p>
  330. <p><strong>Returns</strong><br>
  331. <code>TRUE</code> is returned if all is ok, otherwise <code>FALSE</code>.
  332. </p>
  333. <a name="index-bfd_005falloc"></a>
  334. <a name="bfd_005falloc"></a>
  335. <h4 class="subsubsection">2.14.1.12 <code>bfd_alloc</code></h4>
  336. <p><strong>Synopsis</strong>
  337. </p><div class="example">
  338. <pre class="example">void *bfd_alloc (bfd *abfd, bfd_size_type wanted);
  339. </pre></div>
  340. <p><strong>Description</strong><br>
  341. Allocate a block of <var>wanted</var> bytes of memory attached to
  342. <code>abfd</code> and return a pointer to it.
  343. </p>
  344. <a name="index-bfd_005falloc2"></a>
  345. <a name="bfd_005falloc2"></a>
  346. <h4 class="subsubsection">2.14.1.13 <code>bfd_alloc2</code></h4>
  347. <p><strong>Synopsis</strong>
  348. </p><div class="example">
  349. <pre class="example">void *bfd_alloc2 (bfd *abfd, bfd_size_type nmemb, bfd_size_type size);
  350. </pre></div>
  351. <p><strong>Description</strong><br>
  352. Allocate a block of <var>nmemb</var> elements of <var>size</var> bytes each
  353. of memory attached to <code>abfd</code> and return a pointer to it.
  354. </p>
  355. <a name="index-bfd_005fzalloc"></a>
  356. <a name="bfd_005fzalloc"></a>
  357. <h4 class="subsubsection">2.14.1.14 <code>bfd_zalloc</code></h4>
  358. <p><strong>Synopsis</strong>
  359. </p><div class="example">
  360. <pre class="example">void *bfd_zalloc (bfd *abfd, bfd_size_type wanted);
  361. </pre></div>
  362. <p><strong>Description</strong><br>
  363. Allocate a block of <var>wanted</var> bytes of zeroed memory
  364. attached to <code>abfd</code> and return a pointer to it.
  365. </p>
  366. <a name="index-bfd_005fzalloc2"></a>
  367. <a name="bfd_005fzalloc2"></a>
  368. <h4 class="subsubsection">2.14.1.15 <code>bfd_zalloc2</code></h4>
  369. <p><strong>Synopsis</strong>
  370. </p><div class="example">
  371. <pre class="example">void *bfd_zalloc2 (bfd *abfd, bfd_size_type nmemb, bfd_size_type size);
  372. </pre></div>
  373. <p><strong>Description</strong><br>
  374. Allocate a block of <var>nmemb</var> elements of <var>size</var> bytes each
  375. of zeroed memory attached to <code>abfd</code> and return a pointer to it.
  376. </p>
  377. <a name="index-bfd_005fcalc_005fgnu_005fdebuglink_005fcrc32"></a>
  378. <a name="bfd_005fcalc_005fgnu_005fdebuglink_005fcrc32"></a>
  379. <h4 class="subsubsection">2.14.1.16 <code>bfd_calc_gnu_debuglink_crc32</code></h4>
  380. <p><strong>Synopsis</strong>
  381. </p><div class="example">
  382. <pre class="example">unsigned long bfd_calc_gnu_debuglink_crc32
  383. (unsigned long crc, const unsigned char *buf, bfd_size_type len);
  384. </pre></div>
  385. <p><strong>Description</strong><br>
  386. Computes a CRC value as used in the .gnu_debuglink section.
  387. Advances the previously computed <var>crc</var> value by computing
  388. and adding in the crc32 for <var>len</var> bytes of <var>buf</var>.
  389. </p>
  390. <p><strong>Returns</strong><br>
  391. Return the updated CRC32 value.
  392. </p>
  393. <a name="index-bfd_005fget_005fdebug_005flink_005finfo"></a>
  394. <a name="bfd_005fget_005fdebug_005flink_005finfo"></a>
  395. <h4 class="subsubsection">2.14.1.17 <code>bfd_get_debug_link_info</code></h4>
  396. <p><strong>Synopsis</strong>
  397. </p><div class="example">
  398. <pre class="example">char *bfd_get_debug_link_info (bfd *abfd, unsigned long *crc32_out);
  399. </pre></div>
  400. <p><strong>Description</strong><br>
  401. Fetch the filename and CRC32 value for any separate debuginfo
  402. associated with <var>abfd</var>. Return NULL if no such info found,
  403. otherwise return filename and update <var>crc32_out</var>. The
  404. returned filename is allocated with <code>malloc</code>; freeing it
  405. is the responsibility of the caller.
  406. </p>
  407. <a name="index-bfd_005fget_005falt_005fdebug_005flink_005finfo"></a>
  408. <a name="bfd_005fget_005falt_005fdebug_005flink_005finfo"></a>
  409. <h4 class="subsubsection">2.14.1.18 <code>bfd_get_alt_debug_link_info</code></h4>
  410. <p><strong>Synopsis</strong>
  411. </p><div class="example">
  412. <pre class="example">char *bfd_get_alt_debug_link_info (bfd * abfd,
  413. bfd_size_type *buildid_len,
  414. bfd_byte **buildid_out);
  415. </pre></div>
  416. <p><strong>Description</strong><br>
  417. Fetch the filename and BuildID value for any alternate debuginfo
  418. associated with <var>abfd</var>. Return NULL if no such info found,
  419. otherwise return filename and update <var>buildid_len</var> and
  420. <var>buildid_out</var>. The returned filename and build_id are
  421. allocated with <code>malloc</code>; freeing them is the
  422. responsibility of the caller.
  423. </p>
  424. <a name="index-separate_005fdebug_005ffile_005fexists"></a>
  425. <a name="separate_005fdebug_005ffile_005fexists"></a>
  426. <h4 class="subsubsection">2.14.1.19 <code>separate_debug_file_exists</code></h4>
  427. <p><strong>Synopsis</strong>
  428. </p><div class="example">
  429. <pre class="example">bfd_boolean separate_debug_file_exists
  430. (char *name, unsigned long crc32);
  431. </pre></div>
  432. <p><strong>Description</strong><br>
  433. Checks to see if <var>name</var> is a file and if its contents
  434. match <var>crc32</var>.
  435. </p>
  436. <a name="index-separate_005falt_005fdebug_005ffile_005fexists"></a>
  437. <a name="separate_005falt_005fdebug_005ffile_005fexists"></a>
  438. <h4 class="subsubsection">2.14.1.20 <code>separate_alt_debug_file_exists</code></h4>
  439. <p><strong>Synopsis</strong>
  440. </p><div class="example">
  441. <pre class="example">bfd_boolean separate_alt_debug_file_exists
  442. (char *name, unsigned long buildid);
  443. </pre></div>
  444. <p><strong>Description</strong><br>
  445. Checks to see if <var>name</var> is a file and if its BuildID
  446. matches <var>buildid</var>.
  447. </p>
  448. <a name="index-find_005fseparate_005fdebug_005ffile"></a>
  449. <a name="find_005fseparate_005fdebug_005ffile"></a>
  450. <h4 class="subsubsection">2.14.1.21 <code>find_separate_debug_file</code></h4>
  451. <p><strong>Synopsis</strong>
  452. </p><div class="example">
  453. <pre class="example">char *find_separate_debug_file
  454. (bfd *abfd, const char *dir, bfd_boolean include_dirs,
  455. get_func_type get, check_func_type check);
  456. </pre></div>
  457. <p><strong>Description</strong><br>
  458. Searches for a debug information file corresponding to <var>abfd</var>.
  459. The name of the separate debug info file is returned by the <var>get</var>
  460. function. This function scans various fixed locations in the
  461. filesystem, including the file tree rooted at <var>dir</var>. If the
  462. <var>include_dirs</var> parameter is true then the directory components of
  463. <var>abfd</var>&rsquo;s filename will be included in the searched locations.
  464. </p>
  465. <p>Returns the filename of the first file to be found which receives a
  466. TRUE result from the <var>check</var> function. Returns NULL if no valid
  467. file could be found.
  468. </p>
  469. <a name="index-bfd_005ffollow_005fgnu_005fdebuglink"></a>
  470. <a name="bfd_005ffollow_005fgnu_005fdebuglink"></a>
  471. <h4 class="subsubsection">2.14.1.22 <code>bfd_follow_gnu_debuglink</code></h4>
  472. <p><strong>Synopsis</strong>
  473. </p><div class="example">
  474. <pre class="example">char *bfd_follow_gnu_debuglink (bfd *abfd, const char *dir);
  475. </pre></div>
  476. <p><strong>Description</strong><br>
  477. Takes a BFD and searches it for a .gnu_debuglink section. If this
  478. section is found, it examines the section for the name and checksum
  479. of a &rsquo;.debug&rsquo; file containing auxiliary debugging information. It
  480. then searches the filesystem for this .debug file in some standard
  481. locations, including the directory tree rooted at <var>dir</var>, and if
  482. found returns the full filename.
  483. </p>
  484. <p>If <var>dir</var> is NULL, the search will take place starting at
  485. the current directory.
  486. </p>
  487. <p><strong>Returns</strong><br>
  488. <code>NULL</code> on any errors or failure to locate the .debug file,
  489. otherwise a pointer to a heap-allocated string containing the
  490. filename. The caller is responsible for freeing this string.
  491. </p>
  492. <a name="index-bfd_005ffollow_005fgnu_005fdebugaltlink"></a>
  493. <a name="bfd_005ffollow_005fgnu_005fdebugaltlink"></a>
  494. <h4 class="subsubsection">2.14.1.23 <code>bfd_follow_gnu_debugaltlink</code></h4>
  495. <p><strong>Synopsis</strong>
  496. </p><div class="example">
  497. <pre class="example">char *bfd_follow_gnu_debugaltlink (bfd *abfd, const char *dir);
  498. </pre></div>
  499. <p><strong>Description</strong><br>
  500. Takes a BFD and searches it for a .gnu_debugaltlink section. If this
  501. section is found, it examines the section for the name of a file
  502. containing auxiliary debugging information. It then searches the
  503. filesystem for this file in a set of standard locations, including
  504. the directory tree rooted at <var>dir</var>, and if found returns the
  505. full filename.
  506. </p>
  507. <p>If <var>dir</var> is NULL, the search will take place starting at
  508. the current directory.
  509. </p>
  510. <p><strong>Returns</strong><br>
  511. <code>NULL</code> on any errors or failure to locate the debug file,
  512. otherwise a pointer to a heap-allocated string containing the
  513. filename. The caller is responsible for freeing this string.
  514. </p>
  515. <a name="index-bfd_005fcreate_005fgnu_005fdebuglink_005fsection"></a>
  516. <a name="bfd_005fcreate_005fgnu_005fdebuglink_005fsection"></a>
  517. <h4 class="subsubsection">2.14.1.24 <code>bfd_create_gnu_debuglink_section</code></h4>
  518. <p><strong>Synopsis</strong>
  519. </p><div class="example">
  520. <pre class="example">struct bfd_section *bfd_create_gnu_debuglink_section
  521. (bfd *abfd, const char *filename);
  522. </pre></div>
  523. <p><strong>Description</strong><br>
  524. Takes a <var>BFD</var> and adds a .gnu_debuglink section to it. The section is sized
  525. to be big enough to contain a link to the specified <var>filename</var>.
  526. </p>
  527. <p><strong>Returns</strong><br>
  528. A pointer to the new section is returned if all is ok. Otherwise <code>NULL</code> is
  529. returned and bfd_error is set.
  530. </p>
  531. <a name="index-bfd_005ffill_005fin_005fgnu_005fdebuglink_005fsection"></a>
  532. <a name="bfd_005ffill_005fin_005fgnu_005fdebuglink_005fsection"></a>
  533. <h4 class="subsubsection">2.14.1.25 <code>bfd_fill_in_gnu_debuglink_section</code></h4>
  534. <p><strong>Synopsis</strong>
  535. </p><div class="example">
  536. <pre class="example">bfd_boolean bfd_fill_in_gnu_debuglink_section
  537. (bfd *abfd, struct bfd_section *sect, const char *filename);
  538. </pre></div>
  539. <p><strong>Description</strong><br>
  540. Takes a <var>BFD</var> and containing a .gnu_debuglink section <var>SECT</var>
  541. and fills in the contents of the section to contain a link to the
  542. specified <var>filename</var>. The filename should be relative to the
  543. current directory.
  544. </p>
  545. <p><strong>Returns</strong><br>
  546. <code>TRUE</code> is returned if all is ok. Otherwise <code>FALSE</code> is returned
  547. and bfd_error is set.
  548. </p>
  549. <a name="index-get_005fbuild_005fid"></a>
  550. <a name="get_005fbuild_005fid"></a>
  551. <h4 class="subsubsection">2.14.1.26 <code>get_build_id</code></h4>
  552. <p><strong>Synopsis</strong>
  553. </p><div class="example">
  554. <pre class="example">struct bfd_build_id * get_build_id
  555. (bfd *abfd);
  556. </pre></div>
  557. <p><strong>Description</strong><br>
  558. Finds the build-id associated with <var>abfd</var>. If the build-id is
  559. extracted from the note section then a build-id structure is built
  560. for it, using memory allocated to <var>abfd</var>, and this is then
  561. attached to the <var>abfd</var>.
  562. </p>
  563. <p>Returns a pointer to the build-id structure if a build-id could be
  564. found. If no build-id is found NULL is returned and error code is
  565. set.
  566. </p>
  567. <a name="index-get_005fbuild_005fid_005fname"></a>
  568. <a name="get_005fbuild_005fid_005fname"></a>
  569. <h4 class="subsubsection">2.14.1.27 <code>get_build_id_name</code></h4>
  570. <p><strong>Synopsis</strong>
  571. </p><div class="example">
  572. <pre class="example">char * get_build_id_name
  573. (bfd *abfd, unsigned long *build_id_out)
  574. </pre></div>
  575. <p><strong>Description</strong><br>
  576. Searches <var>abfd</var> for a build-id, and then constructs a pathname
  577. from it. The path is computed as .build-id/NN/NN+NN.debug where
  578. NNNN+NN is the build-id value as a hexadecimal string.
  579. </p>
  580. <p>Returns the constructed filename or NULL upon error.
  581. It is the caller&rsquo;s responsibility to free the memory used to hold the
  582. filename.
  583. If a filename is returned then the <var>build_id_out</var> parameter is
  584. set to a pointer to the build_id structure.
  585. </p>
  586. <a name="index-check_005fbuild_005fid_005ffile"></a>
  587. <a name="check_005fbuild_005fid_005ffile"></a>
  588. <h4 class="subsubsection">2.14.1.28 <code>check_build_id_file</code></h4>
  589. <p><strong>Synopsis</strong>
  590. </p><div class="example">
  591. <pre class="example">bfd_boolean check_build_id_file
  592. (char *name, unsigned long buildid);
  593. </pre></div>
  594. <p><strong>Description</strong><br>
  595. Checks to see if <var>name</var> is a readable file and if its build-id
  596. matches <var>buildid</var>.
  597. </p>
  598. <p>Returns TRUE if the file exists, is readable, and contains a build-id
  599. which matches <var>build-id</var>.
  600. </p>
  601. <a name="index-bfd_005ffollow_005fbuild_005fid_005fdebuglink"></a>
  602. <a name="bfd_005ffollow_005fbuild_005fid_005fdebuglink"></a>
  603. <h4 class="subsubsection">2.14.1.29 <code>bfd_follow_build_id_debuglink</code></h4>
  604. <p><strong>Synopsis</strong>
  605. </p><div class="example">
  606. <pre class="example">char *bfd_follow_build_id_debuglink (bfd *abfd, const char *dir);
  607. </pre></div>
  608. <p><strong>Description</strong><br>
  609. Takes <var>abfd</var> and searches it for a .note.gnu.build-id section.
  610. If this section is found, it extracts the value of the NT_GNU_BUILD_ID
  611. note, which should be a hexadecimal value <var>NNNN+NN</var> (for
  612. 32+ hex digits). It then searches the filesystem for a file named
  613. <var>.build-id/NN/NN+NN.debug</var> in a set of standard locations,
  614. including the directory tree rooted at <var>dir</var>. The filename
  615. of the first matching file to be found is returned. A matching
  616. file should contain a .note.gnu.build-id section with the same
  617. <var>NNNN+NN</var> note as <var>abfd</var>, although this check is currently
  618. not implemented.
  619. </p>
  620. <p>If <var>dir</var> is NULL, the search will take place starting at
  621. the current directory.
  622. </p>
  623. <p><strong>Returns</strong><br>
  624. <code>NULL</code> on any errors or failure to locate the debug file,
  625. otherwise a pointer to a heap-allocated string containing the
  626. filename. The caller is responsible for freeing this string.
  627. </p>
  628. <hr>
  629. <div class="header">
  630. <p>
  631. Next: <a href="Internal.html#Internal" accesskey="n" rel="next">Internal</a>, Previous: <a href="Architectures.html#Architectures" accesskey="p" rel="prev">Architectures</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>
  632. </div>
  633. </body>
  634. </html>