I've embedded a text file in a C program using the following method: http://www.linuxjournal.com/content/embedding-file-executable-aka-hello-world-version-5967
a.out:prog.c file.text
objcopy --input binary --output elf64-x86-64 --binary-architecture i386 file.text file.o
gcc prog.c file.o
objcopy requires to specify the target with the "--output" option.
How can I set "--output" in Makefile so objcopy will use the user's architecture ?
Thanks.
Firstly: You are not trying to emulate the
-b
capability of the GCC ld, are you? In more verbose terms: The GCC ld can actually load a number of binary formats, see the documentation. If that's what you want to achieve, something like:might save you the whole objcopy call.
While I'm not able to find documentation on the issue, the output of
objdump -i
seems to be sorted by preference, soshould expand to the usual target architecture. Stating again: I have no documentation on this behaviour, so better don't rely blindly on it.