Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

1120 lines
53KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1991-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3
  6. or any later version published by the Free Software Foundation;
  7. with no Invariant Sections, with no Front-Cover Texts, and with no
  8. Back-Cover Texts. A copy of the license is included in the
  9. section entitled "GNU Free Documentation License".
  10. -->
  11. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  12. <head>
  13. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  14. <title>objcopy (GNU Binary Utilities)</title>
  15. <meta name="description" content="objcopy (GNU Binary Utilities)">
  16. <meta name="keywords" content="objcopy (GNU Binary Utilities)">
  17. <meta name="resource-type" content="document">
  18. <meta name="distribution" content="global">
  19. <meta name="Generator" content="makeinfo">
  20. <link href="index.html#Top" rel="start" title="Top">
  21. <link href="Binutils-Index.html#Binutils-Index" rel="index" title="Binutils Index">
  22. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  23. <link href="index.html#Top" rel="up" title="Top">
  24. <link href="objdump.html#objdump" rel="next" title="objdump">
  25. <link href="nm.html#nm" rel="prev" title="nm">
  26. <style type="text/css">
  27. <!--
  28. a.summary-letter {text-decoration: none}
  29. blockquote.indentedblock {margin-right: 0em}
  30. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  31. blockquote.smallquotation {font-size: smaller}
  32. div.display {margin-left: 3.2em}
  33. div.example {margin-left: 3.2em}
  34. div.lisp {margin-left: 3.2em}
  35. div.smalldisplay {margin-left: 3.2em}
  36. div.smallexample {margin-left: 3.2em}
  37. div.smalllisp {margin-left: 3.2em}
  38. kbd {font-style: oblique}
  39. pre.display {font-family: inherit}
  40. pre.format {font-family: inherit}
  41. pre.menu-comment {font-family: serif}
  42. pre.menu-preformatted {font-family: serif}
  43. pre.smalldisplay {font-family: inherit; font-size: smaller}
  44. pre.smallexample {font-size: smaller}
  45. pre.smallformat {font-family: inherit; font-size: smaller}
  46. pre.smalllisp {font-size: smaller}
  47. span.nolinebreak {white-space: nowrap}
  48. span.roman {font-family: initial; font-weight: normal}
  49. span.sansserif {font-family: sans-serif; font-weight: normal}
  50. ul.no-bullet {list-style: none}
  51. -->
  52. </style>
  53. </head>
  54. <body lang="en">
  55. <a name="objcopy"></a>
  56. <div class="header">
  57. <p>
  58. Next: <a href="objdump.html#objdump" accesskey="n" rel="next">objdump</a>, Previous: <a href="nm.html#nm" accesskey="p" rel="prev">nm</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Binutils-Index.html#Binutils-Index" title="Index" rel="index">Index</a>]</p>
  59. </div>
  60. <hr>
  61. <a name="objcopy-1"></a>
  62. <h2 class="chapter">3 objcopy</h2>
  63. <div class="smallexample">
  64. <pre class="smallexample">objcopy [<samp>-F</samp> <var>bfdname</var>|<samp>--target=</samp><var>bfdname</var>]
  65. [<samp>-I</samp> <var>bfdname</var>|<samp>--input-target=</samp><var>bfdname</var>]
  66. [<samp>-O</samp> <var>bfdname</var>|<samp>--output-target=</samp><var>bfdname</var>]
  67. [<samp>-B</samp> <var>bfdarch</var>|<samp>--binary-architecture=</samp><var>bfdarch</var>]
  68. [<samp>-S</samp>|<samp>--strip-all</samp>]
  69. [<samp>-g</samp>|<samp>--strip-debug</samp>]
  70. [<samp>--strip-unneeded</samp>]
  71. [<samp>-K</samp> <var>symbolname</var>|<samp>--keep-symbol=</samp><var>symbolname</var>]
  72. [<samp>-N</samp> <var>symbolname</var>|<samp>--strip-symbol=</samp><var>symbolname</var>]
  73. [<samp>--strip-unneeded-symbol=</samp><var>symbolname</var>]
  74. [<samp>-G</samp> <var>symbolname</var>|<samp>--keep-global-symbol=</samp><var>symbolname</var>]
  75. [<samp>--localize-hidden</samp>]
  76. [<samp>-L</samp> <var>symbolname</var>|<samp>--localize-symbol=</samp><var>symbolname</var>]
  77. [<samp>--globalize-symbol=</samp><var>symbolname</var>]
  78. [<samp>--globalize-symbols=</samp><var>filename</var>]
  79. [<samp>-W</samp> <var>symbolname</var>|<samp>--weaken-symbol=</samp><var>symbolname</var>]
  80. [<samp>-w</samp>|<samp>--wildcard</samp>]
  81. [<samp>-x</samp>|<samp>--discard-all</samp>]
  82. [<samp>-X</samp>|<samp>--discard-locals</samp>]
  83. [<samp>-b</samp> <var>byte</var>|<samp>--byte=</samp><var>byte</var>]
  84. [<samp>-i</samp> [<var>breadth</var>]|<samp>--interleave</samp>[=<var>breadth</var>]]
  85. [<samp>--interleave-width=</samp><var>width</var>]
  86. [<samp>-j</samp> <var>sectionpattern</var>|<samp>--only-section=</samp><var>sectionpattern</var>]
  87. [<samp>-R</samp> <var>sectionpattern</var>|<samp>--remove-section=</samp><var>sectionpattern</var>]
  88. [<samp>--keep-section=</samp><var>sectionpattern</var>]
  89. [<samp>--remove-relocations=</samp><var>sectionpattern</var>]
  90. [<samp>-p</samp>|<samp>--preserve-dates</samp>]
  91. [<samp>-D</samp>|<samp>--enable-deterministic-archives</samp>]
  92. [<samp>-U</samp>|<samp>--disable-deterministic-archives</samp>]
  93. [<samp>--debugging</samp>]
  94. [<samp>--gap-fill=</samp><var>val</var>]
  95. [<samp>--pad-to=</samp><var>address</var>]
  96. [<samp>--set-start=</samp><var>val</var>]
  97. [<samp>--adjust-start=</samp><var>incr</var>]
  98. [<samp>--change-addresses=</samp><var>incr</var>]
  99. [<samp>--change-section-address</samp> <var>sectionpattern</var>{=,+,-}<var>val</var>]
  100. [<samp>--change-section-lma</samp> <var>sectionpattern</var>{=,+,-}<var>val</var>]
  101. [<samp>--change-section-vma</samp> <var>sectionpattern</var>{=,+,-}<var>val</var>]
  102. [<samp>--change-warnings</samp>] [<samp>--no-change-warnings</samp>]
  103. [<samp>--set-section-flags</samp> <var>sectionpattern</var>=<var>flags</var>]
  104. [<samp>--set-section-alignment</samp> <var>sectionpattern</var>=<var>align</var>]
  105. [<samp>--add-section</samp> <var>sectionname</var>=<var>filename</var>]
  106. [<samp>--dump-section</samp> <var>sectionname</var>=<var>filename</var>]
  107. [<samp>--update-section</samp> <var>sectionname</var>=<var>filename</var>]
  108. [<samp>--rename-section</samp> <var>oldname</var>=<var>newname</var>[,<var>flags</var>]]
  109. [<samp>--long-section-names</samp> {enable,disable,keep}]
  110. [<samp>--change-leading-char</samp>] [<samp>--remove-leading-char</samp>]
  111. [<samp>--reverse-bytes=</samp><var>num</var>]
  112. [<samp>--srec-len=</samp><var>ival</var>] [<samp>--srec-forceS3</samp>]
  113. [<samp>--redefine-sym</samp> <var>old</var>=<var>new</var>]
  114. [<samp>--redefine-syms=</samp><var>filename</var>]
  115. [<samp>--weaken</samp>]
  116. [<samp>--keep-symbols=</samp><var>filename</var>]
  117. [<samp>--strip-symbols=</samp><var>filename</var>]
  118. [<samp>--strip-unneeded-symbols=</samp><var>filename</var>]
  119. [<samp>--keep-global-symbols=</samp><var>filename</var>]
  120. [<samp>--localize-symbols=</samp><var>filename</var>]
  121. [<samp>--weaken-symbols=</samp><var>filename</var>]
  122. [<samp>--add-symbol</samp> <var>name</var>=[<var>section</var>:]<var>value</var>[,<var>flags</var>]]
  123. [<samp>--alt-machine-code=</samp><var>index</var>]
  124. [<samp>--prefix-symbols=</samp><var>string</var>]
  125. [<samp>--prefix-sections=</samp><var>string</var>]
  126. [<samp>--prefix-alloc-sections=</samp><var>string</var>]
  127. [<samp>--add-gnu-debuglink=</samp><var>path-to-file</var>]
  128. [<samp>--keep-file-symbols</samp>]
  129. [<samp>--only-keep-debug</samp>]
  130. [<samp>--strip-dwo</samp>]
  131. [<samp>--extract-dwo</samp>]
  132. [<samp>--extract-symbol</samp>]
  133. [<samp>--writable-text</samp>]
  134. [<samp>--readonly-text</samp>]
  135. [<samp>--pure</samp>]
  136. [<samp>--impure</samp>]
  137. [<samp>--file-alignment=</samp><var>num</var>]
  138. [<samp>--heap=</samp><var>size</var>]
  139. [<samp>--image-base=</samp><var>address</var>]
  140. [<samp>--section-alignment=</samp><var>num</var>]
  141. [<samp>--stack=</samp><var>size</var>]
  142. [<samp>--subsystem=</samp><var>which</var>:<var>major</var>.<var>minor</var>]
  143. [<samp>--compress-debug-sections</samp>]
  144. [<samp>--decompress-debug-sections</samp>]
  145. [<samp>--elf-stt-common=<var>val</var></samp>]
  146. [<samp>--merge-notes</samp>]
  147. [<samp>--no-merge-notes</samp>]
  148. [<samp>--verilog-data-width=<var>val</var></samp>]
  149. [<samp>-v</samp>|<samp>--verbose</samp>]
  150. [<samp>-V</samp>|<samp>--version</samp>]
  151. [<samp>--help</samp>] [<samp>--info</samp>]
  152. <var>infile</var> [<var>outfile</var>]
  153. </pre></div>
  154. <p>The <small>GNU</small> <code>objcopy</code> utility copies the contents of an object
  155. file to another. <code>objcopy</code> uses the <small>GNU</small> <small>BFD</small> Library to
  156. read and write the object files. It can write the destination object
  157. file in a format different from that of the source object file. The
  158. exact behavior of <code>objcopy</code> is controlled by command-line options.
  159. Note that <code>objcopy</code> should be able to copy a fully linked file
  160. between any two formats. However, copying a relocatable object file
  161. between any two formats may not work as expected.
  162. </p>
  163. <p><code>objcopy</code> creates temporary files to do its translations and
  164. deletes them afterward. <code>objcopy</code> uses <small>BFD</small> to do all its
  165. translation work; it has access to all the formats described in <small>BFD</small>
  166. and thus is able to recognize most formats without being told
  167. explicitly. See <a href="http://sourceware.org/binutils/docs/ld/BFD.html#BFD">BFD</a> in <cite>Using LD</cite>.
  168. </p>
  169. <p><code>objcopy</code> can be used to generate S-records by using an output
  170. target of &lsquo;<samp>srec</samp>&rsquo; (e.g., use &lsquo;<samp>-O srec</samp>&rsquo;).
  171. </p>
  172. <p><code>objcopy</code> can be used to generate a raw binary file by using an
  173. output target of &lsquo;<samp>binary</samp>&rsquo; (e.g., use <samp>-O binary</samp>). When
  174. <code>objcopy</code> generates a raw binary file, it will essentially produce
  175. a memory dump of the contents of the input object file. All symbols and
  176. relocation information will be discarded. The memory dump will start at
  177. the load address of the lowest section copied into the output file.
  178. </p>
  179. <p>When generating an S-record or a raw binary file, it may be helpful to
  180. use <samp>-S</samp> to remove sections containing debugging information. In
  181. some cases <samp>-R</samp> will be useful to remove sections which contain
  182. information that is not needed by the binary file.
  183. </p>
  184. <p>Note&mdash;<code>objcopy</code> is not able to change the endianness of its input
  185. files. If the input format has an endianness (some formats do not),
  186. <code>objcopy</code> can only copy the inputs into file formats that have the
  187. same endianness or which have no endianness (e.g., &lsquo;<samp>srec</samp>&rsquo;).
  188. (However, see the <samp>--reverse-bytes</samp> option.)
  189. </p>
  190. <dl compact="compact">
  191. <dt><code><var>infile</var></code></dt>
  192. <dt><code><var>outfile</var></code></dt>
  193. <dd><p>The input and output files, respectively.
  194. If you do not specify <var>outfile</var>, <code>objcopy</code> creates a
  195. temporary file and destructively renames the result with
  196. the name of <var>infile</var>.
  197. </p>
  198. </dd>
  199. <dt><code>-I <var>bfdname</var></code></dt>
  200. <dt><code>--input-target=<var>bfdname</var></code></dt>
  201. <dd><p>Consider the source file&rsquo;s object format to be <var>bfdname</var>, rather than
  202. attempting to deduce it. See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information.
  203. </p>
  204. </dd>
  205. <dt><code>-O <var>bfdname</var></code></dt>
  206. <dt><code>--output-target=<var>bfdname</var></code></dt>
  207. <dd><p>Write the output file using the object format <var>bfdname</var>.
  208. See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information.
  209. </p>
  210. </dd>
  211. <dt><code>-F <var>bfdname</var></code></dt>
  212. <dt><code>--target=<var>bfdname</var></code></dt>
  213. <dd><p>Use <var>bfdname</var> as the object format for both the input and the output
  214. file; i.e., simply transfer data from source to destination with no
  215. translation. See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information.
  216. </p>
  217. </dd>
  218. <dt><code>-B <var>bfdarch</var></code></dt>
  219. <dt><code>--binary-architecture=<var>bfdarch</var></code></dt>
  220. <dd><p>Useful when transforming a architecture-less input file into an object file.
  221. In this case the output architecture can be set to <var>bfdarch</var>. This
  222. option will be ignored if the input file has a known <var>bfdarch</var>. You
  223. can access this binary data inside a program by referencing the special
  224. symbols that are created by the conversion process. These symbols are
  225. called _binary_<var>objfile</var>_start, _binary_<var>objfile</var>_end and
  226. _binary_<var>objfile</var>_size. e.g. you can transform a picture file into
  227. an object file and then access it in your code using these symbols.
  228. </p>
  229. </dd>
  230. <dt><code>-j <var>sectionpattern</var></code></dt>
  231. <dt><code>--only-section=<var>sectionpattern</var></code></dt>
  232. <dd><p>Copy only the indicated sections from the input file to the output file.
  233. This option may be given more than once. Note that using this option
  234. inappropriately may make the output file unusable. Wildcard
  235. characters are accepted in <var>sectionpattern</var>.
  236. </p>
  237. <p>If the first character of <var>sectionpattern</var> is the exclamation
  238. point (!) then matching sections will not be copied, even if earlier
  239. use of <samp>--only-section</samp> on the same command line would
  240. otherwise copy it. For example:
  241. </p>
  242. <div class="smallexample">
  243. <pre class="smallexample"> --only-section=.text.* --only-section=!.text.foo
  244. </pre></div>
  245. <p>will copy all sectinos maching &rsquo;.text.*&rsquo; but not the section
  246. &rsquo;.text.foo&rsquo;.
  247. </p>
  248. </dd>
  249. <dt><code>-R <var>sectionpattern</var></code></dt>
  250. <dt><code>--remove-section=<var>sectionpattern</var></code></dt>
  251. <dd><p>Remove any section matching <var>sectionpattern</var> from the output file.
  252. This option may be given more than once. Note that using this option
  253. inappropriately may make the output file unusable. Wildcard
  254. characters are accepted in <var>sectionpattern</var>. Using both the
  255. <samp>-j</samp> and <samp>-R</samp> options together results in undefined
  256. behaviour.
  257. </p>
  258. <p>If the first character of <var>sectionpattern</var> is the exclamation
  259. point (!) then matching sections will not be removed even if an
  260. earlier use of <samp>--remove-section</samp> on the same command line
  261. would otherwise remove it. For example:
  262. </p>
  263. <div class="smallexample">
  264. <pre class="smallexample"> --remove-section=.text.* --remove-section=!.text.foo
  265. </pre></div>
  266. <p>will remove all sections matching the pattern &rsquo;.text.*&rsquo;, but will not
  267. remove the section &rsquo;.text.foo&rsquo;.
  268. </p>
  269. </dd>
  270. <dt><code>--keep-section=<var>sectionpattern</var></code></dt>
  271. <dd><p>When removing sections from the output file, keep sections that match
  272. <var>sectionpattern</var>.
  273. </p>
  274. </dd>
  275. <dt><code>--remove-relocations=<var>sectionpattern</var></code></dt>
  276. <dd><p>Remove non-dynamic relocations from the output file for any section
  277. matching <var>sectionpattern</var>. This option may be given more than
  278. once. Note that using this option inappropriately may make the output
  279. file unusable, and attempting to remove a dynamic relocation section
  280. such as &lsquo;<samp>.rela.plt</samp>&rsquo; from an executable or shared library with
  281. <samp>--remove-relocations=.plt</samp> will not work. Wildcard characters
  282. are accepted in <var>sectionpattern</var>.
  283. For example:
  284. </p>
  285. <div class="smallexample">
  286. <pre class="smallexample"> --remove-relocations=.text.*
  287. </pre></div>
  288. <p>will remove the relocations for all sections matching the pattern
  289. &rsquo;.text.*&rsquo;.
  290. </p>
  291. <p>If the first character of <var>sectionpattern</var> is the exclamation
  292. point (!) then matching sections will not have their relocation
  293. removed even if an earlier use of <samp>--remove-relocations</samp> on the
  294. same command line would otherwise cause the relocations to be removed.
  295. For example:
  296. </p>
  297. <div class="smallexample">
  298. <pre class="smallexample"> --remove-relocations=.text.* --remove-relocations=!.text.foo
  299. </pre></div>
  300. <p>will remove all relocations for sections matching the pattern
  301. &rsquo;.text.*&rsquo;, but will not remove relocations for the section
  302. &rsquo;.text.foo&rsquo;.
  303. </p>
  304. </dd>
  305. <dt><code>-S</code></dt>
  306. <dt><code>--strip-all</code></dt>
  307. <dd><p>Do not copy relocation and symbol information from the source file.
  308. </p>
  309. </dd>
  310. <dt><code>-g</code></dt>
  311. <dt><code>--strip-debug</code></dt>
  312. <dd><p>Do not copy debugging symbols or sections from the source file.
  313. </p>
  314. </dd>
  315. <dt><code>--strip-unneeded</code></dt>
  316. <dd><p>Strip all symbols that are not needed for relocation processing.
  317. </p>
  318. </dd>
  319. <dt><code>-K <var>symbolname</var></code></dt>
  320. <dt><code>--keep-symbol=<var>symbolname</var></code></dt>
  321. <dd><p>When stripping symbols, keep symbol <var>symbolname</var> even if it would
  322. normally be stripped. This option may be given more than once.
  323. </p>
  324. </dd>
  325. <dt><code>-N <var>symbolname</var></code></dt>
  326. <dt><code>--strip-symbol=<var>symbolname</var></code></dt>
  327. <dd><p>Do not copy symbol <var>symbolname</var> from the source file. This option
  328. may be given more than once.
  329. </p>
  330. </dd>
  331. <dt><code>--strip-unneeded-symbol=<var>symbolname</var></code></dt>
  332. <dd><p>Do not copy symbol <var>symbolname</var> from the source file unless it is needed
  333. by a relocation. This option may be given more than once.
  334. </p>
  335. </dd>
  336. <dt><code>-G <var>symbolname</var></code></dt>
  337. <dt><code>--keep-global-symbol=<var>symbolname</var></code></dt>
  338. <dd><p>Keep only symbol <var>symbolname</var> global. Make all other symbols local
  339. to the file, so that they are not visible externally. This option may
  340. be given more than once. Note: this option cannot be used in
  341. conjunction with the <samp>--globalize-symbol</samp> or
  342. <samp>--globalize-symbols</samp> options.
  343. </p>
  344. </dd>
  345. <dt><code>--localize-hidden</code></dt>
  346. <dd><p>In an ELF object, mark all symbols that have hidden or internal visibility
  347. as local. This option applies on top of symbol-specific localization options
  348. such as <samp>-L</samp>.
  349. </p>
  350. </dd>
  351. <dt><code>-L <var>symbolname</var></code></dt>
  352. <dt><code>--localize-symbol=<var>symbolname</var></code></dt>
  353. <dd><p>Convert a global or weak symbol called <var>symbolname</var> into a local
  354. symbol, so that it is not visible externally. This option may be
  355. given more than once. Note - unique symbols are not converted.
  356. </p>
  357. </dd>
  358. <dt><code>-W <var>symbolname</var></code></dt>
  359. <dt><code>--weaken-symbol=<var>symbolname</var></code></dt>
  360. <dd><p>Make symbol <var>symbolname</var> weak. This option may be given more than once.
  361. </p>
  362. </dd>
  363. <dt><code>--globalize-symbol=<var>symbolname</var></code></dt>
  364. <dd><p>Give symbol <var>symbolname</var> global scoping so that it is visible
  365. outside of the file in which it is defined. This option may be given
  366. more than once. Note: this option cannot be used in conjunction with
  367. the <samp>-G</samp> or <samp>--keep-global-symbol</samp> options.
  368. </p>
  369. </dd>
  370. <dt><code>-w</code></dt>
  371. <dt><code>--wildcard</code></dt>
  372. <dd><p>Permit regular expressions in <var>symbolname</var>s used in other command
  373. line options. The question mark (?), asterisk (*), backslash (\) and
  374. square brackets ([]) operators can be used anywhere in the symbol
  375. name. If the first character of the symbol name is the exclamation
  376. point (!) then the sense of the switch is reversed for that symbol.
  377. For example:
  378. </p>
  379. <div class="smallexample">
  380. <pre class="smallexample"> -w -W !foo -W fo*
  381. </pre></div>
  382. <p>would cause objcopy to weaken all symbols that start with &ldquo;fo&rdquo;
  383. except for the symbol &ldquo;foo&rdquo;.
  384. </p>
  385. </dd>
  386. <dt><code>-x</code></dt>
  387. <dt><code>--discard-all</code></dt>
  388. <dd><p>Do not copy non-global symbols from the source file.
  389. </p>
  390. </dd>
  391. <dt><code>-X</code></dt>
  392. <dt><code>--discard-locals</code></dt>
  393. <dd><p>Do not copy compiler-generated local symbols.
  394. (These usually start with &lsquo;<samp>L</samp>&rsquo; or &lsquo;<samp>.</samp>&rsquo;.)
  395. </p>
  396. </dd>
  397. <dt><code>-b <var>byte</var></code></dt>
  398. <dt><code>--byte=<var>byte</var></code></dt>
  399. <dd><p>If interleaving has been enabled via the <samp>--interleave</samp> option
  400. then start the range of bytes to keep at the <var>byte</var>th byte.
  401. <var>byte</var> can be in the range from 0 to <var>breadth</var>-1, where
  402. <var>breadth</var> is the value given by the <samp>--interleave</samp> option.
  403. </p>
  404. </dd>
  405. <dt><code>-i [<var>breadth</var>]</code></dt>
  406. <dt><code>--interleave[=<var>breadth</var>]</code></dt>
  407. <dd><p>Only copy a range out of every <var>breadth</var> bytes. (Header data is
  408. not affected). Select which byte in the range begins the copy with
  409. the <samp>--byte</samp> option. Select the width of the range with the
  410. <samp>--interleave-width</samp> option.
  411. </p>
  412. <p>This option is useful for creating files to program <small>ROM</small>. It is
  413. typically used with an <code>srec</code> output target. Note that
  414. <code>objcopy</code> will complain if you do not specify the
  415. <samp>--byte</samp> option as well.
  416. </p>
  417. <p>The default interleave breadth is 4, so with <samp>--byte</samp> set to 0,
  418. <code>objcopy</code> would copy the first byte out of every four bytes
  419. from the input to the output.
  420. </p>
  421. </dd>
  422. <dt><code>--interleave-width=<var>width</var></code></dt>
  423. <dd><p>When used with the <samp>--interleave</samp> option, copy <var>width</var>
  424. bytes at a time. The start of the range of bytes to be copied is set
  425. by the <samp>--byte</samp> option, and the extent of the range is set with
  426. the <samp>--interleave</samp> option.
  427. </p>
  428. <p>The default value for this option is 1. The value of <var>width</var> plus
  429. the <var>byte</var> value set by the <samp>--byte</samp> option must not exceed
  430. the interleave breadth set by the <samp>--interleave</samp> option.
  431. </p>
  432. <p>This option can be used to create images for two 16-bit flashes interleaved
  433. in a 32-bit bus by passing <samp>-b 0 -i 4 --interleave-width=2</samp>
  434. and <samp>-b 2 -i 4 --interleave-width=2</samp> to two <code>objcopy</code>
  435. commands. If the input was &rsquo;12345678&rsquo; then the outputs would be
  436. &rsquo;1256&rsquo; and &rsquo;3478&rsquo; respectively.
  437. </p>
  438. </dd>
  439. <dt><code>-p</code></dt>
  440. <dt><code>--preserve-dates</code></dt>
  441. <dd><p>Set the access and modification dates of the output file to be the same
  442. as those of the input file.
  443. </p>
  444. </dd>
  445. <dt><code>-D</code></dt>
  446. <dt><code>--enable-deterministic-archives</code></dt>
  447. <dd><a name="index-deterministic-archives-2"></a>
  448. <a name="index-_002d_002denable_002ddeterministic_002darchives-2"></a>
  449. <p>Operate in <em>deterministic</em> mode. When copying archive members
  450. and writing the archive index, use zero for UIDs, GIDs, timestamps,
  451. and use consistent file modes for all files.
  452. </p>
  453. <p>If <samp>binutils</samp> was configured with
  454. <samp>--enable-deterministic-archives</samp>, then this mode is on by default.
  455. It can be disabled with the &lsquo;<samp>-U</samp>&rsquo; option, below.
  456. </p>
  457. </dd>
  458. <dt><code>-U</code></dt>
  459. <dt><code>--disable-deterministic-archives</code></dt>
  460. <dd><a name="index-deterministic-archives-3"></a>
  461. <a name="index-_002d_002denable_002ddeterministic_002darchives-3"></a>
  462. <p>Do <em>not</em> operate in <em>deterministic</em> mode. This is the
  463. inverse of the <samp>-D</samp> option, above: when copying archive members
  464. and writing the archive index, use their actual UID, GID, timestamp,
  465. and file mode values.
  466. </p>
  467. <p>This is the default unless <samp>binutils</samp> was configured with
  468. <samp>--enable-deterministic-archives</samp>.
  469. </p>
  470. </dd>
  471. <dt><code>--debugging</code></dt>
  472. <dd><p>Convert debugging information, if possible. This is not the default
  473. because only certain debugging formats are supported, and the
  474. conversion process can be time consuming.
  475. </p>
  476. </dd>
  477. <dt><code>--gap-fill <var>val</var></code></dt>
  478. <dd><p>Fill gaps between sections with <var>val</var>. This operation applies to
  479. the <em>load address</em> (LMA) of the sections. It is done by increasing
  480. the size of the section with the lower address, and filling in the extra
  481. space created with <var>val</var>.
  482. </p>
  483. </dd>
  484. <dt><code>--pad-to <var>address</var></code></dt>
  485. <dd><p>Pad the output file up to the load address <var>address</var>. This is
  486. done by increasing the size of the last section. The extra space is
  487. filled in with the value specified by <samp>--gap-fill</samp> (default zero).
  488. </p>
  489. </dd>
  490. <dt><code>--set-start <var>val</var></code></dt>
  491. <dd><p>Set the start address (also known as the entry address) of the new
  492. file to <var>val</var>. Not all object file formats support setting the
  493. start address.
  494. </p>
  495. </dd>
  496. <dt><code>--change-start <var>incr</var></code></dt>
  497. <dt><code>--adjust-start <var>incr</var></code></dt>
  498. <dd><a name="index-changing-start-address"></a>
  499. <p>Change the start address (also known as the entry address) by adding
  500. <var>incr</var>. Not all object file formats support setting the start
  501. address.
  502. </p>
  503. </dd>
  504. <dt><code>--change-addresses <var>incr</var></code></dt>
  505. <dt><code>--adjust-vma <var>incr</var></code></dt>
  506. <dd><a name="index-changing-object-addresses"></a>
  507. <p>Change the VMA and LMA addresses of all sections, as well as the start
  508. address, by adding <var>incr</var>. Some object file formats do not permit
  509. section addresses to be changed arbitrarily. Note that this does not
  510. relocate the sections; if the program expects sections to be loaded at a
  511. certain address, and this option is used to change the sections such
  512. that they are loaded at a different address, the program may fail.
  513. </p>
  514. </dd>
  515. <dt><code>--change-section-address <var>sectionpattern</var>{=,+,-}<var>val</var></code></dt>
  516. <dt><code>--adjust-section-vma <var>sectionpattern</var>{=,+,-}<var>val</var></code></dt>
  517. <dd><a name="index-changing-section-address"></a>
  518. <p>Set or change both the VMA address and the LMA address of any section
  519. matching <var>sectionpattern</var>. If &lsquo;<samp>=</samp>&rsquo; is used, the section
  520. address is set to <var>val</var>. Otherwise, <var>val</var> is added to or
  521. subtracted from the section address. See the comments under
  522. <samp>--change-addresses</samp>, above. If <var>sectionpattern</var> does not
  523. match any sections in the input file, a warning will be issued, unless
  524. <samp>--no-change-warnings</samp> is used.
  525. </p>
  526. </dd>
  527. <dt><code>--change-section-lma <var>sectionpattern</var>{=,+,-}<var>val</var></code></dt>
  528. <dd><a name="index-changing-section-LMA"></a>
  529. <p>Set or change the LMA address of any sections matching
  530. <var>sectionpattern</var>. The LMA address is the address where the
  531. section will be loaded into memory at program load time. Normally
  532. this is the same as the VMA address, which is the address of the
  533. section at program run time, but on some systems, especially those
  534. where a program is held in ROM, the two can be different. If &lsquo;<samp>=</samp>&rsquo;
  535. is used, the section address is set to <var>val</var>. Otherwise,
  536. <var>val</var> is added to or subtracted from the section address. See the
  537. comments under <samp>--change-addresses</samp>, above. If
  538. <var>sectionpattern</var> does not match any sections in the input file, a
  539. warning will be issued, unless <samp>--no-change-warnings</samp> is used.
  540. </p>
  541. </dd>
  542. <dt><code>--change-section-vma <var>sectionpattern</var>{=,+,-}<var>val</var></code></dt>
  543. <dd><a name="index-changing-section-VMA"></a>
  544. <p>Set or change the VMA address of any section matching
  545. <var>sectionpattern</var>. The VMA address is the address where the
  546. section will be located once the program has started executing.
  547. Normally this is the same as the LMA address, which is the address
  548. where the section will be loaded into memory, but on some systems,
  549. especially those where a program is held in ROM, the two can be
  550. different. If &lsquo;<samp>=</samp>&rsquo; is used, the section address is set to
  551. <var>val</var>. Otherwise, <var>val</var> is added to or subtracted from the
  552. section address. See the comments under <samp>--change-addresses</samp>,
  553. above. If <var>sectionpattern</var> does not match any sections in the
  554. input file, a warning will be issued, unless
  555. <samp>--no-change-warnings</samp> is used.
  556. </p>
  557. </dd>
  558. <dt><code>--change-warnings</code></dt>
  559. <dt><code>--adjust-warnings</code></dt>
  560. <dd><p>If <samp>--change-section-address</samp> or <samp>--change-section-lma</samp> or
  561. <samp>--change-section-vma</samp> is used, and the section pattern does not
  562. match any sections, issue a warning. This is the default.
  563. </p>
  564. </dd>
  565. <dt><code>--no-change-warnings</code></dt>
  566. <dt><code>--no-adjust-warnings</code></dt>
  567. <dd><p>Do not issue a warning if <samp>--change-section-address</samp> or
  568. <samp>--adjust-section-lma</samp> or <samp>--adjust-section-vma</samp> is used, even
  569. if the section pattern does not match any sections.
  570. </p>
  571. </dd>
  572. <dt><code>--set-section-flags <var>sectionpattern</var>=<var>flags</var></code></dt>
  573. <dd><p>Set the flags for any sections matching <var>sectionpattern</var>. The
  574. <var>flags</var> argument is a comma separated string of flag names. The
  575. recognized names are &lsquo;<samp>alloc</samp>&rsquo;, &lsquo;<samp>contents</samp>&rsquo;, &lsquo;<samp>load</samp>&rsquo;,
  576. &lsquo;<samp>noload</samp>&rsquo;, &lsquo;<samp>readonly</samp>&rsquo;, &lsquo;<samp>code</samp>&rsquo;, &lsquo;<samp>data</samp>&rsquo;, &lsquo;<samp>rom</samp>&rsquo;,
  577. &lsquo;<samp>exclude</samp>&rsquo;, &lsquo;<samp>share</samp>&rsquo;, and &lsquo;<samp>debug</samp>&rsquo;. You can set the
  578. &lsquo;<samp>contents</samp>&rsquo; flag for a section which does not have contents, but it
  579. is not meaningful to clear the &lsquo;<samp>contents</samp>&rsquo; flag of a section which
  580. does have contents&ndash;just remove the section instead. Not all flags are
  581. meaningful for all object file formats. In particular the
  582. &lsquo;<samp>share</samp>&rsquo; flag is only meaningful for COFF format files and not for
  583. ELF format files.
  584. </p>
  585. </dd>
  586. <dt><code>--set-section-alignment <var>sectionpattern</var>=<var>align</var></code></dt>
  587. <dd><p>Set the alignment for any sections matching <var>sectionpattern</var>.
  588. <var>align</var> specifies the alignment in bytes and must be a power of
  589. two, i.e. 1, 2, 4, 8&hellip;.
  590. </p>
  591. </dd>
  592. <dt><code>--add-section <var>sectionname</var>=<var>filename</var></code></dt>
  593. <dd><p>Add a new section named <var>sectionname</var> while copying the file. The
  594. contents of the new section are taken from the file <var>filename</var>. The
  595. size of the section will be the size of the file. This option only
  596. works on file formats which can support sections with arbitrary names.
  597. Note - it may be necessary to use the <samp>--set-section-flags</samp>
  598. option to set the attributes of the newly created section.
  599. </p>
  600. </dd>
  601. <dt><code>--dump-section <var>sectionname</var>=<var>filename</var></code></dt>
  602. <dd><p>Place the contents of section named <var>sectionname</var> into the file
  603. <var>filename</var>, overwriting any contents that may have been there
  604. previously. This option is the inverse of <samp>--add-section</samp>.
  605. This option is similar to the <samp>--only-section</samp> option except
  606. that it does not create a formatted file, it just dumps the contents
  607. as raw binary data, without applying any relocations. The option can
  608. be specified more than once.
  609. </p>
  610. </dd>
  611. <dt><code>--update-section <var>sectionname</var>=<var>filename</var></code></dt>
  612. <dd><p>Replace the existing contents of a section named <var>sectionname</var>
  613. with the contents of file <var>filename</var>. The size of the section
  614. will be adjusted to the size of the file. The section flags for
  615. <var>sectionname</var> will be unchanged. For ELF format files the section
  616. to segment mapping will also remain unchanged, something which is not
  617. possible using <samp>--remove-section</samp> followed by
  618. <samp>--add-section</samp>. The option can be specified more than once.
  619. </p>
  620. <p>Note - it is possible to use <samp>--rename-section</samp> and
  621. <samp>--update-section</samp> to both update and rename a section from one
  622. command line. In this case, pass the original section name to
  623. <samp>--update-section</samp>, and the original and new section names to
  624. <samp>--rename-section</samp>.
  625. </p>
  626. </dd>
  627. <dt><code>--add-symbol <var>name</var>=[<var>section</var>:]<var>value</var>[,<var>flags</var>]</code></dt>
  628. <dd><p>Add a new symbol named <var>name</var> while copying the file. This option may be
  629. specified multiple times. If the <var>section</var> is given, the symbol will be
  630. associated with and relative to that section, otherwise it will be an ABS
  631. symbol. Specifying an undefined section will result in a fatal error. There
  632. is no check for the value, it will be taken as specified. Symbol flags can
  633. be specified and not all flags will be meaningful for all object file
  634. formats. By default, the symbol will be global. The special flag
  635. &rsquo;before=<var>othersym</var>&rsquo; will insert the new symbol in front of the specified
  636. <var>othersym</var>, otherwise the symbol(s) will be added at the end of the
  637. symbol table in the order they appear.
  638. </p>
  639. </dd>
  640. <dt><code>--rename-section <var>oldname</var>=<var>newname</var>[,<var>flags</var>]</code></dt>
  641. <dd><p>Rename a section from <var>oldname</var> to <var>newname</var>, optionally
  642. changing the section&rsquo;s flags to <var>flags</var> in the process. This has
  643. the advantage over using a linker script to perform the rename in that
  644. the output stays as an object file and does not become a linked
  645. executable. This option accepts the same set of flags as the
  646. <samp>--sect-section-flags</samp> option.
  647. </p>
  648. <p>This option is particularly helpful when the input format is binary,
  649. since this will always create a section called .data. If for example,
  650. you wanted instead to create a section called .rodata containing binary
  651. data you could use the following command line to achieve it:
  652. </p>
  653. <div class="smallexample">
  654. <pre class="smallexample"> objcopy -I binary -O &lt;output_format&gt; -B &lt;architecture&gt; \
  655. --rename-section .data=.rodata,alloc,load,readonly,data,contents \
  656. &lt;input_binary_file&gt; &lt;output_object_file&gt;
  657. </pre></div>
  658. </dd>
  659. <dt><code>--long-section-names {enable,disable,keep}</code></dt>
  660. <dd><p>Controls the handling of long section names when processing <code>COFF</code>
  661. and <code>PE-COFF</code> object formats. The default behaviour, &lsquo;<samp>keep</samp>&rsquo;,
  662. is to preserve long section names if any are present in the input file.
  663. The &lsquo;<samp>enable</samp>&rsquo; and &lsquo;<samp>disable</samp>&rsquo; options forcibly enable or disable
  664. the use of long section names in the output object; when &lsquo;<samp>disable</samp>&rsquo;
  665. is in effect, any long section names in the input object will be truncated.
  666. The &lsquo;<samp>enable</samp>&rsquo; option will only emit long section names if any are
  667. present in the inputs; this is mostly the same as &lsquo;<samp>keep</samp>&rsquo;, but it
  668. is left undefined whether the &lsquo;<samp>enable</samp>&rsquo; option might force the
  669. creation of an empty string table in the output file.
  670. </p>
  671. </dd>
  672. <dt><code>--change-leading-char</code></dt>
  673. <dd><p>Some object file formats use special characters at the start of
  674. symbols. The most common such character is underscore, which compilers
  675. often add before every symbol. This option tells <code>objcopy</code> to
  676. change the leading character of every symbol when it converts between
  677. object file formats. If the object file formats use the same leading
  678. character, this option has no effect. Otherwise, it will add a
  679. character, or remove a character, or change a character, as
  680. appropriate.
  681. </p>
  682. </dd>
  683. <dt><code>--remove-leading-char</code></dt>
  684. <dd><p>If the first character of a global symbol is a special symbol leading
  685. character used by the object file format, remove the character. The
  686. most common symbol leading character is underscore. This option will
  687. remove a leading underscore from all global symbols. This can be useful
  688. if you want to link together objects of different file formats with
  689. different conventions for symbol names. This is different from
  690. <samp>--change-leading-char</samp> because it always changes the symbol name
  691. when appropriate, regardless of the object file format of the output
  692. file.
  693. </p>
  694. </dd>
  695. <dt><code>--reverse-bytes=<var>num</var></code></dt>
  696. <dd><p>Reverse the bytes in a section with output contents. A section length must
  697. be evenly divisible by the value given in order for the swap to be able to
  698. take place. Reversing takes place before the interleaving is performed.
  699. </p>
  700. <p>This option is used typically in generating ROM images for problematic
  701. target systems. For example, on some target boards, the 32-bit words
  702. fetched from 8-bit ROMs are re-assembled in little-endian byte order
  703. regardless of the CPU byte order. Depending on the programming model, the
  704. endianness of the ROM may need to be modified.
  705. </p>
  706. <p>Consider a simple file with a section containing the following eight
  707. bytes: <code>12345678</code>.
  708. </p>
  709. <p>Using &lsquo;<samp>--reverse-bytes=2</samp>&rsquo; for the above example, the bytes in the
  710. output file would be ordered <code>21436587</code>.
  711. </p>
  712. <p>Using &lsquo;<samp>--reverse-bytes=4</samp>&rsquo; for the above example, the bytes in the
  713. output file would be ordered <code>43218765</code>.
  714. </p>
  715. <p>By using &lsquo;<samp>--reverse-bytes=2</samp>&rsquo; for the above example, followed by
  716. &lsquo;<samp>--reverse-bytes=4</samp>&rsquo; on the output file, the bytes in the second
  717. output file would be ordered <code>34127856</code>.
  718. </p>
  719. </dd>
  720. <dt><code>--srec-len=<var>ival</var></code></dt>
  721. <dd><p>Meaningful only for srec output. Set the maximum length of the Srecords
  722. being produced to <var>ival</var>. This length covers both address, data and
  723. crc fields.
  724. </p>
  725. </dd>
  726. <dt><code>--srec-forceS3</code></dt>
  727. <dd><p>Meaningful only for srec output. Avoid generation of S1/S2 records,
  728. creating S3-only record format.
  729. </p>
  730. </dd>
  731. <dt><code>--redefine-sym <var>old</var>=<var>new</var></code></dt>
  732. <dd><p>Change the name of a symbol <var>old</var>, to <var>new</var>. This can be useful
  733. when one is trying link two things together for which you have no
  734. source, and there are name collisions.
  735. </p>
  736. </dd>
  737. <dt><code>--redefine-syms=<var>filename</var></code></dt>
  738. <dd><p>Apply <samp>--redefine-sym</samp> to each symbol pair &quot;<var>old</var> <var>new</var>&quot;
  739. listed in the file <var>filename</var>. <var>filename</var> is simply a flat file,
  740. with one symbol pair per line. Line comments may be introduced by the hash
  741. character. This option may be given more than once.
  742. </p>
  743. </dd>
  744. <dt><code>--weaken</code></dt>
  745. <dd><p>Change all global symbols in the file to be weak. This can be useful
  746. when building an object which will be linked against other objects using
  747. the <samp>-R</samp> option to the linker. This option is only effective when
  748. using an object file format which supports weak symbols.
  749. </p>
  750. </dd>
  751. <dt><code>--keep-symbols=<var>filename</var></code></dt>
  752. <dd><p>Apply <samp>--keep-symbol</samp> option to each symbol listed in the file
  753. <var>filename</var>. <var>filename</var> is simply a flat file, with one symbol
  754. name per line. Line comments may be introduced by the hash character.
  755. This option may be given more than once.
  756. </p>
  757. </dd>
  758. <dt><code>--strip-symbols=<var>filename</var></code></dt>
  759. <dd><p>Apply <samp>--strip-symbol</samp> option to each symbol listed in the file
  760. <var>filename</var>. <var>filename</var> is simply a flat file, with one symbol
  761. name per line. Line comments may be introduced by the hash character.
  762. This option may be given more than once.
  763. </p>
  764. </dd>
  765. <dt><code>--strip-unneeded-symbols=<var>filename</var></code></dt>
  766. <dd><p>Apply <samp>--strip-unneeded-symbol</samp> option to each symbol listed in
  767. the file <var>filename</var>. <var>filename</var> is simply a flat file, with one
  768. symbol name per line. Line comments may be introduced by the hash
  769. character. This option may be given more than once.
  770. </p>
  771. </dd>
  772. <dt><code>--keep-global-symbols=<var>filename</var></code></dt>
  773. <dd><p>Apply <samp>--keep-global-symbol</samp> option to each symbol listed in the
  774. file <var>filename</var>. <var>filename</var> is simply a flat file, with one
  775. symbol name per line. Line comments may be introduced by the hash
  776. character. This option may be given more than once.
  777. </p>
  778. </dd>
  779. <dt><code>--localize-symbols=<var>filename</var></code></dt>
  780. <dd><p>Apply <samp>--localize-symbol</samp> option to each symbol listed in the file
  781. <var>filename</var>. <var>filename</var> is simply a flat file, with one symbol
  782. name per line. Line comments may be introduced by the hash character.
  783. This option may be given more than once.
  784. </p>
  785. </dd>
  786. <dt><code>--globalize-symbols=<var>filename</var></code></dt>
  787. <dd><p>Apply <samp>--globalize-symbol</samp> option to each symbol listed in the file
  788. <var>filename</var>. <var>filename</var> is simply a flat file, with one symbol
  789. name per line. Line comments may be introduced by the hash character.
  790. This option may be given more than once. Note: this option cannot be
  791. used in conjunction with the <samp>-G</samp> or <samp>--keep-global-symbol</samp>
  792. options.
  793. </p>
  794. </dd>
  795. <dt><code>--weaken-symbols=<var>filename</var></code></dt>
  796. <dd><p>Apply <samp>--weaken-symbol</samp> option to each symbol listed in the file
  797. <var>filename</var>. <var>filename</var> is simply a flat file, with one symbol
  798. name per line. Line comments may be introduced by the hash character.
  799. This option may be given more than once.
  800. </p>
  801. </dd>
  802. <dt><code>--alt-machine-code=<var>index</var></code></dt>
  803. <dd><p>If the output architecture has alternate machine codes, use the
  804. <var>index</var>th code instead of the default one. This is useful in case
  805. a machine is assigned an official code and the tool-chain adopts the
  806. new code, but other applications still depend on the original code
  807. being used. For ELF based architectures if the <var>index</var>
  808. alternative does not exist then the value is treated as an absolute
  809. number to be stored in the e_machine field of the ELF header.
  810. </p>
  811. </dd>
  812. <dt><code>--writable-text</code></dt>
  813. <dd><p>Mark the output text as writable. This option isn&rsquo;t meaningful for all
  814. object file formats.
  815. </p>
  816. </dd>
  817. <dt><code>--readonly-text</code></dt>
  818. <dd><p>Make the output text write protected. This option isn&rsquo;t meaningful for all
  819. object file formats.
  820. </p>
  821. </dd>
  822. <dt><code>--pure</code></dt>
  823. <dd><p>Mark the output file as demand paged. This option isn&rsquo;t meaningful for all
  824. object file formats.
  825. </p>
  826. </dd>
  827. <dt><code>--impure</code></dt>
  828. <dd><p>Mark the output file as impure. This option isn&rsquo;t meaningful for all
  829. object file formats.
  830. </p>
  831. </dd>
  832. <dt><code>--prefix-symbols=<var>string</var></code></dt>
  833. <dd><p>Prefix all symbols in the output file with <var>string</var>.
  834. </p>
  835. </dd>
  836. <dt><code>--prefix-sections=<var>string</var></code></dt>
  837. <dd><p>Prefix all section names in the output file with <var>string</var>.
  838. </p>
  839. </dd>
  840. <dt><code>--prefix-alloc-sections=<var>string</var></code></dt>
  841. <dd><p>Prefix all the names of all allocated sections in the output file with
  842. <var>string</var>.
  843. </p>
  844. </dd>
  845. <dt><code>--add-gnu-debuglink=<var>path-to-file</var></code></dt>
  846. <dd><p>Creates a .gnu_debuglink section which contains a reference to
  847. <var>path-to-file</var> and adds it to the output file. Note: the file at
  848. <var>path-to-file</var> must exist. Part of the process of adding the
  849. .gnu_debuglink section involves embedding a checksum of the contents
  850. of the debug info file into the section.
  851. </p>
  852. <p>If the debug info file is built in one location but it is going to be
  853. installed at a later time into a different location then do not use
  854. the path to the installed location. The <samp>--add-gnu-debuglink</samp>
  855. option will fail because the installed file does not exist yet.
  856. Instead put the debug info file in the current directory and use the
  857. <samp>--add-gnu-debuglink</samp> option without any directory components,
  858. like this:
  859. </p>
  860. <div class="smallexample">
  861. <pre class="smallexample"> objcopy --add-gnu-debuglink=foo.debug
  862. </pre></div>
  863. <p>At debug time the debugger will attempt to look for the separate debug
  864. info file in a set of known locations. The exact set of these
  865. locations varies depending upon the distribution being used, but it
  866. typically includes:
  867. </p>
  868. <dl compact="compact">
  869. <dt><code>* The same directory as the executable.</code></dt>
  870. <dt><code>* A sub-directory of the directory containing the executable</code></dt>
  871. <dd><p>called .debug
  872. </p>
  873. </dd>
  874. <dt><code>* A global debug directory such as /usr/lib/debug.</code></dt>
  875. </dl>
  876. <p>As long as the debug info file has been installed into one of these
  877. locations before the debugger is run everything should work
  878. correctly.
  879. </p>
  880. </dd>
  881. <dt><code>--keep-file-symbols</code></dt>
  882. <dd><p>When stripping a file, perhaps with <samp>--strip-debug</samp> or
  883. <samp>--strip-unneeded</samp>, retain any symbols specifying source file names,
  884. which would otherwise get stripped.
  885. </p>
  886. </dd>
  887. <dt><code>--only-keep-debug</code></dt>
  888. <dd><p>Strip a file, removing contents of any sections that would not be
  889. stripped by <samp>--strip-debug</samp> and leaving the debugging sections
  890. intact. In ELF files, this preserves all note sections in the output.
  891. </p>
  892. <p>Note - the section headers of the stripped sections are preserved,
  893. including their sizes, but the contents of the section are discarded.
  894. The section headers are preserved so that other tools can match up the
  895. debuginfo file with the real executable, even if that executable has
  896. been relocated to a different address space.
  897. </p>
  898. <p>The intention is that this option will be used in conjunction with
  899. <samp>--add-gnu-debuglink</samp> to create a two part executable. One a
  900. stripped binary which will occupy less space in RAM and in a
  901. distribution and the second a debugging information file which is only
  902. needed if debugging abilities are required. The suggested procedure
  903. to create these files is as follows:
  904. </p>
  905. <ol>
  906. <li> Link the executable as normal. Assuming that it is called
  907. <code>foo</code> then...
  908. </li><li> Run <code>objcopy --only-keep-debug foo foo.dbg</code> to
  909. create a file containing the debugging info.
  910. </li><li> Run <code>objcopy --strip-debug foo</code> to create a
  911. stripped executable.
  912. </li><li> Run <code>objcopy --add-gnu-debuglink=foo.dbg foo</code>
  913. to add a link to the debugging info into the stripped executable.
  914. </li></ol>
  915. <p>Note&mdash;the choice of <code>.dbg</code> as an extension for the debug info
  916. file is arbitrary. Also the <code>--only-keep-debug</code> step is
  917. optional. You could instead do this:
  918. </p>
  919. <ol>
  920. <li> Link the executable as normal.
  921. </li><li> Copy <code>foo</code> to <code>foo.full</code>
  922. </li><li> Run <code>objcopy --strip-debug foo</code>
  923. </li><li> Run <code>objcopy --add-gnu-debuglink=foo.full foo</code>
  924. </li></ol>
  925. <p>i.e., the file pointed to by the <samp>--add-gnu-debuglink</samp> can be the
  926. full executable. It does not have to be a file created by the
  927. <samp>--only-keep-debug</samp> switch.
  928. </p>
  929. <p>Note&mdash;this switch is only intended for use on fully linked files. It
  930. does not make sense to use it on object files where the debugging
  931. information may be incomplete. Besides the gnu_debuglink feature
  932. currently only supports the presence of one filename containing
  933. debugging information, not multiple filenames on a one-per-object-file
  934. basis.
  935. </p>
  936. </dd>
  937. <dt><code>--strip-dwo</code></dt>
  938. <dd><p>Remove the contents of all DWARF .dwo sections, leaving the
  939. remaining debugging sections and all symbols intact.
  940. This option is intended for use by the compiler as part of
  941. the <samp>-gsplit-dwarf</samp> option, which splits debug information
  942. between the .o file and a separate .dwo file. The compiler
  943. generates all debug information in the same file, then uses
  944. the <samp>--extract-dwo</samp> option to copy the .dwo sections to
  945. the .dwo file, then the <samp>--strip-dwo</samp> option to remove
  946. those sections from the original .o file.
  947. </p>
  948. </dd>
  949. <dt><code>--extract-dwo</code></dt>
  950. <dd><p>Extract the contents of all DWARF .dwo sections. See the
  951. <samp>--strip-dwo</samp> option for more information.
  952. </p>
  953. </dd>
  954. <dt><code>--file-alignment <var>num</var></code></dt>
  955. <dd><p>Specify the file alignment. Sections in the file will always begin at
  956. file offsets which are multiples of this number. This defaults to
  957. 512.
  958. [This option is specific to PE targets.]
  959. </p>
  960. </dd>
  961. <dt><code>--heap <var>reserve</var></code></dt>
  962. <dt><code>--heap <var>reserve</var>,<var>commit</var></code></dt>
  963. <dd><p>Specify the number of bytes of memory to reserve (and optionally commit)
  964. to be used as heap for this program.
  965. [This option is specific to PE targets.]
  966. </p>
  967. </dd>
  968. <dt><code>--image-base <var>value</var></code></dt>
  969. <dd><p>Use <var>value</var> as the base address of your program or dll. This is
  970. the lowest memory location that will be used when your program or dll
  971. is loaded. To reduce the need to relocate and improve performance of
  972. your dlls, each should have a unique base address and not overlap any
  973. other dlls. The default is 0x400000 for executables, and 0x10000000
  974. for dlls.
  975. [This option is specific to PE targets.]
  976. </p>
  977. </dd>
  978. <dt><code>--section-alignment <var>num</var></code></dt>
  979. <dd><p>Sets the section alignment field in the PE header. Sections in memory
  980. will always begin at addresses which are a multiple of this number.
  981. Defaults to 0x1000.
  982. [This option is specific to PE targets.]
  983. </p>
  984. </dd>
  985. <dt><code>--stack <var>reserve</var></code></dt>
  986. <dt><code>--stack <var>reserve</var>,<var>commit</var></code></dt>
  987. <dd><p>Specify the number of bytes of memory to reserve (and optionally commit)
  988. to be used as stack for this program.
  989. [This option is specific to PE targets.]
  990. </p>
  991. </dd>
  992. <dt><code>--subsystem <var>which</var></code></dt>
  993. <dt><code>--subsystem <var>which</var>:<var>major</var></code></dt>
  994. <dt><code>--subsystem <var>which</var>:<var>major</var>.<var>minor</var></code></dt>
  995. <dd><p>Specifies the subsystem under which your program will execute. The
  996. legal values for <var>which</var> are <code>native</code>, <code>windows</code>,
  997. <code>console</code>, <code>posix</code>, <code>efi-app</code>, <code>efi-bsd</code>,
  998. <code>efi-rtd</code>, <code>sal-rtd</code>, and <code>xbox</code>. You may optionally set
  999. the subsystem version also. Numeric values are also accepted for
  1000. <var>which</var>.
  1001. [This option is specific to PE targets.]
  1002. </p>
  1003. </dd>
  1004. <dt><code>--extract-symbol</code></dt>
  1005. <dd><p>Keep the file&rsquo;s section flags and symbols but remove all section data.
  1006. Specifically, the option:
  1007. </p>
  1008. <ul>
  1009. <li> removes the contents of all sections;
  1010. </li><li> sets the size of every section to zero; and
  1011. </li><li> sets the file&rsquo;s start address to zero.
  1012. </li></ul>
  1013. <p>This option is used to build a <samp>.sym</samp> file for a VxWorks kernel.
  1014. It can also be a useful way of reducing the size of a <samp>--just-symbols</samp>
  1015. linker input file.
  1016. </p>
  1017. </dd>
  1018. <dt><code>--compress-debug-sections</code></dt>
  1019. <dd><p>Compress DWARF debug sections using zlib with SHF_COMPRESSED from the
  1020. ELF ABI. Note - if compression would actually make a section
  1021. <em>larger</em>, then it is not compressed.
  1022. </p>
  1023. </dd>
  1024. <dt><code>--compress-debug-sections=none</code></dt>
  1025. <dt><code>--compress-debug-sections=zlib</code></dt>
  1026. <dt><code>--compress-debug-sections=zlib-gnu</code></dt>
  1027. <dt><code>--compress-debug-sections=zlib-gabi</code></dt>
  1028. <dd><p>For ELF files, these options control how DWARF debug sections are
  1029. compressed. <samp>--compress-debug-sections=none</samp> is equivalent
  1030. to <samp>--decompress-debug-sections</samp>.
  1031. <samp>--compress-debug-sections=zlib</samp> and
  1032. <samp>--compress-debug-sections=zlib-gabi</samp> are equivalent to
  1033. <samp>--compress-debug-sections</samp>.
  1034. <samp>--compress-debug-sections=zlib-gnu</samp> compresses DWARF debug
  1035. sections using zlib. The debug sections are renamed to begin with
  1036. &lsquo;<samp>.zdebug</samp>&rsquo; instead of &lsquo;<samp>.debug</samp>&rsquo;. Note - if compression would
  1037. actually make a section <em>larger</em>, then it is not compressed nor
  1038. renamed.
  1039. </p>
  1040. </dd>
  1041. <dt><code>--decompress-debug-sections</code></dt>
  1042. <dd><p>Decompress DWARF debug sections using zlib. The original section
  1043. names of the compressed sections are restored.
  1044. </p>
  1045. </dd>
  1046. <dt><code>--elf-stt-common=yes</code></dt>
  1047. <dt><code>--elf-stt-common=no</code></dt>
  1048. <dd><p>For ELF files, these options control whether common symbols should be
  1049. converted to the <code>STT_COMMON</code> or <code>STT_OBJECT</code> type.
  1050. <samp>--elf-stt-common=yes</samp> converts common symbol type to
  1051. <code>STT_COMMON</code>. <samp>--elf-stt-common=no</samp> converts common symbol
  1052. type to <code>STT_OBJECT</code>.
  1053. </p>
  1054. </dd>
  1055. <dt><code>--merge-notes</code></dt>
  1056. <dt><code>--no-merge-notes</code></dt>
  1057. <dd><p>For ELF files, attempt (or do not attempt) to reduce the size of any
  1058. SHT_NOTE type sections by removing duplicate notes.
  1059. </p>
  1060. </dd>
  1061. <dt><code>-V</code></dt>
  1062. <dt><code>--version</code></dt>
  1063. <dd><p>Show the version number of <code>objcopy</code>.
  1064. </p>
  1065. </dd>
  1066. <dt><code>--verilog-data-width=<var>bytes</var></code></dt>
  1067. <dd><p>For Verilog output, this options controls the number of bytes
  1068. converted for each output data element. The input target controls the
  1069. endianness of the conversion.
  1070. </p>
  1071. </dd>
  1072. <dt><code>-v</code></dt>
  1073. <dt><code>--verbose</code></dt>
  1074. <dd><p>Verbose output: list all object files modified. In the case of
  1075. archives, &lsquo;<samp>objcopy -V</samp>&rsquo; lists all members of the archive.
  1076. </p>
  1077. </dd>
  1078. <dt><code>--help</code></dt>
  1079. <dd><p>Show a summary of the options to <code>objcopy</code>.
  1080. </p>
  1081. </dd>
  1082. <dt><code>--info</code></dt>
  1083. <dd><p>Display a list showing all architectures and object formats available.
  1084. </p></dd>
  1085. </dl>
  1086. <hr>
  1087. <div class="header">
  1088. <p>
  1089. Next: <a href="objdump.html#objdump" accesskey="n" rel="next">objdump</a>, Previous: <a href="nm.html#nm" accesskey="p" rel="prev">nm</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Binutils-Index.html#Binutils-Index" title="Index" rel="index">Index</a>]</p>
  1090. </div>
  1091. </body>
  1092. </html>