ELFCOPY(1)
π elfcopy(1) β the copy-and-translate-object-files manual, bestie edition
okay so welcome to elfcopy/objcopy, the general commands manual page that's about to be your new hyperfixation. stay with me, this one's a banger π«Ά
πΈ NAME πΈ
elfcopy, objcopy β copy and translate object files. that's it, that's the whole vibe. it copies, it translates, it slays β¨
π¦ SYNOPSIS π¦
elfcopy [-I objformat | -s objformat | --input-target=objformat]
[-K symbolname | --keep-symbol=symbolname]
[-L symbolname | --localize-symbol=symbolname]
[-N symbolname | --strip-symbol=symbolname]
[-O objformat | --output-target=objformat]
[-R sectionname | --remove-section=sectionname]
[-S | --strip-all] [-V | --version]
[-W symbolname | --weaken-symbol=symbolname]
[-X | --discard-locals] [-d | -g | --strip-debug] [-h | --help]
[-j sectionname | --only-section=sectionname]
[-p | --preserve-dates] [-w | --wildcard] [-x | --discard-all]
[--add-gnu-debuglink=filename]
[--add-section sectionname=filename] [--adjust-section-vma
section{+|-|=}val | --change-section-address section{+|-|=}val]
[--adjust-start=increment | --change-start=increment]
[--adjust-vma=increment | --change-addresses=increment]
[--adjust-warnings | --change-warnings]
[--change-section-lma section{+|-|=}val]
[--change-section-vma section{+|-|=}val] [--extract-dwo]
[--gap-fill=val] [--globalize-symbol=ar symbolname]
[--globalize-symbols=filename] [--localize-hidden]
[--localize-symbols=filename]
[--no-adjust-warnings | --no-change-warnings]
[--only-keep-debug] [--pad-to=address]
[--prefix-alloc-sections=string] [--prefix-sections=string]
[--prefix-symbols=string]
[--rename-section oldname=newname[,flags]]
[--set-section-flags sectionname=flags] [--set-start=address]
[--srec-forceS3] [--srec-len=val] [--strip-dwo]
[--strip-symbols=filename] [--strip-unneeded] infile [outfile]
(it's long. it's giving main character energy. copy it exactly, don't be cute with it π)
π DESCRIPTION π
okay so here's the tea: elfcopy copies the content of the binary object named by the argument infile over to the one named by the argument outfile, and while it's doing that it transforms everything according to whatever command line options you gave it. it's a glow-up machine for object files, no cap β¨
and if you don't specify the argument outfile? then elfcopy creates a temporary file and eventually renames it as infile. so it edits in place, lowkey dramatic of it, but okay π
heads up bestie: because of that temporary-file-then-rename thing, if you don't give it anoutfile, yourinfilegets replaced. just so you know. π
the elfcopy utility supports the following options:
β¨ the options, all of them, every single one β¨
-Iobjformat|-sobjformat|--input-target=objformatβ says that the input file named byinfileis in the object format specified byobjformat. you're telling it what it's looking at π-Ksymbolname|--keep-symbol=symbolnameβ copies the symbol named bysymbolnameto the output. keep her! she stays! π-Lsymbolname|--localize-symbol=symbolnameβ makes the symbol named bysymbolnamelocal to the output file. she's staying home now, not going out π-Nsymbol|--strip-symbol=symbolnameβ do not copy the symbol named bysymbolnameto the output. she's not invited. blocked. π«-Oobjformat|--output-target=objformatβ writes the output file using the object format given inobjformat. that argument should be one of the target names recognized byelftc_bfd_find_target(3). yes, really, that's the rule π-Rsectionname|--remove-section=sectionnameβ removes any section with the namesectionnamefrom the output file. gone, deleted, unfollowed β¨-S|--strip-allβ do not copy symbol and relocation information to the target file. scorched earth, no survivors π-V|--versionβ prints a version identifier and exits. quick little hello then bounce π-Wsymbolname|--weaken-symbol=symbolnameβ marks the symbol named bysymbolnameas weak in the output. not weak like weak, weak like ELF-weak, it's a whole thing π-X|--discard-localsβ do not copy compiler generated local symbols to the output. compiler's little scribbles stay out π-d|-g|--strip-debugβ do not copy debugging information to the target file. no debugging bestie, we ship blind π-h|--helpβ displays a help message and exits. the "what does anything do" button π«Ά-jsectionname|--only-section=sectionnameβ copies only the section named bysectionnameto the output. one section only, exclusive guest list π-p|--preserve-datesβ sets the access and modification times of the output file to the same as those of the input. keeps the timestamps matching, so nothing looks sus π°οΈ-w|--wildcardβ uses shell-style patterns to name symbols. the following metacharacters are recognized in patterns:!β if this is the first character of the pattern, it inverts the sense of the pattern match. "not this" energy π*β matches any string of characters in a symbol name. the classic β¨?β matches zero or one character in a symbol name. zero or one, not exactly one, write that down π[β marks the start of a character class. here comes the group π\β removes the special meaning of the next character in the pattern. escape hatch π]β marks the end of a character class. and that's the group closed π¦
-x|--discard-allβ do not copy non-global symbols to the output. local kids stay home π‘--add-gnu-debuglink=filenameβ creates a.gnu_debuglinksection in the output file that references the debug data infilename. a little link back to the receipts π--add-sectionsectionname=filenameβ adds a brand new section to the output file with the namesectionname. the contents of that section get taken from the file named byfilename, and the size of the section will be the number of bytes in the filefilename. new section just dropped π--adjust-section-vmasection{+|-|=}val|--change-section-addresssection{+|-|=}valβ depending on which operator you specified, increases, decreases, or sets both the virtual memory address and the load memory address of the section named bysection. the argumentvalis your desired increment, decrement, or brand new value for the address. two addresses, one option, efficient queen β¨--adjust-start=increment|--change-start=incrementβ increases the entry point address of the output ELF object by the value inincrement. nudge the entry point up π--adjust-vma=increment|--change-addresses=incrementβ increases the virtual memory address and the load memory address of all sections by the value given inincrement. all of them. every single one. periodt π--adjust-warnings|--change-warningsβ issues a warning if the section specified by the options--change-section-address,--change-section-lma, or--change-section-vmadoesn't exist in the input object. this is the default, so it's already on, you don't have to ask twice π’--change-section-lmasection{+|-|=}valβ changes or sets the load memory address of the section named bysection. depending on the operator, the value invalgets used as an increment, a decrement, or as the new value of the load memory address. just the LMA, not the other one π--change-section-vmasection{+|-|=}valβ changes or sets the virtual memory address of the section named bysection. depending on the operator, the value invalgets used as an increment, a decrement, or as the new value of the virtual memory address. just the VMA this time π¦--extract-dwoβ copies only the.dwodebug sections to the output file. dwo girlies rise πΈ--gap-fill=valβ fills the gaps between sections with the byte value specified byval. filling the awkward silences π«Ά--globalize-symbol=symbolnameβ makes the symbol named bysymbolnameglobal, so it's visible outside of the file it's defined in. she's going public, she's touring π--globalize-symbols=filenameβ makes each symbol listed in the file specified byfilenameglobal. a whole list of them, mass glow-up β¨--localize-hiddenβ makes all hidden symbols local to the output file. this includes symbols with internal visiblity. yes, the manpage says "visiblity", we're leaving it π--localize-symbols=filenameβ makes each symbol listed in the file specified byfilenamelocal to the output file. the group chat stays private π--no-adjust-warnings|--no-change-warningsβ do not issue a warning if the section specified by the options--change-section-address,--change-section-lma, or--change-section-vmais missing in the input object. silence is golden, missing section is fine apparently π--only-keep-debugβ copies only debugging information to the output file. debug only, everything else stays home π--pad-to=addressβ pads the load memory address of the output object to the value specified byaddressby increasing the size of the section with the highest load memory address. the tallest section gets stretched, sorry babe π--prefix-alloc-sections=stringβ prefixes the section names of all the allocated sections withstring. every allocated section gets a little name tag π·οΈ--prefix-sections=stringβ prefixes the section names of all the sections withstring. all of them this time, no exceptions β¨--prefix-symbols=stringβ prefixes the symbol names of all the symbols withstring. matching outfits for every symbol π--rename-sectionoldname=newname[,flags]β renames the section named byoldnametonewname, optionally changing that section's flags to whateverflagssays. the allowed values for the argumentflagsare the same as for the option--set-section-flagsright below. a rebrand π¦--set-section-flagssectionname=flagsβ sets the flags for the section named bysectionnameto those specified byflags. the argumentflagsis a comma separated list of these flag names:allocβ the section occupies space in the output file. she takes up room, and she deserves it πcodeβ the section contains machine instructions. actual code, not vibes π€contentsβ this flag is accepted but is ignored. accepted and ignored, we love a polite no-op πdataβ the section contains writeable data. writable, like your notes app πdebugβ the section holds debugging information. bug-hunting HQ πloadβ the section is loadable. it gets loaded π₯noloadβ the section should not be loaded into memory. stay out of memory bestie π«readonlyβ the section is not writable. hands off πromβ the section contains ROM'able contents. yes,ROM'ablewith the apostrophe, exactly like that πshareβ this flag is accepted but is ignored. another polite no-op, iconic of it π
--set-start=addressβ sets the start address of the output ELF object to the value specified byaddress. set the start, set the tone β¨--srec-forceS3β only generates S-records of type βS3β. this option is only meaningful when the output target is set to βsrecβ. S3 only, no other flavors π₯--srec-len=valβ sets the maximum length of an S-record line toval. this option is only meaningful when the output target is set to βsrecβ. keep those lines short and cute π--strip-dwoβ do not copy.dwodebug sections to the output file. sorry dwo girlies, you're out π--strip-symbols=filenameβ do not copy any of the symbols specified byfilenameto the output. the whole blocklist, applied π«--strip-unneededβ do not copy symbols that are not needed for relocation processing. if relocation doesn't need you, you're not coming π
π DIAGNOSTICS π
the elfcopy utility exits 0 on success, and >0 if an error occurs. zero is the slay number, anything above is a situation π«Ά
π SEE ALSO π
ar(1), ld(1), mcs(1), strip(1), elf(3), elftc_bfd_find_target(3), ar(5), elf(5)
go read those too, iykyk π
π§ COMPATIBILITY π§
the elfcopy utility is expected to be option compatible with GNU objcopy. so if you already know that one, you already know this one, bestie π€
β HISTORY β
elfcopy has been implemented by Kai Wang <kaiwang27@users.sourceforge.net>. legend behavior, honestly π
and that's the whole page!! every flag, every operator, every flag name, every reference β all present and accounted for π
this edition of the elfcopy(1) manual page came from Debian and is dated August 30, 2017 β go off, 2017, you ate πβ¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- nixpkgs unstable: elfcopy 15.0.0
- Copyright (c) 2008-2009,2011 Joseph Koshy. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms