Embedding binary blobs using gcc mingw

Posted by myforwik on Stack Overflow See other posts from Stack Overflow or by myforwik
Published on 2010-04-13T04:38:33Z Indexed on 2010/04/13 4:42 UTC
Read the original article Hit count: 346

Filed under:
|
|
|

I am trying to embed binary blobs into an exe file. I am using mingw gcc.

I make the object file like this:

ld -r -b binary -o binary.o input.txt

I then look objdump output to get the symbols:

objdump -x binary.o

And it gives symbols named:

_binary_input_txt_start
_binary_input_txt_end
_binary_input_txt_size

I then try and access them in my C program:

#include <stdlib.h>
#include <stdio.h>

extern char _binary_input_txt_start[];

int main (int argc, char *argv[])
{
    char *p;
    p = _binary_input_txt_start;

    return 0;
}

Then I compile like this:

gcc -o test.exe test.c binary.o

But I always get:

undefined reference to _binary_input_txt_start

Does anyone know what I am doing wrong?

© Stack Overflow or respective owner

Related posts about c

    Related posts about mingw