2 .\" Man page generated from reStructuredText.
4 .TH "LLVM-OBJCOPY" "1" "2020-06-26" "10" "LLVM"
6 llvm-objcopy \- object copying and editing tool
8 .nr rst2man-indent-level 0
12 level \\n[rst2man-indent-level]
13 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
20 .\" .rstReportMargin pre:
22 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
23 . nr rst2man-indent-level +1
24 .\" .rstReportMargin post:
28 .\" indent \\n[an-margin]
29 .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
30 .nr rst2man-indent-level -1
31 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
32 .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
36 \fBllvm\-objcopy\fP [\fIoptions\fP] \fIinput\fP [\fIoutput\fP]
39 \fBllvm\-objcopy\fP is a tool to copy and manipulate objects. In basic
40 usage, it makes a semantic copy of the input to the output. If any options are
41 specified, the output may be modified along the way, e.g. by removing sections.
43 If no output file is specified, the input file is modified in\-place. If "\-" is
44 specified for the input file, the input is read from the program\(aqs standard
45 input stream. If "\-" is specified for the output file, the output is written to
46 the standard output stream of the program.
48 If the input is an archive, any requested operations will be applied to each
49 archive member individually.
51 The tool is still in active development, but in most scenarios it works as a
52 drop\-in replacement for GNU\(aqs \fBobjcopy\fP\&.
53 .SH GENERIC AND CROSS-PLATFORM OPTIONS
55 The following options are either agnostic of the file format, or apply to
56 multiple file formats.
59 .B \-\-add\-gnu\-debuglink <debug\-file>
60 Add a .gnu_debuglink section for \fB<debug\-file>\fP to the output.
64 .B \-\-add\-section <section=file>
65 Add a section named \fB<section>\fP with the contents of \fB<file>\fP to the
66 output. For ELF objects the section will be of type \fISHT_NOTE\fP, if the name
67 starts with ".note". Otherwise, it will have type \fISHT_PROGBITS\fP\&. Can be
68 specified multiple times to add multiple sections.
70 For MachO objects, \fB<section>\fP must be formatted as
71 \fB<segment name>,<section name>\fP\&.
75 .B \-\-binary\-architecture <arch>, \-B
76 Ignored for compatibility.
80 .B \-\-disable\-deterministic\-archives, \-U
81 Use real values for UIDs, GIDs and timestamps when updating archive member
86 .B \-\-discard\-all, \-x
87 Remove most local symbols from the output. Different file formats may limit
88 this to a subset of the local symbols. For example, file and section symbols in
89 ELF objects will not be discarded.
93 .B \-\-dump\-section <section>=<file>
94 Dump the contents of section \fB<section>\fP into the file \fB<file>\fP\&. Can be
95 specified multiple times to dump multiple sections to different files.
96 \fB<file>\fP is unrelated to the input and output files provided to
97 \fBllvm\-objcopy\fP and as such the normal copying and editing
98 operations will still be performed. No operations are performed on the sections
99 prior to dumping them.
101 For MachO objects, \fB<section>\fP must be formatted as
102 \fB<segment name>,<section name>\fP\&.
106 .B \-\-enable\-deterministic\-archives, \-D
107 Enable deterministic mode when copying archives, i.e. use 0 for archive member
108 header UIDs, GIDs and timestamp fields. On by default.
113 Print a summary of command line options.
117 .B \-\-only\-keep\-debug
118 Produce a debug file as the output that only preserves contents of sections
119 useful for debugging purposes.
121 For ELF objects, this removes the contents of \fISHF_ALLOC\fP sections that are not
122 \fISHT_NOTE\fP by making them \fISHT_NOBITS\fP and shrinking the program headers where
127 .B \-\-only\-section <section>, \-j
128 Remove all sections from the output, except for sections named \fB<section>\fP\&.
129 Can be specified multiple times to keep multiple sections.
131 For MachO objects, \fB<section>\fP must be formatted as
132 \fB<segment name>,<section name>\fP\&.
136 .B \-\-redefine\-sym <old>=<new>
137 Rename symbols called \fB<old>\fP to \fB<new>\fP in the output. Can be specified
138 multiple times to rename multiple symbols.
142 .B \-\-redefine\-syms <filename>
143 Rename symbols in the output as described in the file \fB<filename>\fP\&. In the
144 file, each line represents a single symbol to rename, with the old name and new
145 name separated by whitespace. Leading and trailing whitespace is ignored, as is
146 anything following a \(aq#\(aq. Can be specified multiple times to read names from
152 If specified, symbol and section names specified by other switches are treated
153 as extended POSIX regular expression patterns.
157 .B \-\-remove\-section <section>, \-R
158 Remove the specified section from the output. Can be specified multiple times
159 to remove multiple sections simultaneously.
161 For MachO objects, \fB<section>\fP must be formatted as
162 \fB<segment name>,<section name>\fP\&.
166 .B \-\-set\-section\-alignment <section>=<align>
167 Set the alignment of section \fB<section>\fP to \fI<align>\(ga\fP\&. Can be specified
168 multiple times to update multiple sections.
172 .B \-\-strip\-all\-gnu
173 Remove all symbols, debug sections and relocations from the output. This option
174 is equivalent to GNU \fBobjcopy\fP\(aqs \fB\-\-strip\-all\fP switch.
178 .B \-\-strip\-all, \-S
179 For ELF objects, remove from the output all symbols and non\-alloc sections not
180 within segments, except for .gnu.warning, .ARM.attribute sections and the
183 For COFF and Mach\-O objects, remove all symbols, debug sections, and
184 relocations from the output.
188 .B \-\-strip\-debug, \-g
189 Remove all debug sections from the output.
193 .B \-\-strip\-symbol <symbol>, \-N
194 Remove all symbols named \fB<symbol>\fP from the output. Can be specified
195 multiple times to remove multiple symbols.
199 .B \-\-strip\-symbols <filename>
200 Remove all symbols whose names appear in the file \fB<filename>\fP, from the
201 output. In the file, each line represents a single symbol name, with leading
202 and trailing whitespace ignored, as is anything following a \(aq#\(aq. Can be
203 specified multiple times to read names from multiple files.
207 .B \-\-strip\-unneeded\-symbol <symbol>
208 Remove from the output all symbols named \fB<symbol>\fP that are local or
209 undefined and are not required by any relocation.
213 .B \-\-strip\-unneeded\-symbols <filename>
214 Remove all symbols whose names appear in the file \fB<filename>\fP, from the
215 output, if they are local or undefined and are not required by any relocation.
216 In the file, each line represents a single symbol name, with leading and
217 trailing whitespace ignored, as is anything following a \(aq#\(aq. Can be specified
218 multiple times to read names from multiple files.
222 .B \-\-strip\-unneeded
223 Remove from the output all local or undefined symbols that are not required by
224 relocations. Also remove all debug sections.
229 Display the version of the \fBllvm\-objcopy\fP executable.
234 Read command\-line options and commands from response file \fI<FILE>\fP\&.
239 Allow wildcard syntax for symbol\-related flags. On by default for
240 section\-related flags. Incompatible with \-\-regex.
242 Wildcard syntax allows the following special symbols:
258 Any number of characters
274 Escape the next character
288 \fB[!a\-z]\fP, \fB[^a\-z]\fP
290 Negated character class
297 Additionally, starting a wildcard with \(aq!\(aq will prevent a match, even if
298 another flag matches. For example \fB\-w \-N \(aq*\(aq \-N \(aq!x\(aq\fP will strip all symbols
299 except for \fBx\fP\&.
301 The order of wildcards does not matter. For example, \fB\-w \-N \(aq*\(aq \-N \(aq!x\(aq\fP is
302 the same as \fB\-w \-N \(aq!x\(aq \-N \(aq*\(aq\fP\&.
304 .SH COFF-SPECIFIC OPTIONS
306 The following options are implemented only for COFF objects. If used with other
307 objects, \fBllvm\-objcopy\fP will either emit an error or silently ignore
309 .SH ELF-SPECIFIC OPTIONS
311 The following options are implemented only for ELF objects. If used with other
312 objects, \fBllvm\-objcopy\fP will either emit an error or silently ignore
316 .B \-\-add\-symbol <name>=[<section>:]<value>[,<flags>]
317 Add a new symbol called \fB<name>\fP to the output symbol table, in the section
318 named \fB<section>\fP, with value \fB<value>\fP\&. If \fB<section>\fP is not specified,
319 the symbol is added as an absolute symbol. The \fB<flags>\fP affect the symbol
320 properties. Accepted values are:
323 \fIglobal\fP = the symbol will have global binding.
325 \fIlocal\fP = the symbol will have local binding.
327 \fIweak\fP = the symbol will have weak binding.
329 \fIdefault\fP = the symbol will have default visibility.
331 \fIhidden\fP = the symbol will have hidden visibility.
333 \fIprotected\fP = the symbol will have protected visibility.
335 \fIfile\fP = the symbol will be an \fISTT_FILE\fP symbol.
337 \fIsection\fP = the symbol will be an \fISTT_SECTION\fP symbol.
339 \fIobject\fP = the symbol will be an \fISTT_OBJECT\fP symbol.
341 \fIfunction\fP = the symbol will be an \fISTT_FUNC\fP symbol.
343 \fIindirect\-function\fP = the symbol will be an \fISTT_GNU_IFUNC\fP symbol.
346 Additionally, the following flags are accepted but ignored: \fIdebug\fP,
347 \fIconstructor\fP, \fIwarning\fP, \fIindirect\fP, \fIsynthetic\fP, \fIunique\-object\fP, \fIbefore\fP\&.
349 Can be specified multiple times to add multiple symbols.
353 .B \-\-allow\-broken\-links
354 Allow \fBllvm\-objcopy\fP to remove sections even if it would leave invalid
355 section references. Any invalid sh_link fields will be set to zero.
359 .B \-\-build\-id\-link\-dir <dir>
360 Set the directory used by \fI\%\-\-build\-id\-link\-input\fP and
361 \fI\%\-\-build\-id\-link\-output\fP\&.
365 .B \-\-build\-id\-link\-input <suffix>
366 Hard\-link the input to \fB<dir>/xx/xxx<suffix>\fP, where \fB<dir>\fP is the directory
367 specified by \fI\%\-\-build\-id\-link\-dir\fP\&. The path used is derived from the
372 .B \-\-build\-id\-link\-output <suffix>
373 Hard\-link the output to \fB<dir>/xx/xxx<suffix>\fP, where \fB<dir>\fP is the directory
374 specified by \fI\%\-\-build\-id\-link\-dir\fP\&. The path used is derived from the
379 .B \-\-change\-start <incr>, \-\-adjust\-start
380 Add \fB<incr>\fP to the program\(aqs start address. Can be specified multiple
381 times, in which case the values will be applied cumulatively.
385 .B \-\-compress\-debug\-sections [<style>]
386 Compress DWARF debug sections in the output, using the specified style.
387 Supported styles are \fIzlib\-gnu\fP and \fIzlib\fP\&. Defaults to \fIzlib\fP if no style is
392 .B \-\-decompress\-debug\-sections
393 Decompress any compressed DWARF debug sections in the output.
397 .B \-\-discard\-locals, \-X
398 Remove local symbols starting with ".L" from the output.
403 Remove all sections that are not DWARF .dwo sections from the output.
407 .B \-\-extract\-main\-partition
408 Extract the main partition from the output.
412 .B \-\-extract\-partition <name>
413 Extract the named partition from the output.
417 .B \-\-globalize\-symbol <symbol>
418 Mark any defined symbols named \fB<symbol>\fP as global symbols in the output.
419 Can be specified multiple times to mark multiple symbols.
423 .B \-\-globalize\-symbols <filename>
424 Read a list of names from the file \fB<filename>\fP and mark defined symbols with
425 those names as global in the output. In the file, each line represents a single
426 symbol, with leading and trailing whitespace ignored, as is anything following
427 a \(aq#\(aq. Can be specified multiple times to read names from multiple files.
431 .B \-\-input\-target <format>, \-I
432 Read the input as the specified format. See \fI\%SUPPORTED FORMATS\fP for a list of
433 valid \fB<format>\fP values. If unspecified, \fBllvm\-objcopy\fP will attempt
434 to determine the format automatically.
438 .B \-\-keep\-file\-symbols
439 Keep symbols of type \fISTT_FILE\fP, even if they would otherwise be stripped.
443 .B \-\-keep\-global\-symbol <symbol>
444 Make all symbols local in the output, except for symbols with the name
445 \fB<symbol>\fP\&. Can be specified multiple times to ignore multiple symbols.
449 .B \-\-keep\-global\-symbols <filename>
450 Make all symbols local in the output, except for symbols named in the file
451 \fB<filename>\fP\&. In the file, each line represents a single symbol, with leading
452 and trailing whitespace ignored, as is anything following a \(aq#\(aq. Can be
453 specified multiple times to read names from multiple files.
457 .B \-\-keep\-section <section>
458 When removing sections from the output, do not remove sections named
459 \fB<section>\fP\&. Can be specified multiple times to keep multiple sections.
463 .B \-\-keep\-symbol <symbol>, \-K
464 When removing symbols from the output, do not remove symbols named
465 \fB<symbol>\fP\&. Can be specified multiple times to keep multiple symbols.
469 .B \-\-keep\-symbols <filename>
470 When removing symbols from the output do not remove symbols named in the file
471 \fB<filename>\fP\&. In the file, each line represents a single symbol, with leading
472 and trailing whitespace ignored, as is anything following a \(aq#\(aq. Can be
473 specified multiple times to read names from multiple files.
477 .B \-\-localize\-hidden
478 Make all symbols with hidden or internal visibility local in the output.
482 .B \-\-localize\-symbol <symbol>, \-L
483 Mark any defined non\-common symbol named \fB<symbol>\fP as a local symbol in the
484 output. Can be specified multiple times to mark multiple symbols as local.
488 .B \-\-localize\-symbols <filename>
489 Read a list of names from the file \fB<filename>\fP and mark defined non\-common
490 symbols with those names as local in the output. In the file, each line
491 represents a single symbol, with leading and trailing whitespace ignored, as is
492 anything following a \(aq#\(aq. Can be specified multiple times to read names from
497 .B \-\-new\-symbol\-visibility <visibility>
498 Specify the visibility of the symbols automatically created when using binary
499 input or \fI\%\-\-add\-symbol\fP\&. Valid options are:
511 The default is \fIdefault\fP\&.
515 .B \-\-output\-target <format>, \-O
516 Write the output as the specified format. See \fI\%SUPPORTED FORMATS\fP for a list
517 of valid \fB<format>\fP values. If unspecified, the output format is assumed to
518 be the same as the input file\(aqs format.
522 .B \-\-prefix\-alloc\-sections <prefix>
523 Add \fB<prefix>\fP to the front of the names of all allocatable sections in the
528 .B \-\-prefix\-symbols <prefix>
529 Add \fB<prefix>\fP to the front of every symbol name in the output.
533 .B \-\-preserve\-dates, \-p
534 Preserve access and modification timestamps in the output.
538 .B \-\-rename\-section <old>=<new>[,<flag>,...]
539 Rename sections called \fB<old>\fP to \fB<new>\fP in the output, and apply any
540 specified \fB<flag>\fP values. See \fI\%\-\-set\-section\-flags\fP for a list of
541 supported flags. Can be specified multiple times to rename multiple sections.
545 .B \-\-set\-section\-flags <section>=<flag>[,<flag>,...]
546 Set section properties in the output of section \fB<section>\fP based on the
547 specified \fB<flag>\fP values. Can be specified multiple times to update multiple
550 Following is a list of supported flags and their effects:
553 \fIalloc\fP = add the \fISHF_ALLOC\fP flag.
555 \fIload\fP = if the section has \fISHT_NOBITS\fP type, mark it as a \fISHT_PROGBITS\fP
558 \fIreadonly\fP = if this flag is not specified, add the \fISHF_WRITE\fP flag.
560 \fIcode\fP = add the \fISHF_EXECINSTR\fP flag.
562 \fImerge\fP = add the \fISHF_MERGE\fP flag.
564 \fIstrings\fP = add the \fISHF_STRINGS\fP flag.
566 \fIcontents\fP = if the section has \fISHT_NOBITS\fP type, mark it as a \fISHT_PROGBITS\fP
570 The following flags are also accepted, but are ignored for GNU compatibility:
571 \fInoload\fP, \fIdebug\fP, \fIdata\fP, \fIrom\fP, \fIshare\fP\&.
575 .B \-\-set\-start\-addr <addr>
576 Set the start address of the output to \fB<addr>\fP\&. Overrides any previously
577 specified \fI\%\-\-change\-start\fP or \fI\%\-\-adjust\-start\fP options.
581 .B \-\-split\-dwo <dwo\-file>
582 Equivalent to running \fBllvm\-objcopy\fP with \fI\%\-\-extract\-dwo\fP and
583 \fB<dwo\-file>\fP as the output file and no other options, and then with
584 \fI\%\-\-strip\-dwo\fP on the input file.
589 Remove all DWARF .dwo sections from the output.
593 .B \-\-strip\-non\-alloc
594 Remove from the output all non\-allocatable sections that are not within
599 .B \-\-strip\-sections
600 Remove from the output all section headers and all section data not within
601 segments. Note that many tools will not be able to use an object without
606 .B \-\-target <format>, \-F
607 Equivalent to \fI\%\-\-input\-target\fP and \fI\%\-\-output\-target\fP for the
608 specified format. See \fI\%SUPPORTED FORMATS\fP for a list of valid \fB<format>\fP
613 .B \-\-weaken\-symbol <symbol>, \-W
614 Mark any global symbol named \fB<symbol>\fP as a weak symbol in the output. Can
615 be specified multiple times to mark multiple symbols as weak.
619 .B \-\-weaken\-symbols <filename>
620 Read a list of names from the file \fB<filename>\fP and mark global symbols with
621 those names as weak in the output. In the file, each line represents a single
622 symbol, with leading and trailing whitespace ignored, as is anything following
623 a \(aq#\(aq. Can be specified multiple times to read names from multiple files.
628 Mark all defined global symbols as weak in the output.
630 .SH SUPPORTED FORMATS
632 The following values are currently supported by \fBllvm\-objcopy\fP for the
633 \fI\%\-\-input\-target\fP, \fI\%\-\-output\-target\fP, and \fI\%\-\-target\fP
634 options. For GNU \fBobjcopy\fP compatibility, the values are all bfdnames.
649 \fIelf32\-littlearm\fP
653 \fIelf64\-littleaarch64\fP
655 \fIelf32\-littleriscv\fP
657 \fIelf64\-littleriscv\fP
661 \fIelf32\-powerpcle\fP
665 \fIelf64\-powerpcle\fP
669 \fIelf32\-ntradbigmips\fP
671 \fIelf32\-ntradlittlemips\fP
673 \fIelf32\-tradbigmips\fP
675 \fIelf32\-tradlittlemips\fP
677 \fIelf64\-tradbigmips\fP
679 \fIelf64\-tradlittlemips\fP
686 Additionally, all targets except \fIbinary\fP and \fIihex\fP can have \fI\-freebsd\fP as a
688 .SH BINARY INPUT AND OUTPUT
690 If \fIbinary\fP is used as the value for \fI\%\-\-input\-target\fP, the input file
691 will be embedded as a data section in an ELF relocatable object, with symbols
692 \fB_binary_<file_name>_start\fP, \fB_binary_<file_name>_end\fP, and
693 \fB_binary_<file_name>_size\fP representing the start, end and size of the data,
694 where \fB<file_name>\fP is the path of the input file as specified on the command
695 line with non\-alphanumeric characters converted to \fB_\fP\&.
697 If \fIbinary\fP is used as the value for \fI\%\-\-output\-target\fP, the output file
698 will be a raw binary file, containing the memory image of the input file.
699 Symbols and relocation information will be discarded. The image will start at
700 the address of the first loadable section in the output.
703 \fBllvm\-objcopy\fP exits with a non\-zero exit code if there is an error.
704 Otherwise, it exits with code 0.
707 To report bugs, please visit <\fI\%http://llvm.org/bugs/\fP>.
709 There is a known issue with \fI\%\-\-input\-target\fP and \fI\%\-\-target\fP
710 causing only \fBbinary\fP and \fBihex\fP formats to have any effect. Other values
711 will be ignored and \fBllvm\-objcopy\fP will attempt to guess the input
717 Maintained by the LLVM Team (https://llvm.org/).
719 2003-2020, LLVM Project
720 .\" Generated by docutils manpage writer.