bin2obj using llvm


as a compiler can generate object files (COFF, ELF etc.) I wonder if
it is possible to create a bin to object converter (e.g. for image data)
using llvm.

I have found the classes TargetLoweringObjectFileCOFF but
I don't know how to fill it with data and save it. Can you give me a hint
how it works or where in clang I can see how it works.


As an aside, if you’re find with using an alternative tool, I’ve found gnu ld to work fine for this.

ld -r -b binary -o foo.o foo.png
objcopy --rename-section .data=.rodata,alloc,load,readonly,data,contents foo.o

-Bill Lynch


I'd like to use llvm since it is library based and supports multiple targets.