LLVM-OBJCOPY(1)
π¦ 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_debuglinksection 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 typeSHT_NOTE, if the name starts with.note. Otherwise, it will have typeSHT_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 tollvm-objcopyand 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. use0for 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 tollvm-objcopyand 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 theSHF_ALLOCflag.load= if the section hasSHT_NOBITStype, mark it as aSHT_PROGBITSsection.readonly= if this flag is not specified, add theSHF_WRITEflag.exclude= add theSHF_EXCLUDEflag.code= add theSHF_EXECINSTRflag.merge= add theSHF_MERGEflag.strings= add theSHF_STRINGSflag.contents= if the section hasSHT_NOBITStype, mark it as aSHT_PROGBITSsection.large= add theSHF_X86_64_LARGEon 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 theIMAGE_SCN_CNT_UNINITIALIZED_DATAandIMAGE_SCN_MEM_READflags, unless theloadflag is specified.noload= add theIMAGE_SCN_LNK_REMOVEandIMAGE_SCN_MEM_READflags.readonly= if this flag is not specified, add theIMAGE_SCN_MEM_WRITEflag.exclude= add theIMAGE_SCN_LNK_REMOVEandIMAGE_SCN_MEM_READflags.debug= add theIMAGE_SCN_CNT_INITIALIZED_DATA,IMAGE_SCN_MEM_DISCARDABLEandIMAGE_SCN_MEM_READflags.code= add theIMAGE_SCN_CNT_CODE,IMAGE_SCN_MEM_EXECUTEandIMAGE_SCN_MEM_READflags.data= add theIMAGE_SCN_CNT_INITIALIZED_DATAandIMAGE_SCN_MEM_READflags.share= add theIMAGE_SCN_MEM_SHAREDandIMAGE_SCN_MEM_READflags.
--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 GNUobjcopy's--strip-allswitch. 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.attributesections 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'slocalorundefinedand 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'relocalorundefinedand 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 alllocalorundefinedsymbols 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.binvibes. 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 thellvm-objcopyexecutable π·οΈ. 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--regexthough β β οΈ 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 anSTT_FILEsymbol.sectionβ the symbol will be anSTT_SECTIONsymbol.objectβ the symbol will be anSTT_OBJECTsymbol.functionβ the symbol will be anSTT_FUNCsymbol.indirect-functionβ the symbol will be anSTT_GNU_IFUNCsymbol.
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β Letsllvm-objcopyremove sections even if that would leave invalid section references behind. Any invalidsh_linkfields 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-addressargument. If a section name matches multiple patterns, the rightmost change applies. The object file needs to be ofET_RELtype.--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 arezlibandzstd. If<format>is omitted, it useszlib.--compress-sections <section>=<format>β Compresses or decompresses sections matched by<section>using the specified format. Supported formats arezlibandzstd. Specifynonefor 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.dwosections 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-objcopywill attempt to determine the format automatically.--keep-file-symbolsβ Keeps symbols of typeSTT_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:defaulthiddeninternalprotected
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>fromSHT_NOTEsections 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-flagsfor 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-startor--adjust-startoptions.--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 runningllvm-objcopywith--extract-dwoand<dwo-file>as the output file and no other options, and then with--strip-dwoon the input file.--strip-dwoβ Removes all DWARF.dwosections 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-targetand--output-targetfor 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. π«Ά
binaryihexelf32-i386elf32-x86-64elf64-x86-64elf32-iamcuelf32-littlearmelf64-aarch64elf64-littleaarch64elf32-littleriscvelf64-littleriscvelf32-powerpcelf32-powerpcleelf64-powerpcelf64-powerpcleelf32-bigmipself32-ntradbigmipself32-ntradlittlemipself32-tradbigmipself32-tradlittlemipself64-tradbigmipself64-tradlittlemipself32-sparcelf32-sparcelelf32-hexagonelf32-loongarchelf64-loongarchelf64-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 π
llvm-strip(1)β go give it a little read, bestie π
π«Ά AUTHOR π«Ά
maintained by the LLVM Team (https://llvm.org/). slay π.
π COPYRIGHT π
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
- centos-stream 9: llvm 23.1.3-1.el9 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- centos-stream 9: llvm 23.1.3-1.el9 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms