選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

687 行
29KB

  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>Opening and Closing (Untitled Document)</title>
  22. <meta name="description" content="Opening and Closing (Untitled Document)">
  23. <meta name="keywords" content="Opening and Closing (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-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.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="Opening-and-Closing"></a>
  63. <div class="header">
  64. <p>
  65. 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>
  66. </div>
  67. <hr>
  68. <div class="example">
  69. <pre class="example">/* Set to N to open the next N BFDs using an alternate id space. */
  70. extern unsigned int bfd_use_reserved_id;
  71. </pre></div>
  72. <a name="Opening-and-closing-BFDs"></a>
  73. <h3 class="section">2.14 Opening and closing BFDs</h3>
  74. <a name="Functions-for-opening-and-closing"></a>
  75. <h4 class="subsection">2.14.1 Functions for opening and closing</h4>
  76. <a name="index-bfd_005ffopen"></a>
  77. <a name="bfd_005ffopen"></a>
  78. <h4 class="subsubsection">2.14.1.1 <code>bfd_fopen</code></h4>
  79. <p><strong>Synopsis</strong>
  80. </p><div class="example">
  81. <pre class="example">bfd *bfd_fopen (const char *filename, const char *target,
  82. const char *mode, int fd);
  83. </pre></div>
  84. <p><strong>Description</strong><br>
  85. Open the file <var>filename</var> with the target <var>target</var>.
  86. Return a pointer to the created BFD. If <var>fd</var> is not -1,
  87. then <code>fdopen</code> is used to open the file; otherwise, <code>fopen</code>
  88. is used. <var>mode</var> is passed directly to <code>fopen</code> or
  89. <code>fdopen</code>.
  90. </p>
  91. <p>Calls <code>bfd_find_target</code>, so <var>target</var> is interpreted as by
  92. that function.
  93. </p>
  94. <p>The new BFD is marked as cacheable iff <var>fd</var> is -1.
  95. </p>
  96. <p>If <code>NULL</code> is returned then an error has occured. Possible errors
  97. are <code>bfd_error_no_memory</code>, <code>bfd_error_invalid_target</code> or
  98. <code>system_call</code> error.
  99. </p>
  100. <p>On error, <var>fd</var> is always closed.
  101. </p>
  102. <p>A copy of the <var>filename</var> argument is stored in the newly created
  103. BFD. It can be accessed via the bfd_get_filename() macro.
  104. </p>
  105. <a name="index-bfd_005fopenr"></a>
  106. <a name="bfd_005fopenr"></a>
  107. <h4 class="subsubsection">2.14.1.2 <code>bfd_openr</code></h4>
  108. <p><strong>Synopsis</strong>
  109. </p><div class="example">
  110. <pre class="example">bfd *bfd_openr (const char *filename, const char *target);
  111. </pre></div>
  112. <p><strong>Description</strong><br>
  113. Open the file <var>filename</var> (using <code>fopen</code>) with the target
  114. <var>target</var>. Return a pointer to the created BFD.
  115. </p>
  116. <p>Calls <code>bfd_find_target</code>, so <var>target</var> is interpreted as by
  117. that function.
  118. </p>
  119. <p>If <code>NULL</code> is returned then an error has occured. Possible errors
  120. are <code>bfd_error_no_memory</code>, <code>bfd_error_invalid_target</code> or
  121. <code>system_call</code> error.
  122. </p>
  123. <p>A copy of the <var>filename</var> argument is stored in the newly created
  124. BFD. It can be accessed via the bfd_get_filename() macro.
  125. </p>
  126. <a name="index-bfd_005ffdopenr"></a>
  127. <a name="bfd_005ffdopenr"></a>
  128. <h4 class="subsubsection">2.14.1.3 <code>bfd_fdopenr</code></h4>
  129. <p><strong>Synopsis</strong>
  130. </p><div class="example">
  131. <pre class="example">bfd *bfd_fdopenr (const char *filename, const char *target, int fd);
  132. </pre></div>
  133. <p><strong>Description</strong><br>
  134. <code>bfd_fdopenr</code> is to <code>bfd_fopenr</code> much like <code>fdopen</code> is to
  135. <code>fopen</code>. It opens a BFD on a file already described by the
  136. <var>fd</var> supplied.
  137. </p>
  138. <p>When the file is later <code>bfd_close</code>d, the file descriptor will
  139. be closed. If the caller desires that this file descriptor be
  140. cached by BFD (opened as needed, closed as needed to free
  141. descriptors for other opens), with the supplied <var>fd</var> used as
  142. an initial file descriptor (but subject to closure at any time),
  143. call bfd_set_cacheable(bfd, 1) on the returned BFD. The default
  144. is to assume no caching; the file descriptor will remain open
  145. until <code>bfd_close</code>, and will not be affected by BFD operations
  146. on other files.
  147. </p>
  148. <p>Possible errors are <code>bfd_error_no_memory</code>,
  149. <code>bfd_error_invalid_target</code> and <code>bfd_error_system_call</code>.
  150. </p>
  151. <p>On error, <var>fd</var> is closed.
  152. </p>
  153. <p>A copy of the <var>filename</var> argument is stored in the newly created
  154. BFD. It can be accessed via the bfd_get_filename() macro.
  155. </p>
  156. <a name="index-bfd_005fopenstreamr"></a>
  157. <a name="bfd_005fopenstreamr"></a>
  158. <h4 class="subsubsection">2.14.1.4 <code>bfd_openstreamr</code></h4>
  159. <p><strong>Synopsis</strong>
  160. </p><div class="example">
  161. <pre class="example">bfd *bfd_openstreamr (const char * filename, const char * target,
  162. 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_005fzalloc"></a>
  345. <a name="bfd_005fzalloc"></a>
  346. <h4 class="subsubsection">2.14.1.13 <code>bfd_zalloc</code></h4>
  347. <p><strong>Synopsis</strong>
  348. </p><div class="example">
  349. <pre class="example">void *bfd_zalloc (bfd *abfd, bfd_size_type wanted);
  350. </pre></div>
  351. <p><strong>Description</strong><br>
  352. Allocate a block of <var>wanted</var> bytes of zeroed memory
  353. attached to <code>abfd</code> and return a pointer to it.
  354. </p>
  355. <a name="index-bfd_005fcalc_005fgnu_005fdebuglink_005fcrc32"></a>
  356. <a name="bfd_005fcalc_005fgnu_005fdebuglink_005fcrc32"></a>
  357. <h4 class="subsubsection">2.14.1.14 <code>bfd_calc_gnu_debuglink_crc32</code></h4>
  358. <p><strong>Synopsis</strong>
  359. </p><div class="example">
  360. <pre class="example">unsigned long bfd_calc_gnu_debuglink_crc32
  361. (unsigned long crc, const unsigned char *buf, bfd_size_type len);
  362. </pre></div>
  363. <p><strong>Description</strong><br>
  364. Computes a CRC value as used in the .gnu_debuglink section.
  365. Advances the previously computed <var>crc</var> value by computing
  366. and adding in the crc32 for <var>len</var> bytes of <var>buf</var>.
  367. </p>
  368. <p><strong>Returns</strong><br>
  369. Return the updated CRC32 value.
  370. </p>
  371. <a name="index-bfd_005fget_005fdebug_005flink_005finfo_005f1"></a>
  372. <a name="bfd_005fget_005fdebug_005flink_005finfo_005f1"></a>
  373. <h4 class="subsubsection">2.14.1.15 <code>bfd_get_debug_link_info_1</code></h4>
  374. <p><strong>Synopsis</strong>
  375. </p><div class="example">
  376. <pre class="example">char *bfd_get_debug_link_info_1 (bfd *abfd, void *crc32_out);
  377. </pre></div>
  378. <p><strong>Description</strong><br>
  379. Extracts the filename and CRC32 value for any separate debug
  380. information file associated with <var>abfd</var>.
  381. </p>
  382. <p>The <var>crc32_out</var> parameter is an untyped pointer because
  383. this routine is used as a <code>get_func_type</code> function, but it
  384. is expected to be an unsigned long pointer.
  385. </p>
  386. <p><strong>Returns</strong><br>
  387. The filename of the associated debug information file, or NULL
  388. if there is no such file. If the filename was found then the
  389. contents of <var>crc32_out</var> are updated to hold the corresponding
  390. CRC32 value for the file.
  391. </p>
  392. <p>The returned filename is allocated with <code>malloc</code>; freeing
  393. it is the responsibility of the caller.
  394. </p>
  395. <a name="index-bfd_005fget_005fdebug_005flink_005finfo"></a>
  396. <a name="bfd_005fget_005fdebug_005flink_005finfo"></a>
  397. <h4 class="subsubsection">2.14.1.16 <code>bfd_get_debug_link_info</code></h4>
  398. <p><strong>Synopsis</strong>
  399. </p><div class="example">
  400. <pre class="example">char *bfd_get_debug_link_info (bfd *abfd, unsigned long *crc32_out);
  401. </pre></div>
  402. <p><strong>Description</strong><br>
  403. Extracts the filename and CRC32 value for any separate debug
  404. information file associated with <var>abfd</var>.
  405. </p>
  406. <p><strong>Returns</strong><br>
  407. The filename of the associated debug information file, or NULL
  408. if there is no such file. If the filename was found then the
  409. contents of <var>crc32_out</var> are updated to hold the corresponding
  410. CRC32 value for the file.
  411. </p>
  412. <p>The returned filename is allocated with <code>malloc</code>; freeing
  413. it is the responsibility of the caller.
  414. </p>
  415. <a name="index-bfd_005fget_005falt_005fdebug_005flink_005finfo"></a>
  416. <a name="bfd_005fget_005falt_005fdebug_005flink_005finfo"></a>
  417. <h4 class="subsubsection">2.14.1.17 <code>bfd_get_alt_debug_link_info</code></h4>
  418. <p><strong>Synopsis</strong>
  419. </p><div class="example">
  420. <pre class="example">char *bfd_get_alt_debug_link_info (bfd * abfd,
  421. bfd_size_type *buildid_len,
  422. bfd_byte **buildid_out);
  423. </pre></div>
  424. <p><strong>Description</strong><br>
  425. Fetch the filename and BuildID value for any alternate debuginfo
  426. associated with <var>abfd</var>. Return NULL if no such info found,
  427. otherwise return filename and update <var>buildid_len</var> and
  428. <var>buildid_out</var>. The returned filename and build_id are
  429. allocated with <code>malloc</code>; freeing them is the responsibility
  430. of the caller.
  431. </p>
  432. <a name="index-separate_005fdebug_005ffile_005fexists"></a>
  433. <a name="separate_005fdebug_005ffile_005fexists"></a>
  434. <h4 class="subsubsection">2.14.1.18 <code>separate_debug_file_exists</code></h4>
  435. <p><strong>Synopsis</strong>
  436. </p><div class="example">
  437. <pre class="example">bfd_boolean separate_debug_file_exists
  438. (char *name, void *crc32_p);
  439. </pre></div>
  440. <p><strong>Description</strong><br>
  441. Checks to see if <var>name</var> is a file and if its contents
  442. match <var>crc32</var>, which is a pointer to an <code>unsigned
  443. long</code> containing a CRC32.
  444. </p>
  445. <p>The <var>crc32_p</var> parameter is an untyped pointer because
  446. this routine is used as a <code>check_func_type</code> function.
  447. </p>
  448. <a name="index-separate_005falt_005fdebug_005ffile_005fexists"></a>
  449. <a name="separate_005falt_005fdebug_005ffile_005fexists"></a>
  450. <h4 class="subsubsection">2.14.1.19 <code>separate_alt_debug_file_exists</code></h4>
  451. <p><strong>Synopsis</strong>
  452. </p><div class="example">
  453. <pre class="example">bfd_boolean separate_alt_debug_file_exists
  454. (char *name, void *unused);
  455. </pre></div>
  456. <p><strong>Description</strong><br>
  457. Checks to see if <var>name</var> is a file.
  458. </p>
  459. <a name="index-find_005fseparate_005fdebug_005ffile"></a>
  460. <a name="find_005fseparate_005fdebug_005ffile"></a>
  461. <h4 class="subsubsection">2.14.1.20 <code>find_separate_debug_file</code></h4>
  462. <p><strong>Synopsis</strong>
  463. </p><div class="example">
  464. <pre class="example">char *find_separate_debug_file
  465. (bfd *abfd, const char *dir, bfd_boolean include_dirs,
  466. get_func_type get, check_func_type check, void *data);
  467. </pre></div>
  468. <p><strong>Description</strong><br>
  469. Searches for a debug information file corresponding to <var>abfd</var>.
  470. </p>
  471. <p>The name of the separate debug info file is returned by the
  472. <var>get</var> function. This function scans various fixed locations
  473. in the filesystem, including the file tree rooted at <var>dir</var>.
  474. If the <var>include_dirs</var> parameter is true then the directory
  475. components of <var>abfd</var>&rsquo;s filename will be included in the
  476. searched locations.
  477. </p>
  478. <p><var>data</var> is passed unmodified to the <var>get</var> and <var>check</var>
  479. functions. It is generally used to implement build-id-like
  480. matching in the callback functions.
  481. </p>
  482. <p><strong>Returns</strong><br>
  483. Returns the filename of the first file to be found which
  484. receives a TRUE result from the <var>check</var> function.
  485. Returns NULL if no valid file could be found.
  486. </p>
  487. <a name="index-bfd_005ffollow_005fgnu_005fdebuglink"></a>
  488. <a name="bfd_005ffollow_005fgnu_005fdebuglink"></a>
  489. <h4 class="subsubsection">2.14.1.21 <code>bfd_follow_gnu_debuglink</code></h4>
  490. <p><strong>Synopsis</strong>
  491. </p><div class="example">
  492. <pre class="example">char *bfd_follow_gnu_debuglink (bfd *abfd, const char *dir);
  493. </pre></div>
  494. <p><strong>Description</strong><br>
  495. Takes a BFD and searches it for a .gnu_debuglink section. If this
  496. section is found, it examines the section for the name and checksum
  497. of a &rsquo;.debug&rsquo; file containing auxiliary debugging information. It
  498. then searches the filesystem for this .debug file in some standard
  499. locations, including the directory tree rooted at <var>dir</var>, and if
  500. found returns the full filename.
  501. </p>
  502. <p>If <var>dir</var> is NULL, the search will take place starting at
  503. the current directory.
  504. </p>
  505. <p><strong>Returns</strong><br>
  506. <code>NULL</code> on any errors or failure to locate the .debug file,
  507. otherwise a pointer to a heap-allocated string containing the
  508. filename. The caller is responsible for freeing this string.
  509. </p>
  510. <a name="index-bfd_005ffollow_005fgnu_005fdebugaltlink"></a>
  511. <a name="bfd_005ffollow_005fgnu_005fdebugaltlink"></a>
  512. <h4 class="subsubsection">2.14.1.22 <code>bfd_follow_gnu_debugaltlink</code></h4>
  513. <p><strong>Synopsis</strong>
  514. </p><div class="example">
  515. <pre class="example">char *bfd_follow_gnu_debugaltlink (bfd *abfd, const char *dir);
  516. </pre></div>
  517. <p><strong>Description</strong><br>
  518. Takes a BFD and searches it for a .gnu_debugaltlink section. If this
  519. section is found, it examines the section for the name of a file
  520. containing auxiliary debugging information. It then searches the
  521. filesystem for this file in a set of standard locations, including
  522. the directory tree rooted at <var>dir</var>, and if found returns the
  523. full filename.
  524. </p>
  525. <p>If <var>dir</var> is NULL, the search will take place starting at
  526. the current directory.
  527. </p>
  528. <p><strong>Returns</strong><br>
  529. <code>NULL</code> on any errors or failure to locate the debug file,
  530. otherwise a pointer to a heap-allocated string containing the
  531. filename. The caller is responsible for freeing this string.
  532. </p>
  533. <a name="index-bfd_005fcreate_005fgnu_005fdebuglink_005fsection"></a>
  534. <a name="bfd_005fcreate_005fgnu_005fdebuglink_005fsection"></a>
  535. <h4 class="subsubsection">2.14.1.23 <code>bfd_create_gnu_debuglink_section</code></h4>
  536. <p><strong>Synopsis</strong>
  537. </p><div class="example">
  538. <pre class="example">struct bfd_section *bfd_create_gnu_debuglink_section
  539. (bfd *abfd, const char *filename);
  540. </pre></div>
  541. <p><strong>Description</strong><br>
  542. Takes a <var>BFD</var> and adds a .gnu_debuglink section to it. The
  543. section is sized to be big enough to contain a link to the specified
  544. <var>filename</var>.
  545. </p>
  546. <p><strong>Returns</strong><br>
  547. A pointer to the new section is returned if all is ok. Otherwise
  548. <code>NULL</code> is returned and bfd_error is set.
  549. </p>
  550. <a name="index-bfd_005ffill_005fin_005fgnu_005fdebuglink_005fsection"></a>
  551. <a name="bfd_005ffill_005fin_005fgnu_005fdebuglink_005fsection"></a>
  552. <h4 class="subsubsection">2.14.1.24 <code>bfd_fill_in_gnu_debuglink_section</code></h4>
  553. <p><strong>Synopsis</strong>
  554. </p><div class="example">
  555. <pre class="example">bfd_boolean bfd_fill_in_gnu_debuglink_section
  556. (bfd *abfd, struct bfd_section *sect, const char *filename);
  557. </pre></div>
  558. <p><strong>Description</strong><br>
  559. Takes a <var>BFD</var> and containing a .gnu_debuglink section <var>SECT</var>
  560. and fills in the contents of the section to contain a link to the
  561. specified <var>filename</var>. The filename should be relative to the
  562. current directory.
  563. </p>
  564. <p><strong>Returns</strong><br>
  565. <code>TRUE</code> is returned if all is ok. Otherwise <code>FALSE</code> is returned
  566. and bfd_error is set.
  567. </p>
  568. <a name="index-get_005fbuild_005fid"></a>
  569. <a name="get_005fbuild_005fid"></a>
  570. <h4 class="subsubsection">2.14.1.25 <code>get_build_id</code></h4>
  571. <p><strong>Synopsis</strong>
  572. </p><div class="example">
  573. <pre class="example">struct bfd_build_id * get_build_id (bfd *abfd);
  574. </pre></div>
  575. <p><strong>Description</strong><br>
  576. Finds the build-id associated with <var>abfd</var>. If the build-id is
  577. extracted from the note section then a build-id structure is built
  578. for it, using memory allocated to <var>abfd</var>, and this is then
  579. attached to the <var>abfd</var>.
  580. </p>
  581. <p><strong>Returns</strong><br>
  582. Returns a pointer to the build-id structure if a build-id could be
  583. found. If no build-id is found NULL is returned and error code is
  584. set.
  585. </p>
  586. <a name="index-get_005fbuild_005fid_005fname"></a>
  587. <a name="get_005fbuild_005fid_005fname"></a>
  588. <h4 class="subsubsection">2.14.1.26 <code>get_build_id_name</code></h4>
  589. <p><strong>Synopsis</strong>
  590. </p><div class="example">
  591. <pre class="example">char * get_build_id_name (bfd *abfd, void *build_id_out_p)
  592. </pre></div>
  593. <p><strong>Description</strong><br>
  594. Searches <var>abfd</var> for a build-id, and then constructs a pathname
  595. from it. The path is computed as .build-id/NN/NN+NN.debug where
  596. NNNN+NN is the build-id value as a hexadecimal string.
  597. </p>
  598. <p><strong>Returns</strong><br>
  599. Returns the constructed filename or NULL upon error.
  600. It is the caller&rsquo;s responsibility to free the memory used to hold the
  601. filename.
  602. If a filename is returned then the <var>build_id_out_p</var>
  603. parameter (which points to a <code>struct bfd_build_id</code>
  604. pointer) is set to a pointer to the build_id structure.
  605. </p>
  606. <a name="index-check_005fbuild_005fid_005ffile"></a>
  607. <a name="check_005fbuild_005fid_005ffile"></a>
  608. <h4 class="subsubsection">2.14.1.27 <code>check_build_id_file</code></h4>
  609. <p><strong>Synopsis</strong>
  610. </p><div class="example">
  611. <pre class="example">bfd_boolean check_build_id_file (char *name, void *buildid_p);
  612. </pre></div>
  613. <p><strong>Description</strong><br>
  614. Checks to see if <var>name</var> is a readable file and if its build-id
  615. matches <var>buildid</var>.
  616. </p>
  617. <p><strong>Returns</strong><br>
  618. Returns TRUE if the file exists, is readable, and contains a
  619. build-id which matches the build-id pointed at by
  620. <var>build_id_p</var> (which is really a <code>struct bfd_build_id **</code>).
  621. </p>
  622. <a name="index-bfd_005ffollow_005fbuild_005fid_005fdebuglink"></a>
  623. <a name="bfd_005ffollow_005fbuild_005fid_005fdebuglink"></a>
  624. <h4 class="subsubsection">2.14.1.28 <code>bfd_follow_build_id_debuglink</code></h4>
  625. <p><strong>Synopsis</strong>
  626. </p><div class="example">
  627. <pre class="example">char *bfd_follow_build_id_debuglink (bfd *abfd, const char *dir);
  628. </pre></div>
  629. <p><strong>Description</strong><br>
  630. Takes <var>abfd</var> and searches it for a .note.gnu.build-id section.
  631. If this section is found, it extracts the value of the NT_GNU_BUILD_ID
  632. note, which should be a hexadecimal value <var>NNNN+NN</var> (for
  633. 32+ hex digits). It then searches the filesystem for a file named
  634. <var>.build-id/NN/NN+NN.debug</var> in a set of standard locations,
  635. including the directory tree rooted at <var>dir</var>. The filename
  636. of the first matching file to be found is returned. A matching
  637. file should contain a .note.gnu.build-id section with the same
  638. <var>NNNN+NN</var> note as <var>abfd</var>, although this check is currently
  639. not implemented.
  640. </p>
  641. <p>If <var>dir</var> is NULL, the search will take place starting at
  642. the current directory.
  643. </p>
  644. <p><strong>Returns</strong><br>
  645. <code>NULL</code> on any errors or failure to locate the debug file,
  646. otherwise a pointer to a heap-allocated string containing the
  647. filename. The caller is responsible for freeing this string.
  648. </p>
  649. <a name="index-bfd_005fset_005ffilename"></a>
  650. <a name="bfd_005fset_005ffilename"></a>
  651. <h4 class="subsubsection">2.14.1.29 <code>bfd_set_filename</code></h4>
  652. <p><strong>Synopsis</strong>
  653. </p><div class="example">
  654. <pre class="example">const char *bfd_set_filename (bfd *abfd, const char *filename);
  655. </pre></div>
  656. <p><strong>Description</strong><br>
  657. Set the filename of <var>abfd</var>, copying the FILENAME parameter to
  658. bfd_alloc&rsquo;d memory owned by <var>abfd</var>. Returns a pointer the
  659. newly allocated name, or NULL if the allocation failed.
  660. </p>
  661. <hr>
  662. <div class="header">
  663. <p>
  664. 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>
  665. </div>
  666. </body>
  667. </html>