ELFCOPY(1)

πŸ“¦ version 15.1, in freebsd 15.1, nixpkgs unstable

πŸ’… 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 an outfile, your infile gets replaced. just so you know. πŸ™ˆ

the elfcopy utility supports the following options:

✨ the options, all of them, every single one ✨

  • -I objformat | -s objformat | --input-target=objformat β€” says that the input file named by infile is in the object format specified by objformat. you're telling it what it's looking at πŸŽ€
  • -K symbolname | --keep-symbol=symbolname β€” copies the symbol named by symbolname to the output. keep her! she stays! πŸ’–
  • -L symbolname | --localize-symbol=symbolname β€” makes the symbol named by symbolname local to the output file. she's staying home now, not going out 🏠
  • -N symbol | --strip-symbol=symbolname β€” do not copy the symbol named by symbolname to the output. she's not invited. blocked. 🚫
  • -O objformat | --output-target=objformat β€” writes the output file using the object format given in objformat. that argument should be one of the target names recognized by elftc_bfd_find_target(3). yes, really, that's the rule πŸ“‹
  • -R sectionname | --remove-section=sectionname β€” removes any section with the name sectionname from 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 πŸ‘‹
  • -W symbolname | --weaken-symbol=symbolname β€” marks the symbol named by symbolname as 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 🫢
  • -j sectionname | --only-section=sectionname β€” copies only the section named by sectionname to 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_debuglink section in the output file that references the debug data in filename. a little link back to the receipts πŸ”—
  • --add-section sectionname=filename β€” adds a brand new section to the output file with the name sectionname. the contents of that section get taken from the file named by filename, and the size of the section will be the number of bytes in the file filename. new section just dropped πŸ’–
  • --adjust-section-vma section{+|-|=}val | --change-section-address section{+|-|=}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 by section. the argument val is 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 in increment. 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 in increment. 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-vma doesn't exist in the input object. this is the default, so it's already on, you don't have to ask twice πŸ“’
  • --change-section-lma section{+|-|=}val β€” changes or sets the load memory address of the section named by section. depending on the operator, the value in val gets 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-vma section{+|-|=}val β€” changes or sets the virtual memory address of the section named by section. depending on the operator, the value in val gets 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 .dwo debug sections to the output file. dwo girlies rise 🌸
  • --gap-fill=val β€” fills the gaps between sections with the byte value specified by val. filling the awkward silences 🫢
  • --globalize-symbol=symbolname β€” makes the symbol named by symbolname global, 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 by filename global. 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 by filename local 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-vma is 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 by address by 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 with string. every allocated section gets a little name tag 🏷️
  • --prefix-sections=string β€” prefixes the section names of all the sections with string. all of them this time, no exceptions ✨
  • --prefix-symbols=string β€” prefixes the symbol names of all the symbols with string. matching outfits for every symbol πŸ’–
  • --rename-section oldname=newname[,flags] β€” renames the section named by oldname to newname, optionally changing that section's flags to whatever flags says. the allowed values for the argument flags are the same as for the option --set-section-flags right below. a rebrand πŸ¦‹
  • --set-section-flags sectionname=flags β€” sets the flags for the section named by sectionname to those specified by flags. the argument flags is 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'able with 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 by address. 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 to val. this option is only meaningful when the output target is set to β€œsrec”. keep those lines short and cute πŸ“
  • --strip-dwo β€” do not copy .dwo debug sections to the output file. sorry dwo girlies, you're out 😭
  • --strip-symbols=filename β€” do not copy any of the symbols specified by filename to 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