Looks good. The reason I know a bit about this is I had the same "bin2o" hacky script that used objcopy. It broke every time someone found a new architecture or platform (ie. having to choose the correct -O and -B flags is non-trivial if you want to support every architecture).
The solution (which is not really much better than yours) is a script that creates some assembler and assembles it:
The solution (which is not really much better than yours) is a script that creates some assembler and assembles it:
https://github.com/libguestfs/supermin/blob/master/src/bin2s...
I think it's bad that such a simple thing is so hard to do.
Edit: In fact looking at the script now I can see we really should be using .rodata instead of .data. That bug has survived for at least 4 years. Patch posted: https://www.redhat.com/archives/libguestfs/2015-December/msg...