[llvm-dev] [lld] supporting binary-to-ELF conversion

Ed Maste via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 14 15:46:07 PDT 2016


On 14 March 2016 at 21:32, Rui Ueyama <ruiu at google.com> wrote:
> That command uses the linker to wrap a blob with an ELF header. This is an
> interesting feature, but it seems to me that that is too specific to some
> special use case. Linkers are, well, to link stuff, and in this case this
> links nothing. If the linker hadn't supported "-b binary", they would have
> done this in a different way.

Ok, that was my thought as well. I only second-guessed it when I found
gold supports it, since as far as I know the intent of gold's design
was to support only ELF linking.

> I think this use case should be done using objdump. You can create an empty
> ELF file using as or something, and copy the blob to .text section using
> objcopy, no?

Yes, objcopy works much as ld -r for this use case, except that
objcopy needs the output machine type to be specified explicitly. This
is probably another argument against supporting it in lld, actually --
we'd need the notion of a default output format.


More information about the llvm-dev mailing list