| 1 | .\" Copyright (c) 1991, 93, 94, 95, 96, 1997 Free Software Foundation |
| 2 | .\" See section COPYING for conditions for redistribution |
| 3 | .TH objcopy 1 "October 1994" "cygnus support" "GNU Development Tools" |
| 4 | .de BP |
| 5 | .sp |
| 6 | .ti \-.2i |
| 7 | \(** |
| 8 | .. |
| 9 | |
| 10 | .SH NAME |
| 11 | objcopy \- copy and translate object files |
| 12 | |
| 13 | .SH SYNOPSIS |
| 14 | .hy 0 |
| 15 | .na |
| 16 | .TP |
| 17 | .B objcopy |
| 18 | .RB "[\|" \-F\ \fIbfdname\fR\ |\ \fB\-\-target=\fIbfdname\fR "\|]" |
| 19 | .RB "[\|" \-I\ \fIbfdname\fR\ |\ \fB\-\-input\-target=\fIbfdname\fR "\|]" |
| 20 | .RB "[\|" \-O\ \fIbfdname\fR\ |\ \fB\-\-output\-target=\fIbfdname\fR "\|]" |
| 21 | .RB "[\|" \-R\ \fIsectionname\fR\ |\ \fB\-\-remove\-section=\fIsectionname\fR "\|]" |
| 22 | .RB "[\|" \-S\fR\ |\ \fB\-\-strip\-all\fR "\|]" |
| 23 | .RB "[\|" \-g\fR\ |\ \fB\-\-strip\-debug\fR "\|]" |
| 24 | .RB "[\|" \-\-strip\-unneeded\fR "\|]" |
| 25 | .RB "[\|" \-K\ \fIsymbolname\fR\ |\ \fB\-\-keep\-symbol=\fIsymbolname\fR "\|]" |
| 26 | .RB "[\|" \-N\ \fIsymbolname\fR\ |\ \fB\-\-strip\-symbol=\fIsymbolname\fR "\|]" |
| 27 | .RB "[\|" \-L\ \fIsymbolname\fR\ |\ \fB\-\-localize\-symbol=\fIsymbolname\fR "\|]" |
| 28 | .RB "[\|" \-W\ \fIsymbolname\fR\ |\ \fB\-\-weaken\-symbol=\fIsymbolname\fR "\|]" |
| 29 | .RB "[\|" \-x\fR\ |\ \fB\-\-discard\-all\fR "\|]" |
| 30 | .RB "[\|" \-X\fR\ |\ \fB\-\-discard\-locals\fR "\|]" |
| 31 | .RB "[\|" \-b\ \fIbyte\fR\ |\ \fB\-\-byte=\fIbyte\fR "\|]" |
| 32 | .RB "[\|" \-i\ \fIinterleave\fR\ |\ \fB\-\-interleave=\fIinterleave\fR "\|]" |
| 33 | .RB "[\|" \-p\fR\ |\ \fB\-\-preserve\-dates\fR "\|]" |
| 34 | .RB "[\|" \-\-debugging "\|]" |
| 35 | .RB "[\|" \-\-gap\-fill=\fIval\fR "\|]" |
| 36 | .RB "[\|" \-\-pad\-to=\fIaddress\fR "\|]" |
| 37 | .RB "[\|" \-\-set\-start=\fIval\fR "\|]" |
| 38 | .RB "[\|" \-\-adjust\-start=\fIincr\fR "\|]" |
| 39 | .RB "[\|" \-\-adjust\-vma=\fIincr\fR "\|]" |
| 40 | .RB "[\|" \-\-adjust\-section\-vma=\fIsection{=,+,-}val\fR "\|]" |
| 41 | .RB "[\|" \-\-adjust\-warnings\fR "\|]" |
| 42 | .RB "[\|" \-\-no\-adjust\-warnings\fR "\|]" |
| 43 | .RB "[\|" \-\-set\-section\-flags=\fIsection=flags\fR "\|]" |
| 44 | .RB "[\|" \-\-add\-section=\fIsectionname=filename\fR "\|]" |
| 45 | .RB "[\|" \-\-change\-leading\-char\fR "\|]" |
| 46 | .RB "[\|" \-\-remove\-leading\-char\fR "\|]" |
| 47 | .RB "[\|" \-\-weaken\fR "\|]" |
| 48 | .RB "[\|" \-v\ |\ \-\-verbose\fR "\|]" |
| 49 | .RB "[\|" \-V\ |\ \-\-version\fR "\|]" |
| 50 | .RB "[\|" \-\-help\fR "\|]" |
| 51 | .B infile |
| 52 | .RB "[\|" outfile\fR "\|]" |
| 53 | .SH DESCRIPTION |
| 54 | The GNU |
| 55 | .B objcopy |
| 56 | utility copies the contents of an object file to another. |
| 57 | .B objcopy |
| 58 | uses the GNU BFD Library to read and write the object files. It can |
| 59 | write the destination object file in a format different from that of |
| 60 | the source object file. The exact behavior of |
| 61 | .B objcopy |
| 62 | is controlled by command-line options. |
| 63 | .PP |
| 64 | .B objcopy |
| 65 | creates temporary files to do its translations and deletes them |
| 66 | afterward. |
| 67 | .B objcopy |
| 68 | uses BFD to do all its translation work; it knows about all the |
| 69 | formats BFD knows about, and thus is able to recognize most formats |
| 70 | without being told explicitly. |
| 71 | .PP |
| 72 | .B objcopy |
| 73 | can be used to generate S-records by using an output target of |
| 74 | .B srec |
| 75 | (e.g., use |
| 76 | .B -O srec). |
| 77 | .PP |
| 78 | .B objcopy |
| 79 | can be used to generate a raw binary file by using an output target of |
| 80 | .B binary |
| 81 | (e.g., use |
| 82 | .B -O binary). |
| 83 | When |
| 84 | .B objcopy |
| 85 | generates a raw binary file, it will essentially produce a memory dump |
| 86 | of the contents of the input object file. All symbols and relocation |
| 87 | information will be discarded. The memory dump will start at the |
| 88 | virtual address of the lowest section copied into the output file. |
| 89 | .PP |
| 90 | When generating an S-record or a raw binary file, it may be helpful to |
| 91 | use |
| 92 | .B -S |
| 93 | to remove sections containing debugging information. In some cases |
| 94 | .B -R |
| 95 | will be useful to remove sections which contain information which is |
| 96 | not needed by the binary file. |
| 97 | .PP |
| 98 | .I infile |
| 99 | and |
| 100 | .I outfile |
| 101 | are the source and output files respectively. If you do not specify |
| 102 | .IR outfile , |
| 103 | .B objcopy |
| 104 | creates a temporary file and destructively renames the result with the |
| 105 | name of the input file. |
| 106 | |
| 107 | .SH OPTIONS |
| 108 | .TP |
| 109 | .B \-I \fIbfdname\fR, \fB\-\-input\-target=\fIbfdname |
| 110 | Consider the source file's object format to be |
| 111 | .IR bfdname , |
| 112 | rather than attempting to deduce it. |
| 113 | .TP |
| 114 | .B \-O \fIbfdname\fR, \fB\-\-output\-target=\fIbfdname |
| 115 | Write the output file using the object format |
| 116 | .IR bfdname . |
| 117 | .TP |
| 118 | .B \-F \fIbfdname\fR, \fB\-\-target=\fIbfdname |
| 119 | Use |
| 120 | .I bfdname |
| 121 | as the object format for both the input and the output file; i.e. |
| 122 | simply transfer data from source to destination with no translation. |
| 123 | .TP |
| 124 | .B \-R \fIsectionname\fR, \fB\-\-remove-section=\fIsectionname |
| 125 | Remove the named section from the file. This option may be given more |
| 126 | than once. Note that using this option inappropriately may make the |
| 127 | output file unusable. |
| 128 | .TP |
| 129 | .B \-S\fR, \fB\-\-strip\-all |
| 130 | Do not copy relocation and symbol information from the source file. |
| 131 | .TP |
| 132 | .B \-g\fR, \fB\-\-strip\-debug |
| 133 | Do not copy debugging symbols from the source file. |
| 134 | .TP |
| 135 | .B \-\-strip\-unneeded |
| 136 | Strip all symbols that are not needed for relocation processing. |
| 137 | .TP |
| 138 | .B \-K \fIsymbolname\fR, \fB\-\-keep\-symbol=\fIsymbolname |
| 139 | Copy only symbol \fIsymbolname\fP from the source file. This option |
| 140 | may be given more than once. |
| 141 | .TP |
| 142 | .B \-N \fIsymbolname\fR, \fB\-\-strip\-symbol=\fIsymbolname |
| 143 | Do not copy symbol \fIsymbolname\fP from the source file. This option |
| 144 | may be given more than once. |
| 145 | .TP |
| 146 | .B \-L \fIsymbolname\fR, \fB\-\-localize\-symbol=\fIsymbolname |
| 147 | Make symbol \fIsymbolname\fP local to the file, so that it is not |
| 148 | visible externally. This option may be given more than once. |
| 149 | .TP |
| 150 | .B \-W \fIsymbolname\fR, \fB\-\-weaken\-symbol=\fIsymbolname |
| 151 | Make symbol \fIsymbolname\fP weak. This option may be given more than once. |
| 152 | .TP |
| 153 | .B \-x\fR, \fB \-\-discard\-all |
| 154 | Do not copy non-global symbols from the source file. |
| 155 | .TP |
| 156 | .B \-X\fR, \fB\-\-discard\-locals |
| 157 | Do not copy compiler-generated local symbols. (These usually start |
| 158 | with "L" or "."). |
| 159 | .TP |
| 160 | .B \-b \fIbyte\fR, \fB\-\-byte=\fIbyte |
| 161 | Keep only every \fIbyte\fPth byte of the input file (header data is |
| 162 | not affected). \fIbyte\fP can be in the range from 0 to the |
| 163 | interleave-1. This option is useful for creating files to program |
| 164 | ROMs. It is typically used with an srec output target. |
| 165 | .TP |
| 166 | .B \-i \fIinterleave\fR, \fB\-\-interleave=\fIinterleave |
| 167 | Only copy one out of every \fIinterleave\fP bytes. Which one to copy is |
| 168 | selected by the \fB\-b\fP or \fB\-\-byte\fP option. The default is 4. |
| 169 | The interleave is ignored if neither \fB\-b\fP nor \fB\-\-byte\fP is given. |
| 170 | .TP |
| 171 | .B \-p\fR, \fB\-\-preserve\-dates |
| 172 | Set the access and modification dates of the output file to be the same |
| 173 | as those of the input file. |
| 174 | .TP |
| 175 | .B \-\-debugging |
| 176 | Convert debugging information, if possible. This is not the default |
| 177 | because only certain debugging formats are supported, and the |
| 178 | conversion process can be time consuming. |
| 179 | .TP |
| 180 | .B \-\-gap\-fill=\fIval |
| 181 | Fill gaps between sections with \fIval\fP. This is done by increasing |
| 182 | the size of the section with the lower address, and filling in the extra |
| 183 | space created with \fIval\fP. |
| 184 | .TP |
| 185 | .B \-\-pad\-to=\fIaddress |
| 186 | Pad the output file up to the virtual address \fIaddress\fP. This is |
| 187 | done by increasing the size of the last section. The extra space is |
| 188 | filled in with the value specified by \fB\-\-gap\-fill\fP (default |
| 189 | zero). |
| 190 | .TP |
| 191 | .B \fB\-\-set\-start=\fIval |
| 192 | Set the start address of the new file to \fIval\fP. Not all object |
| 193 | file formats support setting the start address. |
| 194 | .TP |
| 195 | .B \fB\-\-adjust\-start=\fIincr |
| 196 | Adjust the start address by adding \fIincr\fP. Not all object file |
| 197 | formats support setting the start address. |
| 198 | .TP |
| 199 | .B \fB\-\-adjust\-vma=\fIincr |
| 200 | Adjust the address of all sections, as well as the start address, by |
| 201 | adding \fIincr\fP. Some object file formats do not permit section |
| 202 | addresses to be changed arbitrarily. Note that this does not relocate |
| 203 | the sections; if the program expects sections to be loaded at a |
| 204 | certain address, and this option is used to change the sections such |
| 205 | that they are loaded at a different address, the program may fail. |
| 206 | .TP |
| 207 | .B \fB\-\-adjust\-section\-vma=\fIsection{=,+,-}val |
| 208 | Set or adjust the address of the named \fIsection\fP. If \fI=\fP is |
| 209 | used, the section address is set to \fIval\fP. Otherwise, \fIval\fP |
| 210 | is added to or subtracted from the section address. See the comments |
| 211 | under \fB\-\-adjust\-vma\fP, above. If \fIsection\fP does not exist |
| 212 | in the input file, a warning will be issued, unless |
| 213 | \fB\-\-no\-adjust\-warnings\fP is used. |
| 214 | .TP |
| 215 | .B \fB\-\-adjust\-warnings |
| 216 | If \fB\-\-adjust\-section\-vma\fP is used, and the named section does |
| 217 | not exist, issue a warning. This is the default. |
| 218 | .TP |
| 219 | .B \fB\-\-no\-adjust\-warnings |
| 220 | Do not issue a warning if \fB\-\-adjust\-section\-vma\fP is used, even |
| 221 | if the named section does not exist. |
| 222 | .TP |
| 223 | .B \fB\-\-set\-section\-flags=\fIsection=flags |
| 224 | Set the flags for the named section. The \fIflags\fP argument is a |
| 225 | comma separated string of flag names. The recognized names are |
| 226 | \fIalloc\fP, \fIload\fP, \fIreadonly\fP, \fIcode\fP, \fIdata\fP, and |
| 227 | \fIrom\fP. Not all flags are meaningful for all object file |
| 228 | formats. |
| 229 | .TP |
| 230 | .B \fB\-\-add\-section=\fIsectionname=filename |
| 231 | Add a new section named \fIsectionname\fR while copying the file. The |
| 232 | contents of the new section are taken from the file \fIfilename\fR. |
| 233 | The size of the section will be the size of the file. This option |
| 234 | only works on file formats which can support sections with arbitrary |
| 235 | names. |
| 236 | .TP |
| 237 | .B \-\-change\-leading\-char |
| 238 | Some object file formats use special characters at the start of |
| 239 | symbols. The most common such character is underscore, which compilers |
| 240 | often add before every symbol. This option tells |
| 241 | .B objcopy |
| 242 | to change the leading character of every symbol when it converts |
| 243 | between object file formats. If the object file formats use the same |
| 244 | leading character, this option has no effect. Otherwise, it will add |
| 245 | a character, or remove a character, or change a character, as |
| 246 | appropriate. |
| 247 | .TP |
| 248 | .B \-\-remove\-leading\-char |
| 249 | If the first character of a global symbol is a special symbol leading |
| 250 | character used by the object file format, remove the character. The |
| 251 | most common symbol leading character is underscore. This option will |
| 252 | remove a leading underscore from all global symbols. This can be |
| 253 | useful if you want to link together objects of different file formats |
| 254 | with different conventions for symbol names. This is different from |
| 255 | @code{--change-leading-char} because it always changes the symbol name |
| 256 | when appropriate, regardless of the object file format of the output |
| 257 | .TP |
| 258 | .B \-\-weaken |
| 259 | Change all global symbols in the file to be weak. |
| 260 | .TP |
| 261 | .B \-v\fR, \fB\-\-verbose |
| 262 | Verbose output: list all object files modified. In the case of |
| 263 | archives, "\fBobjcopy \-V\fR" lists all members of the archive. |
| 264 | .TP |
| 265 | .B \-V\fR, \fB\-\-version |
| 266 | Show the version number of |
| 267 | .B objcopy |
| 268 | and exit. |
| 269 | .TP |
| 270 | .B \-\-help |
| 271 | Show a summary of the options to |
| 272 | .B objcopy |
| 273 | and exit. |
| 274 | .SH "SEE ALSO" |
| 275 | .RB "`\|" binutils "\|'" |
| 276 | entry in |
| 277 | .B |
| 278 | info\c |
| 279 | \&; |
| 280 | .I |
| 281 | The GNU Binary Utilities\c |
| 282 | \&, Roland H. Pesch (June 1993). |
| 283 | |
| 284 | .SH COPYING |
| 285 | Copyright (c) 1993, 94, 95, 96, 1997 Free Software Foundation, Inc. |
| 286 | .PP |
| 287 | Permission is granted to make and distribute verbatim copies of |
| 288 | this manual provided the copyright notice and this permission notice |
| 289 | are preserved on all copies. |
| 290 | .PP |
| 291 | Permission is granted to copy and distribute modified versions of this |
| 292 | manual under the conditions for verbatim copying, provided that the |
| 293 | entire resulting derived work is distributed under the terms of a |
| 294 | permission notice identical to this one. |
| 295 | .PP |
| 296 | Permission is granted to copy and distribute translations of this |
| 297 | manual into another language, under the above conditions for modified |
| 298 | versions, except that this permission notice may be included in |
| 299 | translations approved by the Free Software Foundation instead of in |
| 300 | the original English. |