Aren't there many tools out there that can already do this? I thought even objcopy(1) can turn an arbitrary file into a .o file containing a single symbol holding the data.
objcopy --input binary --output elf64-x86-64 myfile.txt myfile.o extern char foo_start[] asm("section$start$__DATA$__foo");
extern char foo_end[] asm("section$end$__DATA$__foo");Windows under MSVC doesn't use ELF either (it uses PE for the .EXE) and it links in intermediate ELF object files fine. I've made an EXE that was a mix of files compiled by MSVC and GCC.