LLVM-OBJCOPY(1)
okay so bestie, welcome to LLVM-OBJCOPY(1) β the LLVM manual page for llvm-objcopy, aka the object-copying and editing tool that is lowkey carrying entire build pipelines. This is part 1, and we are keeping every single detail, no cap. π
β¨
π NAME π
llvm-objcopy β object copying and editing tool π
π¦ SYNOPSIS π¦
llvm-objcopy [options] input [output]
πΈ DESCRIPTION πΈ
llvm-objcopy is a tool to copy and manipulate objects. In basic usage, it makes a semantic copy of the input to the output. If any options are specified, the output may be modified along the way, e.g. by removing sections. It's giving βcopy but make it fashion.β π
If no output file is specified, the input file is modified in-place. 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 yes, bestie, - is the main character for stdin/stdout vibes. π
If the input is an archive, any requested operations will be applied to each archive member individually. Not me treating every archive member like its own little icon. π«Ά
The tool is still in active development, but in most scenarios it works as a drop-in replacement for GNU's objcopy. Periodt. π₯
π GENERIC AND CROSS-PLATFORM OPTIONS π
The following options are either agnostic of the file format, or apply to multiple file formats. Basically: these are the versatile besties. β¨
--add-gnu-debuglink <debug-file>β Add a.gnu_debuglinksection for<debug-file>to the output. Debug-link slay. π--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. For MachO objects,<section>must be formatted as<segment name>,<section name>. π¦--binary-architecture <arch>,-Bβ Ignored for compatibility. It's literally just vibing there. π--disable-deterministic-archives,-Uβ Use real values for UIDs, GIDs and timestamps when updating archive member headers. Real ones only. π--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. It's giving cleanup era. π§--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. 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. Deterministic queen behavior. π--globalize-symbol <symbol>β Mark any defined symbols named<symbol>as global symbols in the output. Can be specified multiple times to mark multiple symbols. Make them global, make them iconic. π--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. π--help,-hβ Print a summary of command line options. The βhelp me help youβ option. π«Ά--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. Keep the chosen ones global, bestie. π--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. Localize era. π¦--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. For ELF objects, this removes the contents ofSHF_ALLOCsections that are notSHT_NOTEby making themSHT_NOBITSand shrinking the program headers where possible. Debug-only main character energy. π--only-section <section>,-jβ Remove all sections from the output, except for sections named<section>. Can be specified multiple times to keep multiple sections. For MachO objects,<section>must be formatted as<segment name>,<section name>. Keep only the chosen faves. π--redefine-sym <old>=<new>β Rename symbols called<old>to<new>in the output. Can be specified multiple times to rename multiple symbols. Name change slay. π--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. 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 it doesn't start with the prefix, it's not invited to the removal party. π--remove-section <section>,-Rβ Remove the specified section from the output. Can be specified multiple times to remove multiple sections simultaneously. For MachO objects,<section>must be formatted as<segment name>,<section name>. Bye-bye section. π--set-section-alignment <section>=<align>β Set the alignment of section<section>to<align>. Can be specified multiple times to update multiple sections. Alignment check, but make it section-specific. π--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 arealloc,load,noload,readonly,exclude,debug,code,data,rom,share,contents,merge,strings, andlarge. Not all flags are meaningful for all object file formats or target architectures. Flag buffet, but read the labels. π 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. β οΈ 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 that symbol exactly as it is, bestie. π--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. Strip era, GNU-compatible edition. π--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 clean-out vibe. π₯--strip-debug,-gβ Remove all debug sections from the output. Debug sections? Not invited. π--strip-symbol <symbol>,-Nβ Remove all symbols named<symbol>from the output. Can be specified multiple times to remove multiple symbols. Symbol deletion slay. π--strip-symbols <filename>β Remove all symbols whose names appear in the file<filename>, from the output. In the file, each line represents a single symbol name, with leading and trailing whitespace ignored, as is anything following a#. Can be specified multiple times to read names from multiple files. π--strip-unneeded-symbol <symbol>β Remove from the output all symbols named<symbol>that are local or undefined and are not required by any relocation. If it's unneeded, it's getting uninvited. β¨--strip-unneeded-symbols <filename>β this one's a β¨targetedβ¨ cleanse, bestie. It removes every symbol whose name shows up in <filename> from the output, but only if it's local or undefined and nothing needs it for a relocation. So likeβ¦ it won't ghost a symbol that a relocation is literally depending on, because that would be messy π . In the file, each line = one single symbol name. Leading and trailing whitespace gets ignored, and so does anything after a#(yes, comments, we love a comment π). You can pass this flag multiple times to pull names from multiple files. π--strip-unneededβ the full glow-up reset π₯. Removes all local or undefined symbols from the output that relocations don't require, and also nukes all debug sections. It's giving "clean slate, no baggage, main character energy."--update-section <name>=<file>β swap the contents of the section <name> with the contents of the file <file>. π«Ά Easy. But β and this is the important part, ngl β if <name> is part of a segment, the new contents cannot be larger than the existing section. So don't try to make it bigger, it will not slay, it will just fail π.--version,-Vβ shows the version of thellvm-objcopyexecutable. Little identity check, we love a queen who knows herself π.--wildcard,-wβ lets you use wildcard syntax on the symbol-related flags. It's on by default for section-related flags. β οΈ Heads up: it's incompatible with--regex, so pick a lane bestie, you can't have both π.
Wildcard syntax supports these special little 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]
Also, starting a wildcard with ! will prevent a match, even if another flag matches it. Obsessed with this one: -w -N '*' -N '!x' strips all the symbols except for x. Like, everyone out except x, x is the guest of honour π¦.
And the order of wildcards does not matter. For real: -w -N '*' -N '!x' is exactly the same as -w -N '!x' -N '*'. Same vibe either way, no cap π.
@<FILE>β reads command-line options and commands from the response file <FILE>. Basically it's like "hey, take my notes, I wrote it all down for you" πβ¨.
π ELF-SPECIFIC OPTIONS π
okay so these next ones are ELF-only, bestie β the manual says: the following options are implemented only for ELF objects. If you use them with other objects, llvm-objcopy will either emit an error or silently ignore them. π 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. β¨
--allow-broken-linksβ Allowllvm-objcopyto remove sections even if it would leave invalid section references. Any invalidsh_linkfields will be set to zero. no cap, it just zeroes them--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 of ET_REL type. π«Ά
--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.Lnot 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. β¨
--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 π¦
--keep-undefinedβ Keep undefined symbols, even if they would otherwise be stripped. iconic Mach-O behavior, honestly
π 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. π
π§ BINARY INPUT AND OUTPUT π§
Okay bestie, this part is genuinely iconic because it's where llvm-objcopy stops being a format nerd and starts doing β¨raw bytesβ¨.
If binary is 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 little besties β symbols, actually β that mark it all out:
_binary_<file_name>_startβ where the data starts π_binary_<file_name>_endβ where it ends π_binary_<file_name>_sizeβ how big it is, because size matters, periodt πΈ
And <file_name> here is the path of the input file exactly as you specified it on the command line, with every non-alphanumeric character converted to _. Yes, literally every single one. No cap.
Now flip it around: if binary is the value for --output-target, the output file is a raw binary file containing the memory image of the input file. It's giving "just the bytes, ma'am" π
.
Heads up bestie: symbols and relocation information get discarded. Gone. Not coming back. The image will start at the address of the first loadable section in the output β that's the vibe, that's the rule π₯
π EXIT STATUS π
llvm-objcopy exits with a non-zero exit code if there's an error. Otherwise? Code 0. Slay. Clean exit, no drama π«Ά
π BUGS π
Found a bug? First of all, relatable. Second of all, please go visit:
https://github.com/llvm/llvm-project/labels/tools:llvm-objcopy/strip/
There's also a known issue you should absolutely know about: --input-target and --target only actually do anything for the binary and ihex formats π. Any other value gets ignored, and llvm-objcopy will just try to guess the input format on its own. It's giving "I'll figure it out myself, thanks" β which is lowkey not the energy you want from a tool that's supposed to do exactly what you told it. So keep that in mind fr fr.
π SEE ALSO π
llvm-strip(1)β its sibling, its partner in crime, its main character co-star π
π Author π
Maintained by the LLVM Team (<https://llvm.org/>). Legends, honestly.
π Copyright π
2003-2026, LLVM Project
And that's a wrap on the whole page, bestie!! π¦ Go forth and copy some objects, you absolute icon β This lil' section you just read is from the LLVM-OBJCOPY(1) manual page, section 21, dated 2026-05-15 β screenshot it, bookmark it, tattoo it, whatever feels right π
π¦ where this page comes from
- fedora 44: llvm21 21.1.8-5.fc44 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- fedora 44: llvm21 21.1.8-5.fc44 Β· 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