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

Rui Ueyama via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 14 14:32:04 PDT 2016


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.

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?

On Mon, Mar 14, 2016 at 11:24 AM, Ed Maste via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> One of the issues I reported in using lld as the FreeBSD base system
> linker is that the base system currently uses ld -r to convert a
> binary file (device firmware image) into an ELF object:
>
> > A tool for loading firmware into a wireless USB device includes a
> > built-in copy of the firmware image, and the image is converted to an
> > ELF file using ld -r.
>
> The invocation is:
> ld -b binary -d -warn-common -r -d -o ar5523.o ar5523.bin
> which produces an object with a .data section containing the binary
> data, and symbols for the start, end, and size.
>
> I think the -d here has no effect and could be dropped, but we do not
> support "-b binary" in lld. Originally I thought this is somewhat
> strange functionality for a linker to support, and assumed there'd be
> no interest in adding support to lld.
>
> It could be addressed in FreeBSD by using objcopy or just converting
> the binary blob to a C array and treating it as another source file.
>
> That said, I was surprised to find that gold also supports this use,
> so perhaps it's less strange than I thought. Before I go and make a
> change in FreeBSD I want to see what others think about supporting "-b
> binary" in lld.
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160314/3eb00d9a/attachment.html>


More information about the llvm-dev mailing list