LLVM-OBJCOPY(1)

πŸ“¦ version 23.1.3, in centos-stream 9

πŸ¦‹ LLVM-OBJCOPY(1) β€” the llvm-objcopy glow-up πŸ¦‹

part 1 of the LLVM manual, but make it group chat


✨ NAME ✨

llvm-objcopy β€” the object copying and editing tool, aka the icon that copies your object files and edits them on the way through πŸ’…


🌸 SYNOPSIS 🌸

llvm-objcopy [options] input [output]

πŸŽ€ DESCRIPTION πŸŽ€

okay so bestie, llvm-objcopy is a tool to copy and manipulate objects. In basic usage, she makes a semantic copy of the input to the output. Fr fr, that's it. But the moment you throw any options at her, the output may be modified along the way β€” like, say, by removing sections. Main character energy: she doesn't just copy, she curates πŸ’–

If no output file is specified, the input file is modified in-place. (Yes, in-place. She's editing the original. Handle with care, ngl πŸ™ˆ) 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. Stdin and stdout, we love a flexible queen ✨

If the input is an archive, any requested operations will be applied to each archive member individually. Every member gets the treatment, no member left behind 🫢

real talk: the tool is still in active development, but in most scenarios it works as a drop-in replacement for GNU's objcopy. So like… highkey usable, lowkey still growing 🌱

⭐ GENERIC AND CROSS-PLATFORM OPTIONS ⭐

The following options are either agnostic of the file format, or apply to multiple file formats. Equal opportunity options, we stan 🌈

  • --add-gnu-debuglink <debug-file> β€” Add a .gnu_debuglink section for <debug-file> to the output. Little forwarding address for your debug info πŸŽ€
  • --add-section <section=file> β€” Add 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 will have type SHT_PROGBITS. Can be specified multiple times to add multiple sections. (Stack 'em, bestie.)

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

  • --binary-architecture <arch>, -B β€” Ignored for compatibility. She's literally just standing there being a vibe, bless πŸ’€
  • --disable-deterministic-archives, -U β€” Use real values for UIDs, GIDs and timestamps when updating archive member headers. Chaotic mode: ON. She's using the actual real-world numbers, no cap πŸ”₯
  • --discard-all, -x β€” Remove 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. Bye bestie, you will not be missed πŸ’¨
  • --dump-section <section>=<file> β€” Dump 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, the dump is the raw tea, 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. On by default. Consistency queen, always on her grind πŸ‘‘
  • --extract-section <section>=<file> β€” Extract the specified section <section> into the file <file> as a seperate object. (that's the manpage's spelling, not mine 😭) 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.
  • --globalize-symbol <symbol> β€” Mark any defined symbols named <symbol> as global symbols in the output. Can be specified multiple times to mark multiple symbols. Give them the spotlight, they earned it ⭐
  • --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. Batch glow-up πŸ¦‹
  • --help, -h β€” Print a summary of command line options. The classic "what do you even do" button πŸ’–
  • --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 a local now except the chosen ones, iykyk ✨
  • --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.
  • --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. Your fave has been humbled, respectfully πŸ™ˆ
  • --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. Just the debugging bits, edited down like a good photo dump πŸŽ€

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.

  • --only-section <section>, -j β€” Remove all sections from the output, except for sections named <section>. Can be specified multiple times to keep multiple sections. Marie Kondo mode: everything goes unless it sparks joy πŸ’…

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. New name, new era 🌸
  • --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.
  • --regex β€” If specified, symbol and section names specified by other switches are treated as extended POSIX regular expression patterns. Glow-up for your matchers, regex girlies rise πŸ”₯
  • --remove-symbol-prefix <prefix> β€” Remove <prefix> from the start of every symbol name. No-op for symbols that do not start with <prefix>. If the prefix isn't there, she simply does not care 🫢
  • --remove-section <section>, -R β€” Remove the specified section from the output. Can be specified multiple times to remove multiple sections simultaneously. Blocked and reported βœ‹

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. Posture check for your sections πŸ“
  • --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.

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, don't come for her if a flag just vibes and does nothing on your arch πŸ’€)

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. (x86_64 only, bestie, she will literally refuse otherwise πŸ™…)

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. Leave her alone, she's doing great 🌸
  • --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. Yes, the GNU one. Same energy, different font πŸ’…
  • --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. (Those three get a pass, they're protected ✨)

For COFF and Mach-O objects, remove all symbols, debug sections, and relocations from the output.

For WebAssembly objects, remove all custom sections except for those named metadata.code.*.

  • --strip-debug, -g β€” Remove all debug sections from the output. Debug info? Never met her πŸ’€
  • --strip-symbol <symbol>, -N β€” Remove all symbols named <symbol> from the output. Can be specified multiple times to remove multiple symbols. Gone, blocked, unfollowed πŸ¦‹

okay that's the first chunk bestie β€” more parts are coming, don't go anywhere πŸ’œ

  • --strip-symbols <filename> β€” bestie, this one reads a whole list of symbol names out of <filename> and yeets every single one of them from the output ✨. In that file, each line is one symbol name, okay? Leading and trailing whitespace gets ignored (rude but fair), and so does anything after a # (so go off with comments, love that for you πŸ’…). And yeah β€” you can pass this bad boy multiple times to slurp names from multiple files. Stack 'em up 🫢.
  • --strip-unneeded-symbol <symbol> β€” removes every symbol named <symbol> from the output, but only if it's local or undefined and not required by any relocation πŸ”₯. Like, if a relocation needs it, it stays β€” no cap, it's protected.
  • --strip-unneeded-symbols <filename> β€” the file-based version of the above, and it's giving "bulk edit era" πŸŽ€. Removes all symbols whose names appear in <filename>, but again only when they're local or undefined and not required by any relocation. In the file, each line is a single symbol name, leading and trailing whitespace is ignored, and anything after a # is ignored too. Can be specified multiple times to read names from multiple files β€” literally stack as many as you want 🌸.
  • --strip-unneeded β€” the main character of cleanup flags πŸ‘‘. Removes from the output all local or undefined symbols that aren't required by relocations, and removes all debug sections. Two-for-one slay. πŸ’€ bye-bye debug info.
  • --update-section <name>=<file> β€” swaps out the contents of the section <name> with the contents of <file> πŸ¦‹. So like --update-section .foo=bar.bin vibes. But ⚠️ if the section <name> is part of a segment, the new contents cannot be larger than the existing section. Respect the size limit, bestie, it's not a suggestion πŸ™ˆ.
  • --verbose, -v β€” prints the paths of the files that get copied πŸ“‚. Just so you can see what's going down. Lowkey satisfying ngl.
  • --version, -V β€” displays the version of the llvm-objcopy executable 🏷️. Simple. Iconic. Periodt.
  • --wildcard, -w β€” allows wildcard syntax for symbol-related flags πŸ’«. It's on by default for section-related flags (she's confident, she doesn't need to be asked). Incompatible with --regex though β€” ⚠️ pick a lane, you cannot have both.

Wildcard syntax recognises these 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. It's giving main character exemption πŸŽ€.

The order of wildcards does not matter β€” bestie, it's a vibe, not a queue 🌈. For example, -w -N '*' -N '!x' is the same as -w -N '!x' -N '*'. Same energy, different order, identical outcome fr fr.

  • @<FILE> β€” reads command-line options and commands from the response file <FILE> πŸ“œ. Like a little note-passing situation β€” you write the options down, <FILE> holds them, and everything in there gets read in πŸ’Œ.

πŸ’… ELF-SPECIFIC OPTIONS πŸ’…

Okay bestie, these options are ELF-only. If you bust them out on some other kind of object, llvm-objcopy will either emit an error or silently ignore them β€” that’s the whole deal. 🫢

  • --add-symbol <name>=[<section>:]<value>[,<flags>] β€” Adds a brand-new symbol called <name> to the output symbol table, inside the section named <section>, with value <value>. If <section> isn’t specified, the symbol gets added as an absolute symbol. The <flags> control the symbol’s 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.

Also, these flags are accepted but ignored: debug, constructor, warning, indirect, synthetic, unique-object, before.

You can specify this multiple times to add multiple symbols. ✨

  • --allow-broken-links β€” Lets llvm-objcopy remove sections even if that would leave invalid section references behind. Any invalid sh_link fields get set to zero. Messy but permitted. πŸ’€
  • --change-section-lma \*{+-}<val> β€” Shifts the LMA of non-zero-sized segments by <val>.
  • --change-section-address <section>{=+-}<val>, --adjust-section-vma β€” Changes the address of sections matching the <section> pattern to the specified value, or applies +<val>/-<val> to the current value. You can specify it multiple times to set multiple patterns. Each section only gets 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.
  • --change-start <incr>, --adjust-start β€” Adds <incr> to the program’s start address. You can specify it multiple times, and then the values get applied cumulatively. πŸŽ€
  • --compress-debug-sections [<format>] β€” Compresses DWARF debug sections in the output using the specified format. Supported formats are zlib and zstd. If <format> is omitted, it uses zlib.
  • --compress-sections <section>=<format> β€” Compresses or decompresses 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 β€” Decompresses any compressed DWARF debug sections in the output.
  • --discard-locals, -X β€” Removes local symbols starting with ".L" that aren’t referenced by relocations from the output.
  • --extract-dwo β€” Removes all sections that are not DWARF .dwo sections from the output.
  • --extract-main-partition β€” Extracts the main partition from the output.
  • --extract-partition <name> β€” Extracts the named partition from the output.
  • --gap-fill <value> β€” For binary outputs, fills the gaps between sections with <value> instead of zero. The value must be an unsigned 8-bit integer. πŸ”₯
  • --input-target <format>, -I β€” Reads 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 β€” Keeps symbols of type STT_FILE, even if they would otherwise be stripped. Protect the little file symbols. πŸ₯Ί
  • --keep-section <section> β€” When removing sections from the output, don’t remove sections named <section>. Can be specified multiple times to keep multiple sections.
  • --keep-symbol <symbol>, -K β€” When removing symbols from the output, don’t remove symbols named <symbol>. Can be specified multiple times to keep multiple symbols.
  • --keep-symbols <filename> β€” When removing symbols from the output, don’t remove symbols named in the file <filename>. In that 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 β€” Marks all symbols with hidden or internal visibility local in the output.
  • --new-symbol-visibility <visibility> β€” Specifies the visibility of symbols automatically created when using binary input or --add-symbol. Valid options are:
    • default
    • hidden
    • internal
    • protected

The default is default. πŸ’…

  • --no-verify-note-sections β€” When adding note sections, does not verify if the section format is valid.
  • --output-target <format>, -O β€” Writes 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, pads the output to the load address <address> using a value of zero or the value specified by --gap-fill.
  • --prefix-alloc-sections <prefix> β€” Adds <prefix> to the front of the names of all allocatable sections in the output.
  • --prefix-symbols <prefix> β€” Adds <prefix> to the front of every symbol name in the output.
  • --preserve-dates, -p β€” Preserves access and modification timestamps in the output. πŸ•°οΈ
  • --remove-note [<name>/]<type> β€” Removes 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>,...] β€” Renames sections called <old> to <new> in the output, and applies 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> β€” Sets the type of section <section> to the integer <type>. Can be specified multiple times to update multiple sections.
  • --set-start <addr> β€” Sets the start address of the output to <addr>. This overrides any previously specified --change-start or --adjust-start options.
  • --set-symbol-visibility <symbol>=<visibility> β€” Changes the visibility of a symbol to the specified value.
  • --set-symbols-visibility <filename>=<visibility> β€” Reads a list of symbols from <filename> and changes 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 β€” Removes all DWARF .dwo sections from the output.
  • --strip-non-alloc β€” Removes from the output all non-allocatable sections that are not within segments.
  • --strip-sections β€” Removes 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. So yeah, this one is giving β€œchaotic brave” energy. πŸ’€
  • --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, verifies if the section format is valid. On by default. βœ…
  • --weaken-symbol <symbol>, -W β€” Marks global symbols named <symbol> as weak symbols in the output. Can be specified multiple times to mark multiple symbols as weak.
  • --weaken-symbols <filename> β€” Reads a list of names from the file <filename> and marks global symbols with those names as weak in the output. In that 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 β€” Marks all defined global symbols as weak in the output.

🍎 MACH-O-SPECIFIC OPTIONS 🍎

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

πŸͺŸ COFF-SPECIFIC OPTIONS πŸͺŸ

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

🌈 SUPPORTED FORMATS 🌈

These are the values 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. πŸ¦‹

🧚 BINARY INPUT AND OUTPUT 🧚

okay so bestie, when binary is the value you pass to --input-target, your input file gets embedded as a data section inside an ELF relocatable object. and the symbols are literally:

  • _binary_<file_name>_start
  • _binary_<file_name>_end
  • _binary_<file_name>_size

those represent the start, end, and size of the data β€” iconic trio behavior πŸ’…. here <file_name> is the path of the input file exactly as you specified it on the command line, but with all non-alphanumeric characters converted to _. yes, the underscores ate ✨.

when binary is the value you pass to --output-target, the output file is a raw binary file containing the memory image of the input file. symbols and relocation information are discarded, periodt. the image starts at the address of the first loadable section in the output. that’s the whole vibe 🫢.


✨ EXIT STATUS ✨

llvm-objcopy exits with a non-zero exit code if there is an error. otherwise, it exits with code 0. very demure, very predictable πŸ’–.


πŸ’€ BUGS πŸ’€

to report bugs, please visit:

https://github.com/llvm/llvm-project/labels/tools:llvm-objcopy/strip/

also, there is a known issue with --input-target and --target causing only binary and ihex formats to have any effect. other values will be ignored and llvm-objcopy will attempt to guess the input format. not me warning you in advance 😭.


πŸ‘€ SEE ALSO πŸ‘€


🫢 AUTHOR 🫢

maintained by the LLVM Team (https://llvm.org/). slay πŸ’œ.


2003-2026, LLVM Project. no cap, that’s the copyright line πŸ“.


and that’s the whole page, bestie! this is LLVM-OBJCOPY(1), manual section 23, dated 2026-10-06 β€” signing off with maximum sparkle πŸ§šπŸ’–βœ¨.

πŸ“¦ where this page comes from