Data-only static libraries with GCC
Posted
by
regularfry
on Stack Overflow
See other posts from Stack Overflow
or by regularfry
Published on 2011-03-08T16:05:09Z
Indexed on
2011/03/08
16:10 UTC
Read the original article
Hit count: 198
How can I make static libraries with only binary data, that is without any object code, and make that data available to a C program? Here's the build process and simplified code I'm trying to make work:
./datafile
:
abcdefghij
Makefile
:
libdatafile.a:
ar [magic] datafile
main: libdatafile.a
gcc main.c libdatafile.a -o main
main.c
:
#define TEXTPTR [more magic]
int main(){
char mystring[11];
memset(mystring, '\0', 11);
memcpy(TEXTPTR, mystring, 10);
puts(mystring);
puts(mystring);
return 0;
}
The output I'm expecting from running main
is, of course:
abcdefghijabcdefghij
My question is: what should [magic] and [more magic] be?
© Stack Overflow or respective owner