Say I want to embed a file called data
in my C executable.
The result which comes up from google is this linuxjournal page which says use objdump
like this
objcopy --input binary \
--output elf32-i386 \
--binary-architecture i386 data data.o
However this is dependent on the architecture of the computer, for example when compiling the object from the previous command it gives i386 architecture of input file 'data.o' is incompatible with i386:x86-64 output
and I have to change the arguments.
However with the unix tool xxd, I can simply make a c source code with the data in a unsigned char array and an integer with its length and obtain the same result with device independent compilation commands.
data.o: data.c
gcc -c data.c
data.c: data
xxd -i data > data.c
What is the preferred method and why?