objcopy is another simpler, good choice. I need koio to provide a stdio-like API and a consistent external baseline for how embedding files is done in chopsui so that it can be consistent between chopsui, third-party chopsui libraries, chopsui applications, and end-user extensibility. To that end I found it more appropriate to write a tool like this.
Another option for those willing to use GNU C extensions is a small inline assembly fragment with the .incbin directive…wrapped up in a convenient macro approximating the usage in the article (the .len member here is admittedly a bit hackish), perhaps something like:
(This approach has the disadvantage of introducing an external file dependency that -M flags won’t report, however, so it’ll probably require a manual annotation in your makefile.)
On illumos systems we have elfwrap(1), which will create an object file with a symbol for the start and end of a region containing the bytes from the wrapped file that you can then link into C or C-like programs.
Much simpler solution that often might be enough is xxd -i.
Author of koio here.
objcopy is another simpler, good choice. I need koio to provide a stdio-like API and a consistent external baseline for how embedding files is done in chopsui so that it can be consistent between chopsui, third-party chopsui libraries, chopsui applications, and end-user extensibility. To that end I found it more appropriate to write a tool like this.
Another option for those willing to use GNU C extensions is a small inline assembly fragment with the
.incbindirective…wrapped up in a convenient macro approximating the usage in the article (the.lenmember here is admittedly a bit hackish), perhaps something like:(This approach has the disadvantage of introducing an external file dependency that
-Mflags won’t report, however, so it’ll probably require a manual annotation in your makefile.)On illumos systems we have elfwrap(1), which will create an object file with a symbol for the start and end of a region containing the bytes from the wrapped file that you can then link into C or C-like programs.
FWIW, I also made a tool like this: pyxxd
More tools like this: