Using Mingw for Windows 10, and looking into solutions to add a file as a binary for linking. I thought I would start simple by adding a text file, called text.txt that contains the message "Hello, world!" , to my program. I'm using objcopy.exe to do this.
I've managed to create the binary of text.txt okay and using objdump -t text.o, it produces the following symbol table...
text.o: file format elf32-i386
SYMBOL TABLE:
00000000 l d .data 00000000 .data
00000000 g .data 00000000 _binary_text_txt_start
0000000c g .data 00000000 _binary_text_txt_end
0000000c g *ABS* 00000000 _binary_text_txt_size
...and the main source file contains the following...
#include <stdio.h>
extern char _binary_text_txt_start;
extern char _binary_text_txt_end;
extern char _binary_text_txt_size;
void main()
{
printf( "\n\nFILE SIZE: %d\n\n", _binary_text_txt_size );
}
...but then compiling the project produces the following error...
undefined reference to `_binary_text_txt_size' collect2.exe: error: ld returned 1 exit status
...which has me confused as the symbol table clearly has _binary_text_txt_size defined. Just wondered if anyone can shed light on what I am overlooking?
Cheers.