[llvm-dev] llvm-objcopy proposal

Ed Maste via llvm-dev llvm-dev at lists.llvm.org
Fri Jun 2 11:34:47 PDT 2017

On 1 June 2017 at 20:21, Jake Ehrlich via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> LLVM already implements its own version of almost all of binutils. The
> exceptions to this rule are objcopy and strip. This is a proposal to
> implement
> an llvm version of objcopy/strip to complete llvm’s binutils.

A bit of info from the FreeBSD perspective. In FreeBSD we use ELF Tool
Chain versions of most binutils (addr2line, c++filt, objcopy, nm,
size, strings, strip, readelf) and bespoke versions of other tools
(ar, elfdump, ranlib). The exceptions are as (for which we have no
replacement), ld.bfd (we've switched to LLD for arm64 and are working
on other architectures), and objdump (investigating llvm-objdump,
although it still has some limitations).

That said, I would very much like to see LLVM equivalents for all of
the tools so that we can compare and benchmark against other
implementations, and so that we have an alternative available if it
becomes necessary. I would be happy for llvm-objcopy to exist.

> 1. Use Case: Stripping debug information of an executable to a file
> 6. Use Case: DWARF fission
> 8. Use Case: Adding a gdb index

It seems like these ought to just be done by the linker. We don't yet
use (6) in FreeBSD because our toolchain is still using some ancient
components on most architectures but it is something I very much wish
to start doing.

> 2. Use Case: Stripping debug information of a relocatable object to a file
>    Who uses it: None of the 4 projects considered
> 5. Use Case: “Complete stripping” an executable
>    Who uses it: None of the 4 projects
>    ```sh
>    eu-strip --strip-sections foo
>    ```

I'd be surprised to find this being used.

> 3. Use Case: Stripping debug information of a shared library to a file
> 4. Use Case: Stripping an executable
> 7. Use Case: Converting an executable to binary
> 9. Use Case: Converting between formats [ELF->PE]
> 12. Use Case: Removing a specific unwanted section

We use these cases in FreeBSD.

One additional use case for you: converting from a binary to an ELF object file
objcopy -I binary -O elf64-x86-64 foo.bin foo.o
This is sometimes used for embedding binary files for use by drivers and such.

More information about the llvm-dev mailing list