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.

287 lines
11KB

  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>Error reporting (Untitled Document)</title>
  22. <meta name="description" content="Error reporting (Untitled Document)">
  23. <meta name="keywords" content="Error reporting (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="Miscellaneous.html#Miscellaneous" rel="next" title="Miscellaneous">
  32. <link href="typedef-bfd.html#typedef-bfd" rel="prev" title="typedef bfd">
  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="Error-reporting"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Miscellaneous.html#Miscellaneous" accesskey="n" rel="next">Miscellaneous</a>, Previous: <a href="typedef-bfd.html#typedef-bfd" accesskey="p" rel="prev">typedef bfd</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. <a name="Error-reporting-1"></a>
  69. <h3 class="section">2.2 Error reporting</h3>
  70. <p>Most BFD functions return nonzero on success (check their
  71. individual documentation for precise semantics). On an error,
  72. they call <code>bfd_set_error</code> to set an error condition that callers
  73. can check by calling <code>bfd_get_error</code>.
  74. If that returns <code>bfd_error_system_call</code>, then check
  75. <code>errno</code>.
  76. </p>
  77. <p>The easiest way to report a BFD error to the user is to
  78. use <code>bfd_perror</code>.
  79. </p>
  80. <a name="Type-bfd_005ferror_005ftype"></a>
  81. <h4 class="subsection">2.2.1 Type <code>bfd_error_type</code></h4>
  82. <p>The values returned by <code>bfd_get_error</code> are defined by the
  83. enumerated type <code>bfd_error_type</code>.
  84. </p>
  85. <div class="example">
  86. <pre class="example">
  87. typedef enum bfd_error
  88. {
  89. bfd_error_no_error = 0,
  90. bfd_error_system_call,
  91. bfd_error_invalid_target,
  92. bfd_error_wrong_format,
  93. bfd_error_wrong_object_format,
  94. bfd_error_invalid_operation,
  95. bfd_error_no_memory,
  96. bfd_error_no_symbols,
  97. bfd_error_no_armap,
  98. bfd_error_no_more_archived_files,
  99. bfd_error_malformed_archive,
  100. bfd_error_missing_dso,
  101. bfd_error_file_not_recognized,
  102. bfd_error_file_ambiguously_recognized,
  103. bfd_error_no_contents,
  104. bfd_error_nonrepresentable_section,
  105. bfd_error_no_debug_section,
  106. bfd_error_bad_value,
  107. bfd_error_file_truncated,
  108. bfd_error_file_too_big,
  109. bfd_error_sorry,
  110. bfd_error_on_input,
  111. bfd_error_invalid_error_code
  112. }
  113. bfd_error_type;
  114. </pre></div>
  115. <a name="index-bfd_005fget_005ferror"></a>
  116. <a name="bfd_005fget_005ferror"></a>
  117. <h4 class="subsubsection">2.2.1.1 <code>bfd_get_error</code></h4>
  118. <p><strong>Synopsis</strong>
  119. </p><div class="example">
  120. <pre class="example">bfd_error_type bfd_get_error (void);
  121. </pre></div>
  122. <p><strong>Description</strong><br>
  123. Return the current BFD error condition.
  124. </p>
  125. <a name="index-bfd_005fset_005ferror"></a>
  126. <a name="bfd_005fset_005ferror"></a>
  127. <h4 class="subsubsection">2.2.1.2 <code>bfd_set_error</code></h4>
  128. <p><strong>Synopsis</strong>
  129. </p><div class="example">
  130. <pre class="example">void bfd_set_error (bfd_error_type error_tag);
  131. </pre></div>
  132. <p><strong>Description</strong><br>
  133. Set the BFD error condition to be <var>error_tag</var>.
  134. </p>
  135. <p><var>error_tag</var> must not be bfd_error_on_input. Use
  136. bfd_set_input_error for input errors instead.
  137. </p>
  138. <a name="index-bfd_005fset_005finput_005ferror"></a>
  139. <a name="bfd_005fset_005finput_005ferror"></a>
  140. <h4 class="subsubsection">2.2.1.3 <code>bfd_set_input_error</code></h4>
  141. <p><strong>Synopsis</strong>
  142. </p><div class="example">
  143. <pre class="example">void bfd_set_input_error (bfd *input, bfd_error_type error_tag);
  144. </pre></div>
  145. <p><strong>Description</strong><br>
  146. Set the BFD error condition to be bfd_error_on_input.
  147. <var>input</var> is the input bfd where the error occurred, and
  148. <var>error_tag</var> the bfd_error_type error.
  149. </p>
  150. <a name="index-bfd_005ferrmsg"></a>
  151. <a name="bfd_005ferrmsg"></a>
  152. <h4 class="subsubsection">2.2.1.4 <code>bfd_errmsg</code></h4>
  153. <p><strong>Synopsis</strong>
  154. </p><div class="example">
  155. <pre class="example">const char *bfd_errmsg (bfd_error_type error_tag);
  156. </pre></div>
  157. <p><strong>Description</strong><br>
  158. Return a string describing the error <var>error_tag</var>, or
  159. the system error if <var>error_tag</var> is <code>bfd_error_system_call</code>.
  160. </p>
  161. <a name="index-bfd_005fperror"></a>
  162. <a name="bfd_005fperror"></a>
  163. <h4 class="subsubsection">2.2.1.5 <code>bfd_perror</code></h4>
  164. <p><strong>Synopsis</strong>
  165. </p><div class="example">
  166. <pre class="example">void bfd_perror (const char *message);
  167. </pre></div>
  168. <p><strong>Description</strong><br>
  169. Print to the standard error stream a string describing the
  170. last BFD error that occurred, or the last system error if
  171. the last BFD error was a system call failure. If <var>message</var>
  172. is non-NULL and non-empty, the error string printed is preceded
  173. by <var>message</var>, a colon, and a space. It is followed by a newline.
  174. </p>
  175. <a name="BFD-error-handler"></a>
  176. <h4 class="subsection">2.2.2 BFD error handler</h4>
  177. <p>Some BFD functions want to print messages describing the
  178. problem. They call a BFD error handler function. This
  179. function may be overridden by the program.
  180. </p>
  181. <p>The BFD error handler acts like vprintf.
  182. </p>
  183. <div class="example">
  184. <pre class="example">
  185. typedef void (*bfd_error_handler_type) (const char *, va_list);
  186. </pre></div>
  187. <a name="index-_005fbfd_005ferror_005fhandler"></a>
  188. <a name="g_t_005fbfd_005ferror_005fhandler"></a>
  189. <h4 class="subsubsection">2.2.2.1 <code>_bfd_error_handler</code></h4>
  190. <p><strong>Synopsis</strong>
  191. </p><div class="example">
  192. <pre class="example">void _bfd_error_handler (const char *fmt, ...) ATTRIBUTE_PRINTF_1;
  193. </pre></div>
  194. <p><strong>Description</strong><br>
  195. This is the default routine to handle BFD error messages.
  196. Like fprintf (stderr, ...), but also handles some extra format
  197. specifiers.
  198. </p>
  199. <p>%pA section name from section. For group components, prints
  200. group name too.
  201. %pB file name from bfd. For archive components, prints
  202. archive too.
  203. </p>
  204. <p>Beware: Only supports a maximum of 9 format arguments.
  205. </p>
  206. <a name="index-bfd_005fset_005ferror_005fhandler"></a>
  207. <a name="bfd_005fset_005ferror_005fhandler"></a>
  208. <h4 class="subsubsection">2.2.2.2 <code>bfd_set_error_handler</code></h4>
  209. <p><strong>Synopsis</strong>
  210. </p><div class="example">
  211. <pre class="example">bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type);
  212. </pre></div>
  213. <p><strong>Description</strong><br>
  214. Set the BFD error handler function. Returns the previous
  215. function.
  216. </p>
  217. <a name="index-bfd_005fset_005ferror_005fprogram_005fname"></a>
  218. <a name="bfd_005fset_005ferror_005fprogram_005fname"></a>
  219. <h4 class="subsubsection">2.2.2.3 <code>bfd_set_error_program_name</code></h4>
  220. <p><strong>Synopsis</strong>
  221. </p><div class="example">
  222. <pre class="example">void bfd_set_error_program_name (const char *);
  223. </pre></div>
  224. <p><strong>Description</strong><br>
  225. Set the program name to use when printing a BFD error. This
  226. is printed before the error message followed by a colon and
  227. space. The string must not be changed after it is passed to
  228. this function.
  229. </p>
  230. <a name="BFD-assert-handler"></a>
  231. <h4 class="subsection">2.2.3 BFD assert handler</h4>
  232. <p>If BFD finds an internal inconsistency, the bfd assert
  233. handler is called with information on the BFD version, BFD
  234. source file and line. If this happens, most programs linked
  235. against BFD are expected to want to exit with an error, or mark
  236. the current BFD operation as failed, so it is recommended to
  237. override the default handler, which just calls
  238. _bfd_error_handler and continues.
  239. </p>
  240. <div class="example">
  241. <pre class="example">
  242. typedef void (*bfd_assert_handler_type) (const char *bfd_formatmsg,
  243. const char *bfd_version,
  244. const char *bfd_file,
  245. int bfd_line);
  246. </pre></div>
  247. <a name="index-bfd_005fset_005fassert_005fhandler"></a>
  248. <a name="bfd_005fset_005fassert_005fhandler"></a>
  249. <h4 class="subsubsection">2.2.3.1 <code>bfd_set_assert_handler</code></h4>
  250. <p><strong>Synopsis</strong>
  251. </p><div class="example">
  252. <pre class="example">bfd_assert_handler_type bfd_set_assert_handler (bfd_assert_handler_type);
  253. </pre></div>
  254. <p><strong>Description</strong><br>
  255. Set the BFD assert handler function. Returns the previous
  256. function.
  257. </p>
  258. <hr>
  259. <div class="header">
  260. <p>
  261. Next: <a href="Miscellaneous.html#Miscellaneous" accesskey="n" rel="next">Miscellaneous</a>, Previous: <a href="typedef-bfd.html#typedef-bfd" accesskey="p" rel="prev">typedef bfd</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>
  262. </div>
  263. </body>
  264. </html>