LLVM-OBJCOPY(1)

πŸ’– LLVM-OBJCOPY(1) πŸ’–

okay so this is the manual page for llvm-objcopy, from the LLVM crew. it's giving ✨object copying and editing tool✨ and honestly? it's a whole vibe. sit down bestie, we're doing this 🫢


🌸 NAME 🌸

llvm-objcopy β€” the object copying and editing tool. that's it, that's the girl. πŸ’…


✨ SYNOPSIS ✨

llvm-objcopy [options] input [output]

πŸ¦‹ DESCRIPTION πŸ¦‹

so llvm-objcopy is a tool to copy and manipulate objects. in basic usage, it makes a semantic copy of the input to the output. but the moment you pass any options, the output can get modified along the way β€” like, removing sections, that kinda thing. no cap. πŸ’–

if no output file is specified, the input file gets modified in-place. (yes, in place. it's giving "we're changing it where it lives", be careful bestie 😭)

if - is specified for the input file, the input is read from the program's standard input stream. if - is specified for the output file, the output is written to the standard output stream of the program. so like, pipes? iconic. 🌈

if the input is an archive, any requested operations get applied to each archive member individually. every single one. she's thorough. πŸ‘‘

ngl the tool is still in active development, but in most scenarios it works as a drop-in replacement for GNU's objcopy. slay.


πŸŽ€ GENERIC AND CROSS-PLATFORM OPTIONS πŸŽ€

these options are either agnostic of the file format, or they apply to multiple file formats. equal opportunity queen. πŸ’œ


  • --add-gnu-debuglink <debug-file> β€” adds a .gnu_debuglink section for <debug-file> to the output. cute lil breadcrumb trail back to your debug info πŸ“
  • --add-section <section=file> β€” adds a section named <section> with the contents of <file> to the output. for ELF objects the section will be of type SHT_NOTE if the name starts with .note. otherwise, it gets type SHT_PROGBITS. can be specified multiple times to add multiple sections. stack 'em up bestie πŸ“š

for MachO objects, <section> must be formatted as <segment name>,<section name>. don't forget the comma, it's non-negotiable πŸ’…

  • --binary-architecture <arch>, -B β€” ignored for compatibility. yeah she just sits there. hello queen, we see you, we don't use you πŸ™ˆ
  • --disable-deterministic-archives, -U β€” use real values for UIDs, GIDs and timestamps when updating archive member headers. like, actual real-world values, not the zeros. live a little πŸ”₯
  • --discard-all, -x β€” removes most local symbols not referenced by relocations from the output. different file formats may limit this to a subset of the local symbols. for example, file and section symbols in ELF objects will not be discarded. additionally, remove all debug sections. she's cleaning house and she's not sorry 🧹
  • --dump-section <section>=<file> β€” dumps the contents of section <section> into the file <file>. can be specified multiple times to dump multiple sections to different files. <file> is unrelated to the input and output files provided to llvm-objcopy and as such the normal copying and editing operations will still be performed. no operations are performed on the sections prior to dumping them. so like, raw. untouched. 🫢

for MachO objects, <section> must be formatted as <segment name>,<section name>.

  • --enable-deterministic-archives, -D β€” enable deterministic mode when copying archives, i.e. use 0 for archive member header UIDs, GIDs and timestamp fields. it's on by default, so she's already doing this unless you tell her otherwise. consistency queen ⭐
  • --extract-section <section>=<file> β€” extract the specified section <section> into the file <file> as a seperate object. can be specified multiple times to extract multiple sections. <file> is unrelated to the input and output files provided to llvm-objcopy and as such the normal copying and editing operations will still be performed. no operations are performed on the sections prior to dumping them. (and yes, "seperate" β€” we're quoting the original, we keep every letter, no editing the queen's spelling ✨)
  • --globalize-symbol <symbol> β€” mark any defined symbols named <symbol> as global symbols in the output. can be specified multiple times to mark multiple symbols. glow up time 🌟
  • --globalize-symbols <filename> β€” read a list of names from the file <filename> and mark defined symbols with those names as global in the output. in the file, each line represents a single symbol, with leading and trailing whitespace ignored, as is anything following a #. can be specified multiple times to read names from multiple files. bulk glow up, we love a shortcut πŸ“
  • --help, -h β€” print a summary of command line options. when in doubt, ask the queen herself πŸ’–
  • --keep-global-symbol <symbol>, -G β€” mark all symbols local in the output, except for symbols with the name <symbol>. can be specified multiple times to ignore multiple symbols. everyone's getting demoted except the chosen ones πŸ‘‘
  • --keep-global-symbols <filename> β€” mark all symbols local in the output, except for symbols named in the file <filename>. in the file, each line represents a single symbol, with leading and trailing whitespace ignored, as is anything following a #. can be specified multiple times to read names from multiple files. the VIP list, basically πŸ’…
  • --localize-symbol <symbol>, -L β€” mark any defined non-common symbol named <symbol> as a local symbol in the output. can be specified multiple times to mark multiple symbols as local. sorry babe, you're staying home 🏠
  • --localize-symbols <filename> β€” read a list of names from the file <filename> and mark defined non-common symbols with those names as local in the output. in the file, each line represents a single symbol, with leading and trailing whitespace ignored, as is anything following a #. can be specified multiple times to read names from multiple files.
  • --only-keep-debug β€” produce a debug file as the output that only preserves contents of sections useful for debugging purposes. it's giving ✨minimalist✨ but make it functional.

for ELF objects, this removes the contents of SHF_ALLOC sections that are not SHT_NOTE by making them SHT_NOBITS and shrinking the program headers where possible. (no cap, she really does all that.)

  • --only-section <section>, -j β€” remove all sections from the output, except for sections named <section>. can be specified multiple times to keep multiple sections. main character sections only, everyone else leave πŸ”₯

for MachO objects, <section> must be formatted as <segment name>,<section name>.

  • --redefine-sym <old>=<new> β€” rename symbols called <old> to <new> in the output. can be specified multiple times to rename multiple symbols. it's giving rebrand πŸ’–
  • --redefine-syms <filename> β€” rename symbols in the output as described in the file <filename>. in the file, each line represents a single symbol to rename, with the old name and new name separated by whitespace. leading and trailing whitespace is ignored, as is anything following a #. can be specified multiple times to read names from multiple files. mass rebrand, love that for her πŸŽ€
  • --regex β€” if specified, symbol and section names specified by other switches are treated as extended POSIX regular expression patterns. okay regex girlie, we see you 🌸
  • --remove-symbol-prefix <prefix> β€” remove <prefix> from the start of every symbol name. no-op for symbols that do not start with <prefix>. if you don't have the prefix, nothing happens, she's not gonna force it πŸ’œ
  • --remove-section <section>, -R β€” remove the specified section from the output. can be specified multiple times to remove multiple sections simultaneously. bye bestie, blocked 🚫

for MachO objects, <section> must be formatted as <segment name>,<section name>.

  • --set-section-alignment <section>=<align> β€” set the alignment of section <section> to <align>. can be specified multiple times to update multiple sections. alignment is self care ✨
  • --set-section-flags <section>=<flag>[,<flag>,...] β€” set section properties in the output of section <section> based on the specified <flag> values. can be specified multiple times to update multiple sections. flags are comma-separated, iykyk πŸ’…

supported flag names are alloc, load, noload, readonly, exclude, debug, code, data, rom, share, contents, merge, strings, and large. not all flags are meaningful for all object file formats or target architectures, so like, read the room 🫢

for ELF objects, the flags have the following effects:

  • alloc = add the SHF_ALLOC flag.
  • load = if the section has SHT_NOBITS type, mark it as a SHT_PROGBITS section.
  • readonly = if this flag is not specified, add the SHF_WRITE flag.
  • exclude = add the SHF_EXCLUDE flag.
  • code = add the SHF_EXECINSTR flag.
  • merge = add the SHF_MERGE flag.
  • strings = add the SHF_STRINGS flag.
  • contents = if the section has SHT_NOBITS type, mark it as a SHT_PROGBITS section.
  • large = add the SHF_X86_64_LARGE on x86_64; rejected if the target architecture is not x86_64. so don't try it, she will say no 😭

for COFF objects, the flags have the following effects:

  • alloc = add the IMAGE_SCN_CNT_UNINITIALIZED_DATA and IMAGE_SCN_MEM_READ flags, unless the load flag is specified.
  • noload = add the IMAGE_SCN_LNK_REMOVE and IMAGE_SCN_MEM_READ flags.
  • readonly = if this flag is not specified, add the IMAGE_SCN_MEM_WRITE flag.
  • exclude = add the IMAGE_SCN_LNK_REMOVE and IMAGE_SCN_MEM_READ flags.
  • debug = add the IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE and IMAGE_SCN_MEM_READ flags.
  • code = add the IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE and IMAGE_SCN_MEM_READ flags.
  • data = add the IMAGE_SCN_CNT_INITIALIZED_DATA and IMAGE_SCN_MEM_READ flags.
  • share = add the IMAGE_SCN_MEM_SHARED and IMAGE_SCN_MEM_READ flags.
  • --skip-symbol <symbol> β€” do not change the parameters of symbol <symbol> when executing other options that can change the symbol's name, binding or visibility. she's protected, hands off πŸ™ˆ
  • --skip-symbols <filename> β€” do not change the parameters of symbols named in the file <filename> when executing other options that can change the symbol's name, binding or visibility. in the file, each line represents a single symbol, with leading and trailing whitespace ignored, as is anything following a #. can be specified multiple times to read names from multiple files.
  • --strip-all-gnu β€” remove all symbols, debug sections and relocations from the output. this option is equivalent to GNU objcopy's --strip-all switch. she's a direct translation, fr fr πŸ’€
  • --strip-all, -S β€” for ELF objects, remove from the output all symbols and non-alloc sections not within segments, except for .gnu.warning, .ARM.attribute sections and the section name table.

for COFF and Mach-O objects, remove all symbols, debug sections, and relocations from the output. full reset, no leftovers πŸ”₯

  • --strip-debug, -g β€” remove all debug sections from the output. bye debug info, it was real πŸ¦‹
  • --strip-symbol <symbol>, -N β€” remove all symbols named <symbol> from the output. can be specified multiple times to remove multiple symbols. gone, deleted, never happened πŸ’…

more parts coming, don't go anywhere bestie πŸ’–

  • --strip-symbols <filename> β€” okay bestie, this one reads a file and removes every symbol whose name shows up in it from the output. In that file, each line is a single symbol name β€” leading and trailing whitespace gets ignored, and anything after a # gets ignored too. You can specify this multiple times to read names from multiple files. πŸ’…
  • --strip-unneeded-symbol <symbol> β€” removes from the output all symbols named <symbol>, but only if they’re local or undefined and no relocation needs them. Lowkey surgical. ✨
  • --strip-unneeded-symbols <filename> β€” same energy as above, but file-powered: removes all symbols whose names appear in <filename> from the output, if they’re local or undefined and not required by any relocation. Each line is one symbol name, leading and trailing whitespace ignored, and anything after # ignored. Can be specified multiple times to read names from multiple files. πŸŽ€
  • --strip-unneeded β€” removes from the output all local or undefined symbols that relocations don’t need. Also removes all debug sections. It’s giving cleanup era. πŸ’€
  • --update-section <name>=<file> β€” replaces the contents of section <name> with contents from the file <file>. If section <name> is part of a segment, the new contents cannot be larger than the existing section. So don’t try to make it bigger, bestie. 🫢
  • --version, -V β€” displays the version of the llvm-objcopy executable. Iconic. πŸ‘‘
  • --wildcard, -w β€” allows wildcard syntax for symbol-related flags. On by default for section-related flags. Incompatible with --regex. No cap.

Wildcard syntax allows the following special symbols:

  • * β€” any number of characters, equivalent to .*
  • ? β€” any single character, equivalent to .
  • \ β€” escape the next character, equivalent to \
  • [a-z] β€” character class, equivalent to [a-z]
  • [!a-z], [^a-z] β€” negated character class, equivalent to [^a-z]

Additionally, starting a wildcard with ! will prevent a match, even if another flag matches. For example, -w -N '*' -N '!x' will strip all symbols except for x.

The order of wildcards does not matter. For example, -w -N '*' -N '!x' is the same as -w -N '!x' -N '*'.

  • @<FILE> β€” reads command-line options and commands from response file <FILE>. It’s the β€œbestie, I wrote it down for you” move. 🌸

ELF-SPECIFIC OPTIONS πŸ’–

okay bestie, these options are ELF-only. They're giving ELF-only main character energy, but if you use them with other object types, llvm-objcopy will either emit an error or just silently ignore them. So vibe check your file format first, fr fr. iykyk.


  • --add-symbol <name>=[<section>:]<value>[,<flags>] β€” Add a new symbol called <name> to the output symbol table, in the section named <section>, with value <value>. If <section> is not specified, the symbol is added as an absolute symbol. The <flags> affect the symbol properties. Accepted values are:
    • global = the symbol will have global binding.
    • local = the symbol will have local binding.
    • weak = the symbol will have weak binding.
    • default = the symbol will have default visibility.
    • hidden = the symbol will have hidden visibility.
    • protected = the symbol will have protected visibility.
    • file = the symbol will be an STT_FILE symbol.
    • section = the symbol will be an STT_SECTION symbol.
    • object = the symbol will be an STT_OBJECT symbol.
    • function = the symbol will be an STT_FUNC symbol.
    • indirect-function = the symbol will be an STT_GNU_IFUNC symbol.

Additionally, the following flags are accepted but ignored: debug, constructor, warning, indirect, synthetic, unique-object, before.

Can be specified multiple times to add multiple symbols. slay.

  • --allow-broken-links β€” Allow llvm-objcopy to remove sections even if it would leave invalid section references. Any invalid sh_link fields will be set to zero.
  • --change-section-lma \*{+-}<val> β€” Shift LMA of non-zero-sized segments by <val>.
  • --change-section-address <section>{=+-}<val>, --adjust-section-vma β€” Change the address of sections that match <section> pattern to the specified value, or apply +<val>/-<val> to the current value. Can be specified multiple times to specify multiple patterns. Each section is only modified by one --change-section-address argument. If a section name matches multiple patterns, the rightmost change applies. The object file needs to be of ET_REL type. no cap.
  • --change-start <incr>, --adjust-start β€” Add <incr> to the program's start address. Can be specified multiple times, in which case the values will be applied cumulatively.
  • --compress-debug-sections [<format>] β€” Compress DWARF debug sections in the output, using the specified format. Supported formats are zlib and zstd. Use zlib if <format> is omitted.
  • --compress-sections <section>=<format> β€” Compress or decompress sections matched by <section> using the specified format. Supported formats are zlib and zstd. Specify none for decompression. When a section is matched by multiple options, the last one wins. A wildcard <section> starting with '!' is disallowed. Sections within a segment cannot be (de)compressed. πŸ’€
  • --decompress-debug-sections β€” Decompress any compressed DWARF debug sections in the output.
  • --discard-locals, -X β€” Remove local symbols starting with ".L" not referenced by relocations from the output.
  • --extract-dwo β€” Remove all sections that are not DWARF .dwo sections from the output.
  • --extract-main-partition β€” Extract the main partition from the output.
  • --extract-partition <name> β€” Extract the named partition from the output.
  • --gap-fill <value> β€” For binary outputs, fill the gaps between sections with <value> instead of zero. The value must be an unsigned 8-bit integer.
  • --input-target <format>, -I β€” Read the input as the specified format. See SUPPORTED FORMATS for a list of valid <format> values. If unspecified, llvm-objcopy will attempt to determine the format automatically.
  • --keep-file-symbols β€” Keep symbols of type STT_FILE, even if they would otherwise be stripped.
  • --keep-section <section> β€” When removing sections from the output, do not remove sections named <section>. Can be specified multiple times to keep multiple sections.
  • --keep-symbol <symbol>, -K β€” When removing symbols from the output, do not remove symbols named <symbol>. Can be specified multiple times to keep multiple symbols.
  • --keep-symbols <filename> β€” When removing symbols from the output do not remove symbols named in the file <filename>. In the file, each line represents a single symbol, with leading and trailing whitespace ignored, as is anything following a '#'. Can be specified multiple times to read names from multiple files.
  • --localize-hidden β€” Mark all symbols with hidden or internal visibility local in the output.
  • --new-symbol-visibility <visibility> β€” Specify the visibility of the symbols automatically created when using binary input or --add-symbol. Valid options are:
    • default
    • hidden
    • internal
    • protected

The default is default. periodt.

  • --no-verify-note-sections β€” When adding note sections, do not verify if the section format is valid.
  • --output-target <format>, -O β€” Write the output as the specified format. See SUPPORTED FORMATS for a list of valid <format> values. If unspecified, the output format is assumed to be the same as the value specified for --input-target or the input file's format if that option is also unspecified.
  • --pad-to <address> β€” For binary outputs, pad the output to the load address <address> using a value of zero or the value specified by --gap-fill.
  • --prefix-alloc-sections <prefix> β€” Add <prefix> to the front of the names of all allocatable sections in the output.
  • --prefix-symbols <prefix> β€” Add <prefix> to the front of every symbol name in the output.
  • --preserve-dates, -p β€” Preserve access and modification timestamps in the output.
  • --remove-note [<name>/]<type> β€” Remove notes of integer type <type> and name <name> from SHT_NOTE sections that are not in a segment. Can be specified multiple times.
  • --rename-section <old>=<new>[,<flag>,...] β€” Rename sections called <old> to <new> in the output, and apply any specified <flag> values. See --set-section-flags for a list of supported flags. Can be specified multiple times to rename multiple sections.
  • --set-section-type <section>=<type> β€” Set the type of section <section> to the integer <type>. Can be specified multiple times to update multiple sections.
  • --set-start <addr> β€” Set the start address of the output to <addr>. Overrides any previously specified --change-start or --adjust-start options.
  • --set-symbol-visibility <symbol>=<visibility> β€” Change the visibility of a symbol to the specified value.
  • --set-symbols-visibility <filename>=<visibility> β€” Read a list of symbols from <filename> and change their visibility to the specified value. Visibility values: default, internal, hidden, protected.
  • --split-dwo <dwo-file> β€” Equivalent to running llvm-objcopy with --extract-dwo and <dwo-file> as the output file and no other options, and then with --strip-dwo on the input file.
  • --strip-dwo β€” Remove all DWARF .dwo sections from the output.
  • --strip-non-alloc β€” Remove from the output all non-allocatable sections that are not within segments.
  • --strip-sections β€” Remove from the output all section headers and all section data not within segments. Note that many tools will not be able to use an object without section headers. πŸ’€
  • --target <format>, -F β€” Equivalent to --input-target and --output-target for the specified format. See SUPPORTED FORMATS for a list of valid <format> values.
  • --verify-note-sections β€” When adding note sections, verify if the section format is valid. On by default.
  • --weaken-symbol <symbol>, -W β€” Mark global symbols named <symbol> as weak symbols in the output. Can be specified multiple times to mark multiple symbols as weak.
  • --weaken-symbols <filename> β€” Read a list of names from the file <filename> and mark global symbols with those names as weak in the output. In the file, each line represents a single symbol, with leading and trailing whitespace ignored, as is anything following a '#'. Can be specified multiple times to read names from multiple files.
  • --weaken β€” Mark all defined global symbols as weak in the output.

MACH-O-SPECIFIC OPTIONS πŸ¦‹

okay Mach-O besties, this one is short and sweet.

  • --keep-undefined β€” Keep undefined symbols, even if they would otherwise be stripped.

COFF-SPECIFIC OPTIONS πŸŽ€

  • --subsystem <name>[:<version>] β€” Set the PE subsystem, and optionally subsystem version.

SUPPORTED FORMATS 🌈

The following values are currently supported by llvm-objcopy for the --input-target, --output-target, and --target options. For GNU objcopy compatibility, the values are all bfdnames.

  • binary
  • ihex
  • elf32-i386
  • elf32-x86-64
  • elf64-x86-64
  • elf32-iamcu
  • elf32-littlearm
  • elf64-aarch64
  • elf64-littleaarch64
  • elf32-littleriscv
  • elf64-littleriscv
  • elf32-powerpc
  • elf32-powerpcle
  • elf64-powerpc
  • elf64-powerpcle
  • elf32-bigmips
  • elf32-ntradbigmips
  • elf32-ntradlittlemips
  • elf32-tradbigmips
  • elf32-tradlittlemips
  • elf64-tradbigmips
  • elf64-tradlittlemips
  • elf32-sparc
  • elf32-sparcel
  • elf32-hexagon
  • elf32-loongarch
  • elf64-loongarch
  • elf64-s390

The following formats are supported by llvm-objcopy for the --output-target only:

  • srec

Additionally, all targets except binary, ihex, and srec can have -freebsd as a suffix. periodt.

🫢 BINARY INPUT AND OUTPUT 🫢

Okay bestie, this part is lowkey the ✨magic trick✨ of the whole page, so lock in.

  • If you use binary as the value for --input-target, your input file gets embedded as a data section in an ELF relocatable object. And because you need to find that data later, it comes with three symbols:
    • _binary_<file_name>_start β€” where the data begins πŸ‘‘
    • _binary_<file_name>_end β€” where the data ends πŸŽ€
    • _binary_<file_name>_size β€” how big the data is πŸ’…

And <file_name> here is the path of the input file exactly as you wrote it on the command line, except every non-alphanumeric character gets converted to _. Yes, even that. It's giving "sanitized for the compiler's convenience," and honestly? Slay.

  • If you use binary as the value for --output-target instead, the output file is a raw binary file containing the memory image of the input file. Heads up though:
    • Symbols and relocation information will be discarded. Gone. Bye. πŸ’€
    • The image starts at the address of the first loadable section in the output. Not zero, not the ELF header, the first loadable section. Periodt.

🌈 EXIT STATUS 🌈

Not me caring about exit codes, but like, scripts need to know:

  • llvm-objcopy exits with a non-zero exit code if there is an error 😭
  • Otherwise, it exits with code 0 ✨ (the good ending)

πŸ’€ BUGS πŸ’€

Found something cursed? To report bugs, please visit https://github.com/llvm/llvm-project/labels/tools:llvm-objcopy/strip/. The devs are genuinely so nice, go tell them 🫢

⚠️ There's a known issue with --input-target and --target causing only binary and ihex formats to have any effect. Every other value gets ignored and llvm-objcopy will attempt to guess the input format instead. So like… it's vibes-based detection at that point. No cap.

πŸ‘‘ SEE ALSO πŸ‘‘

Your other bestie, obviously:


πŸ¦‹ Author πŸ¦‹

Maintained by the LLVM Team (https://llvm.org/). Icons only.

2003-2026, LLVM Project. The way they've been keeping this thing alive for two decades-plus?? Main character energy fr fr.


And that's the whole page, babe πŸ’… This was LLVM-OBJCOPY(1), page 22, dated 2026-07-16. Go forth and copy objects responsibly πŸŒΈβœ¨πŸ¦‹

πŸ“¦ where this page comes from