<div dir="ltr">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.<div><br></div><div>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?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 14, 2016 at 11:24 AM, Ed Maste via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">One of the issues I reported in using lld as the FreeBSD base system<br>
linker is that the base system currently uses ld -r to convert a<br>
binary file (device firmware image) into an ELF object:<br>
<br>
> A tool for loading firmware into a wireless USB device includes a<br>
> built-in copy of the firmware image, and the image is converted to an<br>
> ELF file using ld -r.<br>
<br>
The invocation is:<br>
ld -b binary -d -warn-common -r -d -o ar5523.o ar5523.bin<br>
which produces an object with a .data section containing the binary<br>
data, and symbols for the start, end, and size.<br>
<br>
I think the -d here has no effect and could be dropped, but we do not<br>
support "-b binary" in lld. Originally I thought this is somewhat<br>
strange functionality for a linker to support, and assumed there'd be<br>
no interest in adding support to lld.<br>
<br>
It could be addressed in FreeBSD by using objcopy or just converting<br>
the binary blob to a C array and treating it as another source file.<br>
<br>
That said, I was surprised to find that gold also supports this use,<br>
so perhaps it's less strange than I thought. Before I go and make a<br>
change in FreeBSD I want to see what others think about supporting "-b<br>
binary" in lld.<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div>