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.

127 lines
5.1KB

  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>How It Works (Untitled Document)</title>
  22. <meta name="description" content="How It Works (Untitled Document)">
  23. <meta name="keywords" content="How It Works (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="Overview.html#Overview" rel="up" title="Overview">
  31. <link href="What-BFD-Version-2-Can-Do.html#What-BFD-Version-2-Can-Do" rel="next" title="What BFD Version 2 Can Do">
  32. <link href="History.html#History" rel="prev" title="History">
  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="How-It-Works"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="What-BFD-Version-2-Can-Do.html#What-BFD-Version-2-Can-Do" accesskey="n" rel="next">What BFD Version 2 Can Do</a>, Previous: <a href="History.html#History" accesskey="p" rel="prev">History</a>, Up: <a href="Overview.html#Overview" accesskey="u" rel="up">Overview</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="How-To-Use-BFD"></a>
  69. <h3 class="section">1.2 How To Use BFD</h3>
  70. <p>To use the library, include <samp>bfd.h</samp> and link with <samp>libbfd.a</samp>.
  71. </p>
  72. <p>BFD provides a common interface to the parts of an object file
  73. for a calling application.
  74. </p>
  75. <p>When an application successfully opens a target file (object, archive, or
  76. whatever), a pointer to an internal structure is returned. This pointer
  77. points to a structure called <code>bfd</code>, described in
  78. <samp>bfd.h</samp>. Our convention is to call this pointer a BFD, and
  79. instances of it within code <code>abfd</code>. All operations on
  80. the target object file are applied as methods to the BFD. The mapping is
  81. defined within <code>bfd.h</code> in a set of macros, all beginning
  82. with &lsquo;<samp>bfd_</samp>&rsquo; to reduce namespace pollution.
  83. </p>
  84. <p>For example, this sequence does what you would probably expect:
  85. return the number of sections in an object file attached to a BFD
  86. <code>abfd</code>.
  87. </p>
  88. <div class="example">
  89. <pre class="example">#include &quot;bfd.h&quot;
  90. unsigned int number_of_sections (abfd)
  91. bfd *abfd;
  92. {
  93. return bfd_count_sections (abfd);
  94. }
  95. </pre></div>
  96. <p>The abstraction used within BFD is that an object file has:
  97. </p>
  98. <ul>
  99. <li> a header,
  100. </li><li> a number of sections containing raw data (see <a href="Sections.html#Sections">Sections</a>),
  101. </li><li> a set of relocations (see <a href="Relocations.html#Relocations">Relocations</a>), and
  102. </li><li> some symbol information (see <a href="Symbols.html#Symbols">Symbols</a>).
  103. </li></ul>
  104. <p>Also, BFDs opened for archives have the additional attribute of an index
  105. and contain subordinate BFDs. This approach is fine for a.out and coff,
  106. but loses efficiency when applied to formats such as S-records and
  107. IEEE-695.
  108. </p>
  109. </body>
  110. </html>