Skip to content

objcopy isn't sweaty #24522

Backlog
Backlog

Description

@andrewrk

// note: this is "a minimal effort implementation"
// It doesn't support all possibile elf files: some sections type may need fixups, the program header may need fix up, ...
// It was written for a specific use case (strip debug info to a sperate file, for linux 64-bits executables built with `zig` or `zig c++` )
// It moves and reoders the sections as little as possible to avoid having to do fixups.
// TODO: support non-native endianess
fn ElfFile(comptime is_64: bool) type {

This isn't up to zig project standards.

// zig objcopy doesn't support incremental binaries
.use_llvm = true,

👎 👎

Activity

  1. added this to the upcoming milestone on Jul 20, 2025
  2. added
    bug
    contributor friendly
    on Jul 20, 2025
  3. added a commit that references this issue on Aug 4, 2025
  4. xxxbxxx commented on Aug 25, 2025

    @xxxbxxx
    Contributor

    In case it is useful to someone other than me:
    I've ported the old 0.14.1 code to 0.15.1 in this package:
    https://codeberg.org/xbx/cc_helper

    (as a side note, it is soo nice to experience the 'reusable' part of the zig tagline: being able to actually just grab the objcopy.zig file from the compiler source tree and run it as-is in an other context, no fiddling with include paths or whatever. lovely!)

  5. Parzival-3141 commented on Sep 16, 2025

    @Parzival-3141
    Contributor

    I've started work on this here.

    My goal is to support the most common operations on the most common object formats.
    In other words: support adding/removing/configuring/compressing sections and symbols for ELF, COFF, and MachO objects.

    Conversion between object formats (besides "raw" formats like binary, ihex, etc.) is intentionally unsupported. This feature is rarely used and requires a huge amount of complexity in return. GNU is the only vendor that implements it and built a dedicated library to do it. LLVM drops this feature as well, although it does support converting between ELF types (endianness, architecture, 32/64bit). Zig users should either compile with the desired -ofmt or depend on GNU objcopy.

    Hopefully that's sweaty enough.

  6. Khitiara commented on Oct 12, 2025

    @Khitiara

    anyone actually working on this one? debating taking a look at it (esp given the workarounds posted) given this issue is blocking my project from updating past 0.14.1

    if no, what exactly is needed here? "sweaty" is far from descriptive and the issue gives no details on what would be required specifically

  7. Parzival-3141 commented on Oct 14, 2025

    @Parzival-3141
    Contributor

    @Khitiara I'm still working on this, I've just been busy these past couple weeks. What's your use-case? I'd be happy to collaborate!

  8. Khitiara commented on Oct 14, 2025

    @Khitiara

    @Parzival-3141 my use case is the split debug file option - turning one elf with debug info into a stripped binary and a separate debug info file

  9. marked zig objcopy: Strip support #13928 as a duplicate of this issue on Oct 16, 2025
  10. andrewrk commented on Nov 26, 2026

    @andrewrk
    MemberAuthor

    oops I mixed up objcopy and objdump 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcontributor friendly

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions