LLVM-OBJCOPY(1)
π llvm-objcopy β the manual, bestie edition π
okay so real talk, this is the manpage for llvm-objcopy, part of the LLVM fam. it's giving "tool that copies objects but like, β¨with β¨ opinionsβ¨". stay with me, it's actually so good.
πΈ NAME πΈ
llvm-objcopy β the object copying and editing tool. that's it, that's the whole vibe. she copies, she edits, she slays.
π¦ SYNOPSIS π¦
llvm-objcopy [options] input [output]
like, give her some [options], an input, and maybe an output if you're feeling generous. the brackets are doing a lot of heavy lifting there, iykyk.
β¨ DESCRIPTION β¨
so llvm-objcopy is a tool to copy and manipulate objects. π«Ά in basic usage β like, no thoughts head empty, just vibes β it makes a semantic copy of the input to the output. semantic, not just "copy the bytes", she's doing it correctly and i'm obsessed with her for that.
but the second you specify any options? oh she's modifying the output along the way. example given: removing sections. literally just, poof, section gone. main character energy fr fr π₯
π where do the bytes even go tho
- no output file specified β the input file is modified in-place π. yes, in place. as in, she edits your file right there, on the spot. so like, be aware of that. no cap.
-specified for the input file β the input is read from the program's standard input stream π-specified for the output file β the output is written to the standard output stream of the program π
bestie the-is doing double duty here, so pay attention to which side of the command you put it on.-as input β-as output. they're the same little dash but a whole different situation. π
ποΈ archives, because she's versatile
if the input is an archive, any requested operations will be applied to each archive member individually. each one. individually. she's not doing a group project where one person does all the work β she's going member by member, no shortcuts, very thorough, very demure π
π§ a lil honesty moment
the tool is still in active development. yep, still cooking π. but β and this is the good part β in most scenarios it works as a drop-in replacement for GNU's objcopy. drop-in. replacement. she's out here doing the GNU thing's job and doing it cute. π
that's the beginning of the story, bestie β there's a whole pile of options coming up next, and you already know she has a lot of them π
β¨ GENERIC AND CROSS-PLATFORM OPTIONS β¨
Okay bestie, these are the options that are either totally file-format-agnostic or they work across multiple formats. No format drama, just vibes π
--add-gnu-debuglink <debug-file>β adds a.gnu_debuglinksection for<debug-file>to the output. Slay.--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 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 giving "I'm here but I'm not doing anything" π--disable-deterministic-archives,-Uβ use real values for UIDs, GIDs and timestamps when updating archive member headers.--discard-all,-xβ removes most local symbols 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, removes all debug sections.--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.
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. Iconic default behavior, honestly.--help,-hβ prints a summary of command line options.--only-keep-debugβ produces a debug file as the output that only preserves contents of sections useful for debugging purposes.
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.
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.--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.--remove-section <section>,-Rβ removes 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>.
--set-section-alignment <section>=<align>β sets the alignment of section<section>to<align>. Can be specified multiple times to update multiple 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.
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.
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.
--strip-all-gnuβ removes all symbols, debug sections and relocations from the output. This option is equivalent to GNU objcopy's--strip-allswitch.--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.
For COFF and Mach-O objects, removes all symbols, debug sections, and relocations from the output.
--strip-debug,-gβ removes all debug sections from the output.--strip-symbol <symbol>,-Nβ removes all symbols named<symbol>from the output. Can be specified multiple times to remove multiple symbols.--strip-symbols <filename>β removes 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>β removes from the output all symbols named<symbol>that are local or undefined and are not required by any relocation.--strip-unneeded-symbols <filename>β removes all symbols whose names appear in the file<filename>, from the output, if they are local or undefined and are not required by any relocation. 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β removes from the output all local or undefined symbols that are not required by relocations. Also removes all debug sections.--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. Respect the limit, bestie π«Ά--version,-Vβ displays the version of thellvm-objcopyexecutable.--wildcard,-wβ allows wildcard syntax for symbol-related flags. On by default for section-related flags. Incompatible with--regex.
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>.
π ELF-SPECIFIC OPTIONS π
Okay so these ones? They only work on ELF objects, periodt. If you try them on anything else, llvm-objcopy will either throw an error at you π or just silently ignore them like it didn't even hear you π.
--add-symbol <name>=[<section>:]<value>[,<flags>]β adds a brand new symbol called <name> to the output symbol table, sitting in the section named <section>, with value <value>. If you don't give it a <section>, the symbol gets added as an absolute symbol, iconic behavior honestly β¨. The <flags> control the symbol's properties β here's what you can pass:global= the symbol will have global binding.local= the symbol will have local binding.weak= the symbol will have weak binding.default= the symbol will have default visibility.hidden= the symbol will have hidden visibility.protected= the symbol will have protected visibility.file= the symbol will be an STT_FILE symbol.section= the symbol will be an STT_SECTION symbol.object= the symbol will be an STT_OBJECT symbol.function= the symbol will be an STT_FUNC symbol.indirect-function= the symbol will be an STT_GNU_IFUNC symbol.
Also, these flags are accepted but ignored (they're just there vibing π
): debug, constructor, warning, indirect, synthetic, unique-object, before.
Can be specified multiple times to add multiple symbols. Slay, add as many as your little heart desires π«Ά.
--allow-broken-linksβ letsllvm-objcopyremove sections even if it would leave invalid section references behind. Any invalidsh_linkfields get set to zero. Lowkey chaotic but sometimes you gotta π«Ά.--change-start <incr>,--adjust-startβ adds <incr> to the program's start address. Can be specified multiple times, and the values get applied cumulatively (so they stack, no cap π).--compress-debug-sections [<format>]β compresses DWARF debug sections in the output using the format you specify. Supported formats arezlibandzstdβ and if you omit <format>, it just useszlibby default. Easy β¨.--decompress-debug-sectionsβ does the exact opposite energy: decompresses any compressed DWARF debug sections in the output.--discard-locals,-Xβ removes local symbols starting with".L"from the output. Bye bestie π.--extract-dwoβ removes all sections that aren't DWARF.dwosections from the output. Only the dwo girlies survive π.--extract-main-partitionβ extracts the main partition from the output.--extract-partition <name>β extracts the partition named <name> from the output.--gap-fill <value>β for binary outputs, fills the gaps between sections with <value> instead of zero. Heads up: the value must be an unsigned 8-bit integer, no exceptions π₯.--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 π.--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 is one single symbol, with leading and trailing whitespace ignored, and anything following a'#'ignored too. Can be specified multiple times to read names from multiple files.--input-target <format>,-Iβ reads the input as the specified format. Check SUPPORTED FORMATS for the valid <format> values. If you don't specify it,llvm-objcopywill try to figure out the format automatically. She's intuitive like that π§.--keep-file-symbolsβ keeps symbols of typeSTT_FILE, even if they'd otherwise get stripped. Protect them at all costs π.--keep-global-symbol <symbol>,-Gβ makes all symbols local in the output, except for symbols named <symbol>. Can be specified multiple times to ignore multiple symbols.--keep-global-symbols <filename>β makes all symbols local in the output, except for the ones named in the file <filename>. In the file, each line is one symbol, leading and trailing whitespace ignored, and anything after a'#'ignored. Can be specified multiple times to read names from multiple files.--keep-section <section>β when sections are getting removed from the output, don't remove the ones named <section>. Can be specified multiple times to keep multiple sections π.--keep-symbol <symbol>,-Kβ when symbols are getting removed from the output, don't remove the ones 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 the file, each line is a single symbol, leading and trailing whitespace ignored, and anything following a'#'ignored. Can be specified multiple times to read names from multiple files.--localize-hiddenβ makes all symbols with hidden or internal visibility local in the output.--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.--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 is one symbol, leading and trailing whitespace ignored, and anything following a'#'ignored. Can be specified multiple times to read names from multiple files.--new-symbol-visibility <visibility>β specifies the visibility of the symbols that get created automatically when you use binary input or--add-symbol. Valid options are:defaulthiddeninternalprotected
The default is default. Noted π.
--output-target <format>,-Oβ writes the output as the specified format. See SUPPORTED FORMATS for the valid <format> values. If you leave it unspecified, the output format is assumed to be the same as whatever you passed to--input-target, or the input file's format if that option is also unspecified. She'll figure it out π .--pad-to <address>β for binary outputs, pads the output to the load address <address> using a value of zero, or whatever value you set with--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.--preserve-dates,-pβ preserves access and modification timestamps in the output. Respect the timeline β°.--rename-section <old>=<new>[,<flag>,...]β renames sections called <old> to <new> in the output, and applies any <flag> values you give it. See--set-section-flagsfor the 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 <addr>β sets the start address of the output to <addr>. This one overrides any previously specified--change-startor--adjust-startoptions β she's the main character here π.--split-dwo <dwo-file>β this is 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-step slay β¨.--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.
β οΈ Heads up bestie: many tools will not be able to use an object without section headers. So likeβ¦ know what you're doing π.
--target <format>,-Fβ equivalent to setting both--input-targetand--output-targetto the specified format. See SUPPORTED FORMATS for the valid <format> values.--weaken-symbol <symbol>,-Wβ marks any global symbol named <symbol> as a weak symbol 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 the file, each line is one symbol, leading and trailing whitespace ignored, and anything following a'#'ignored. Can be specified multiple times to read names from multiple files.--weakenβ marks all defined global symbols as weak in the output. Everyone gets the weak treatment, no favorites π.
π MACH-O-SPECIFIC OPTIONS π
--keep-undefinedβ keeps undefined symbols, even if they would otherwise be stripped. Ride or die for the undefined ones π«Ά.
π COFF-SPECIFIC OPTIONS π
--subsystem <name>[:<version>]β sets the PE subsystem, and optionally the subsystem version too. Fancy π.
πΈ SUPPORTED FORMATS πΈ
Here's the tea β these are the values currently supported by llvm-objcopy for the --input-target, --output-target, and --target options. And 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
Also β and this is important β every target except binary and ihex can have -freebsd tacked on as a suffix. Little suffix moment π
.
π¦ BINARY INPUT AND OUTPUT π¦
So if you use binary as the value for --input-target, the input file gets embedded as a data section inside an ELF relocatable object, with the symbols _binary_<file_name>_start, _binary_<file_name>_end, and _binary_<file_name>_size representing the start, end and size of that data β where <file_name> is the path of the input file as you wrote it on the command line, with all non-alphanumeric characters converted to _. Cute little name transformation π§.
If you use binary as the value for --output-target, the output file becomes a raw binary file containing the memory image of the input file. Symbols and relocation information get discarded β gone, deleted, not invited to the party π. The image starts at the address of the first loadable section in the output.
β EXIT STATUS β
llvm-objcopy exits with a non-zero exit code if there's an error. Otherwise, it exits with code 0. Simple as that, bestie π.
π BUGS π
okay so if you find a bug β and honestly, thank you for being that girl, bug reports are literally self-care π β please report it here:
https://github.com/llvm/llvm-project/labels/tools:llvm-objcopy/strip/
now for the tea β there's a known issue with --input-target and --target where only the binary and ihex formats actually have any effect π. any other values get ignored, and llvm-objcopy will attempt to guess the input format. not ideal, but that's the situation bestie, no cap π«Ά
π SEE ALSO π
the see-also bestie on this page is:
llvm-strip(1) <llvm-strip.html>
go give it a read when you're done here π¦β¨
π Author π
maintained by the LLVM Team (https://llvm.org/) β iconic behavior, honestly ππ
π Copyright π
2003-2026, LLVM Project
yes, the whole long range, we love a legacy icon ππΈ
okay that's a wrap on this whole page π the footer vibe is LLVM-OBJCOPY(1), dated 2026-09-09, page 15 β mwah, bye bestie πβ¨π
π¦ where this page comes from
- ubuntu stonking: llvm-18 1:18.1.8-20ubuntu11 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms