Liste des Groupes | Revenir à cl c |
On Thu, 30 May 2024 14:34:00 +0100Where do the _binary_logo_bmp_start and ...-size symbols come from? That is, how do they get into the object file.
bart <bc@freeuk.com> wrote:
On 30/05/2024 03:32, Lawrence D'Oliveiro wrote:extern unsigned char _binary_logo_bmp_start[];On Wed, 29 May 2024 13:58:20 +0200, Bonita Montero wrote:>
I've got a small commandline-tool that makes a const'd char>
-array from any binary file.
It seems to me it would be more efficient to use objcopy to turn
that binary file directly into an object file with symbols
accessible from C code defining its beginning and ending points.
Then just link it into the executable.
None of my compilers, whether for C or anything else, generate object
files.
>
However, suppose I wanted to link a file called 'logo.bmp' say, into
my program, which consisted of a file called main.c.
>
What is the entire process using your suggestion? What do I put into
main.c? Assume the data is represented by a char-array.
>
extern unsigned char _binary_logo_bmp_size[];
The first symbol is an array itself.
The seconded symbol contains the length of array. You use it in somewhat
non-intuitive way:
size_t my_size = (size_t)_binary_logo_bmp_size;
Pay attention that I never used this method myself, just took a look at
the output of objcopy with 'objdump -t', so please don't take my words
as a sure thing.
BTW, options in this case are rather simple:
objcopy -I binary -O elf32-little logo.bmp logo_bmp.o
Replace elf32-little with relevant format for your software. However IThere appears to be an objcopy utility that runs under Windows.
am not sure that it would work for none-elf output formats.
Les messages affichés proviennent d'usenet.