Object file tools

Hello!

Does LLVM provide tools for working with object files? I'm particularly interested in strip and elfcopy tools. Are they a thing? Can they be implemented? Or maybe they are already implemented under different names that I don't know about?

I suppose that with LLD there was a lot of code written for working with ELF, COFF and MachO, so it would be relatively easy to implement llvm-strip and llvm-objcopy.

Regards,
Dmitry

Hello!

Does LLVM provide tools for working with object files? I'm particularly interested in strip and elfcopy tools. Are they a thing? Can they be implemented? Or maybe they are already implemented under different names that I don't know about?

You mean objcopy(1)? Anyway, no, LLVM doesn't implement replacements
for strip/objcopy.
The main issue is that lib/Object only knows how to read object files
but not how to manipulate them. So, as a first step LLVM should grow
this support (in lib/Object or in another library).

I suppose that with LLD there was a lot of code written for working with ELF, COFF and MachO, so it would be relatively easy to implement llvm-strip and llvm-objcopy.

Not sure how much code can be actually factored out. There's some
commonality (e.g. between a subset of the features of objcopy and `ld
-r`) but it's an open question how much of it can be reused.

> Hello!
>
> Does LLVM provide tools for working with object files? I'm particularly
interested in strip and elfcopy tools. Are they a thing? Can they be
implemented? Or maybe they are already implemented under different names
that I don't know about?
>

You mean objcopy(1)? Anyway, no, LLVM doesn't implement replacements
for strip/objcopy.
The main issue is that lib/Object only knows how to read object files
but not how to manipulate them. So, as a first step LLVM should grow
this support (in lib/Object or in another library).

IIUC, providing binutils tools is a part of a LLVM project goal, so sooner
or later we need to write llvm-objcopy and llvm-strip, though I know no one
working on these tools at the moment.

As an aside, for anyone looking for an alternative to binutils (while
suitable LLVM-based ones are not available) the ELF Tool Chain project
provides a reasonably complete set under a BSD license. This is what
we're currently using in FreeBSD for objcopy, strip, nm, etc.

https://sourceforge.net/p/elftoolchain