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_debuglinksection 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 typeSHT_NOTEif the name starts with.note. otherwise, it gets 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>. 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 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, 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. use0for 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 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. (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 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. so don't try it, she will say no π
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 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 GNUobjcopy's--strip-allswitch. 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.attributesections 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 thellvm-objcopyexecutable. 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 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.
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β Allowllvm-objcopyto remove sections even if it would leave invalid section references. Any invalidsh_linkfields 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-addressargument. If a section name matches multiple patterns, the rightmost change applies. The object file needs to be ofET_RELtype. 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 arezlibandzstd. Usezlibif<format>is omitted.--compress-sections <section>=<format>β Compress or decompress 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β 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.dwosections 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-objcopywill attempt to determine the format automatically.--keep-file-symbolsβ Keep symbols of typeSTT_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:defaulthiddeninternalprotected
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-targetor 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>fromSHT_NOTEsections 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-flagsfor 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-startor--adjust-startoptions.--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 runningllvm-objcopywith--extract-dwoand<dwo-file>as the output file and no other options, and then with--strip-dwoon the input file.--strip-dwoβ Remove all DWARF.dwosections 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-targetand--output-targetfor 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.
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. periodt.
π«Ά BINARY INPUT AND OUTPUT π«Ά
Okay bestie, this part is lowkey the β¨magic trickβ¨ of the whole page, so lock in.
- If you use
binaryas 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
binaryas the value for--output-targetinstead, 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-objcopyexits 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-targetand--targetcausing onlybinaryandihexformats to have any effect. Every other value gets ignored andllvm-objcopywill 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.
π Copyright π
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
- fedora 44: llvm 22.1.8-4.fc44 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- fedora 44: llvm 22.1.8-4.fc44 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms