LLVM-OBJCOPY(1)
๐ LLVM-OBJCOPY(1) โ the LLVM manual, section 1 โจ
okay so bestie, gather round, because this is llvm-objcopy from the LLVM manual (section 1), and it's genuinely one of my faves. it copies objects. it edits objects. it does a little bit of everything and honestly? iconic. ๐
โจ NAME โจ
llvm-objcopy โ the object copying and editing tool. yes, that's literally the whole vibe: copy stuff, edit stuff. ๐ฆ
๐ธ SYNOPSIS ๐ธ
llvm-objcopy [options] input [output]
๐ DESCRIPTION ๐
so llvm-objcopy is a tool to copy and manipulate objects, periodt. in basic usage it just makes a semantic copy of the input to the output โ like a little photocopier but for object files. but the second you throw any options at it, the output can get modified along the way, e.g. by removing sections. it's giving "glow-up on the way out the door". ๐
if no output file is specified, the input file is modified in-place. and 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. no cap, - is the main character in both directions. ๐ซถ
if the input is an archive, any requested operations will be applied to each archive member individually. every member gets its turn, nobody's left out. โจ
the tool is still in active development, but in most scenarios it works as a drop-in replacement for GNU's objcopy. lowkey a glow-up in progress, but it ate. ๐ฅ
๐ GENERIC AND CROSS-PLATFORM OPTIONS ๐
these options are either agnostic of the file format, or they apply to multiple file formats. so like, they work everywhere. universal icons only. ๐
--add-gnu-debuglink <debug-file>โ adds a.gnu_debuglinksection for <debug-file> to the output. ๐ง--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 typeSHT_NOTEif the name starts with.note. otherwise it'll have typeSHT_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>.
--binary-architecture <arch>,-Bโ ignored for compatibility. yeah, it's just there so nothing breaks. a decorative option, honestly. ๐--disable-deterministic-archives,-Uโ use real values for UIDs, GIDs and timestamps when updating archive member headers. like, actually real. raw. unfiltered. ๐--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. so it's a spring clean but with exceptions, iykyk. ๐งน--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 tollvm-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 it's a peek, not a pre-makeover. ๐
for MachO objects, <section> must be formatted as <segment name>,<section name>.
--enable-deterministic-archives,-Dโ enables deterministic mode when copying archives, i.e. use0for archive member header UIDs, GIDs and timestamp fields. on by default โ she's already enabled, bestie, she's just that girl. โจ--extract-section <section>=<file>โ extracts the specified section <section> into the file <file> as a separate object. can be specified multiple times to extract multiple sections. <file> is unrelated to the input and output files provided tollvm-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. mhm, same energy as--dump-sectionbut she leaves with a whole new object. ๐--globalize-symbol <symbol>โ marks any defined symbols named <symbol> as global symbols in the output. can be specified multiple times to mark multiple symbols. go off, be known. ๐--globalize-symbols <filename>โ reads a list of names from the file <filename> and marks 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. ๐--help,-hโ prints a summary of command line options. your little map when you're lost. ๐บ๏ธ--keep-global-symbol <symbol>,-Gโ marks all symbols local in the output, except for symbols with the name <symbol>. can be specified multiple times to ignore multiple symbols. so everyone's private except the chosen ones. ๐--keep-global-symbols <filename>โ marks 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โ marks 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>โ reads a list of names from the file <filename> and marks 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โ produces a debug file as the output that only preserves contents of sections useful for debugging purposes. the "keep only the cute parts" of object files. ๐
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โ removes all sections from the output, except for sections named <section>. can be specified multiple times to keep multiple sections. ruthless except to the ones you love. ๐ญ
for MachO objects, <section> must be formatted as <segment name>,<section name>.
--redefine-sym <old>=<new>โ renames symbols called <old> to <new> in the output. can be specified multiple times to rename multiple symbols. rebranding era. โจ--redefine-syms <filename>โ renames 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. regex girlies rise. ๐ฅ--remove-symbol-prefix <prefix>โ removes <prefix> from the start of every symbol name. no-op for symbols that do not start with <prefix>. if it's not there, nothing happens, no drama. ๐--remove-section <section>,-Rโ removes the specified section from the output. can be specified multiple times to remove multiple sections simultaneously. bye bestie, blocked and deleted. ๐
for MachO objects, <section> must be formatted as <segment name>,<section name>.
--set-section-alignment <section>=<align>โ sets the alignment of section <section> to <align>. can be specified multiple times to update multiple sections. posture check, but for sections. ๐--set-section-flags <section>=<flag>[,<flag>,...]โ sets section properties in the output of section <section> based on the specified <flag> values. can be specified multiple times to update multiple sections. flag customization at its finest. ๐จ
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 don't come for me if some of them do nothing on your target, okay? ๐
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. like, she refuses. no x86_64, no entry. ๐ซ
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. she's on do-not-disturb. ๐ธ--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. the whole group chat is exempt. ๐ซถ--strip-all-gnuโ removes all symbols, debug sections and relocations from the output. this option is equivalent to GNUobjcopy's--strip-allswitch. (yes, it's the GNU-flavored one, keep that in mind, iykyk.) โญ--strip-all,-Sโ for ELF objects, removes from the output all symbols and non-alloc sections not within segments, except for.gnu.warning,.ARM.attributesections and the section name table. some things are simply too iconic to remove. ๐
for COFF and Mach-O objects, removes all symbols, debug sections, and relocations from the output.
for WebAssembly objects, removes all custom sections except for those named metadata.code.*.
--strip-debug,-gโ removes all debug sections from the output. clean, fresh, no baggage. ๐ง--strip-symbol <symbol>,-Nโ removes all symbols named <symbol> from the output. can be specified multiple times to remove multiple symbols. ๐๏ธ
โจ okay that's all the generic goodies โ more options coming right up, bestie, don't you dare close the tab ๐
--strip-symbols<filename> โ bestie, this one removes all symbols whose names show up in <filename> from the output. In that file, each line is one symbol name, and leading + trailing whitespace gets ignored, along with anything after a#. You can use this multiple times to read names from multiple files. โจ--strip-unneeded-symbol<symbol> โ removes from the output every symbol named <symbol> that is local or undefined and not required by any relocation. no cap, itโs picky on purpose ๐--strip-unneeded-symbols<filename> โ removes all symbols whose names appear in <filename> from the output, but only if theyโre local or undefined and not required by any relocation. Same file rules as above: one symbol name per line, leading/trailing whitespace ignored, and anything after a#ignored too. Can be specified multiple times to read names from multiple files. ๐--strip-unneededโ removes from the output all local or undefined symbols that are not required by relocations. Also removes all debug sections. itโs giving cleanup era ๐งน--update-section<name>=<file>โ replaces the contents of the section <name> with contents from the file <file>. If the section <name> is part of a segment, the new contents cannot be larger than the existing section. so like, donโt try to overstuff it, bestie ๐ญ--verbose,-vโ prints the paths of files that are copied. tiny receipts, very main character ๐ซถ--version,-Vโ displays the version of thellvm-objcopyexecutable. slay, now you know what youโre running โญ--wildcard,-wโ allows wildcard syntax for symbol-related flags. Itโs on by default for section-related flags. It is incompatible with--regex. ๐ฅ
Wildcard syntax allows these special symbols, iykyk:
*โ 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 '*'. periodt ๐
@<FILE> โ reads command-line options and commands from response file <FILE>. itโs like a lil shortcut bestie, very convenient ๐ธ
โจ ELF-SPECIFIC OPTIONS โจ
Okay so these next ones are ELF-only, bestie. Like, they're literally just for ELF objects. If you try them on some other kind of object, llvm-objcopy will either hit you with an error or just silently ignore you (rude, but okay ๐
).
--add-symbol <name>=[<section>:]<value>[,<flags>]โ Adds a brand-new symbol called<name>to the output symbol table, living in the section named<section>, with value<value>. If you don't give a<section>, the symbol gets added as an absolute symbol. And the<flags>? They tweak 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 below are accepted but ignored (they're just there for vibes, honestly): debug, constructor, warning, indirect, synthetic, unique-object, before.
You can pass this one multiple times to add multiple symbols ๐ซถ.
--allow-broken-linksโ Letsllvm-objcopyremove sections even when that would leave invalid section references behind. Any invalidsh_linkfields just get set to zero. Crisis averted โจ.--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 for multiple patterns. Heads up: each section only gets modified by one--change-section-addressargument. If a section name matches multiple patterns, the rightmost change wins. Oh and the object file needs to be ofET_RELtype. Periodt.--change-start <incr>,--adjust-startโ Adds<incr>to the program's start address. Can be specified multiple times, and the values get applied cumulatively. Math is mathing ๐ .--compress-debug-sections [<format>]โ Compresses DWARF debug sections in the output using the format you pick. Supported formats arezlibandzstd. If you omit<format>, it useszlib.--compress-sections <section>=<format>โ Compresses (or decompresses!) sections matched by<section>using the specified format. Supported formats arezlibandzstd. Saynonefor decompression. When a section is matched by multiple options, the last one wins. A wildcard<section>starting with!is disallowed. And sections within a segment can't be (de)compressed at all. Sorry bestie ๐ญ.--decompress-debug-sectionsโ Decompresses any compressed DWARF debug sections in the output. Undoing the thing, iconic.--discard-locals,-Xโ Removes local symbols starting with.Lfrom the output, but only the ones not referenced by relocations. Bye babes ๐.--extract-dwoโ Removes all sections from the output that are not DWARF.dwosections.--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 โ no funny business ๐ฅ.--input-target <format>,-Iโ Reads the input as the specified format. Check out SUPPORTED FORMATS for the list of valid<format>values. If you don't specify it,llvm-objcopywill try to figure the format out automatically. She's intuitive like that ๐.--keep-file-symbolsโ Keeps symbols of typeSTT_FILE, even when they'd otherwise be stripped. Protect them at all costs ๐ซถ.--keep-section <section>โ When sections are being removed from the output, don't remove sections named<section>. Can be specified multiple times to keep multiple sections.--keep-symbol <symbol>,-Kโ When symbols are being removed 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 the symbols named in the file<filename>. In that file, each line is a single symbol, with leading and trailing whitespace ignored, and anything following a#is ignored too. Can be specified multiple times to read names from multiple files ๐.--localize-hiddenโ Marks all symbols with hidden or internal visibility as local in the output.--new-symbol-visibility <visibility>โ Sets the visibility of the symbols that get automatically created when you use binary input or--add-symbol. Valid options are:defaulthiddeninternalprotected
The default is default.
--no-verify-note-sectionsโ When adding note sections, skips verifying whether the section format is valid. Living dangerously, love that for you ๐.--output-target <format>,-Oโ Writes the output as the specified format. See SUPPORTED FORMATS for the list of valid<format>values. If you don't specify it, the output format is assumed to be whatever you gave to--input-target, or if that option's also missing, the input file's format.--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 single symbol name in the output. Every one. No cap.--preserve-dates,-pโ Preserves access and modification timestamps in the output. Time is a construct but okay โญ.--remove-note [<name>/]<type>โ Removes notes of integer type<type>and name<name>fromSHT_NOTEsections that aren't 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<flag>values you throw at it. Check--set-section-flagsfor the list of supported flags. Can be specified multiple times to rename multiple sections. Glow-up for your 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 one overrides any previously specified--change-startor--adjust-startoptions. She said what she said ๐.--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>โ Exactly equivalent to runningllvm-objcopywith--extract-dwoand<dwo-file>as the output file and no other options, and then running it with--strip-dwoon the input file. Two-for-one โจ.--strip-dwoโ Removes all DWARF.dwosections from the output.--strip-non-allocโ Removes from the output all non-allocatable sections that aren't within segments.--strip-sectionsโ Removes from the output all section headers and all section data not within segments. > Careful bestie: many tools will not be able to use an object without section headers. Like, at all. You've been warned ๐.--target <format>,-Fโ Equivalent to setting both--input-targetand--output-targetfor the specified format. See SUPPORTED FORMATS for the list of valid<format>values. Two birds, one stone ๐ฆ.--verify-note-sectionsโ When adding note sections, verifies whether the section format is valid. On by default, so you're already good ๐ธ.--weaken-symbol <symbol>,-Wโ Marks global symbols named<symbol>as weak symbols in the output. Can be specified multiple times to weaken multiple symbols.--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 the file, each line is a single symbol, with leading and trailing whitespace ignored, and anything following a#is ignored too. Can be specified multiple times to read names from multiple files.--weakenโ Marks all defined global symbols as weak in the output. All of them. Whole squad, weakened ๐ฅ.
๐ MACH-O-SPECIFIC OPTIONS ๐
--keep-undefinedโ Keeps undefined symbols, even if they'd otherwise be stripped. Protecting her peace ๐ซถ.
๐ COFF-SPECIFIC OPTIONS ๐
--subsystem <name>[:<version>]โ Sets the PE subsystem, and optionally the subsystem version if you give it after the colon.
๐ SUPPORTED FORMATS ๐
So these are the values llvm-objcopy currently supports for the --input-target, --output-target, and --target options. And because GNU objcopy compatibility matters, all the values are bfdnames (iykyk).
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
And one more little detail, bestie โ additionally, all targets except binary, ihex, and srec can have -freebsd as a suffix. Cute, right? ๐ง
๐ง BINARY INPUT AND OUTPUT ๐ง
okay so this is the โจspecialโจ mode and you need to know about it, bestie, because it's lowkey iconic.
- If
binaryis the value you pass to--input-target, your input file gets embedded as a data section inside an ELF relocatable object ๐ โ and it comes with three lil symbols:_binary_<file_name>_startโ where the data starts ๐_binary_<file_name>_endโ where it ends ๐_binary_<file_name>_sizeโ how big it is ๐
- about
<file_name>rq: it's the path of the input file exactly as you specified it on the command line, except every non-alphanumeric character gets converted to_. no cap, that's the rule. - If
binaryis 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? Gone. Discarded. Not invited to the party ๐. The image starts at the address of the first loadable section in the output โ that's where it begins, periodt.
๐ EXIT STATUS ๐
- If there's an error,
llvm-objcopyexits with a non-zero exit code. - Otherwise? It exits with code
0. slay ๐
fr fr, a non-zero exit code means something went wrong โ check your vibe (and your error output) before you trust the result ๐
๐ BUGS ๐
Got a bug? Don't suffer in silence, bestie โ go tell the LLVM team:
https://github.com/llvm/llvm-project/labels/tools:llvm-objcopy/strip/
โ ๏ธ There is a known issue with--input-targetand--targetwhere onlybinaryandihexformats have any effect. Any other value will just be ignored, andllvm-objcopywill attempt to guess the input format instead ๐ญ. So like, don't expect those other values to do anything โ iykyk.
๐ SEE ALSO ๐
llvm-strip(1)<llvm-strip.html> โ the sibling, the other half of the duo ๐ซถ
๐ Author ๐
Maintained by the LLVM Team (https://llvm.org/). iconic behaviour, honestly ๐
๐ธ Copyright ๐ธ
2003-2026, LLVM Project โ yeah, they've been at it a minute ๐
okay that's the whole page, bestie โ you're officially a llvm-objcopy girlie now ๐
โจ this was LLVM-OBJCOPY(1), version 23, dated 2026-10-20 โ go forth and copy some objects ๐ฆ๐๐
๐ฆ where this page comes from
- arch rolling: llvm 23.1.4-1 ยท Apache-2.0 WITH LLVM-exception
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms