Re: some tiny and dumb questions

Michael Elizabeth Chastain (mec@shout.net)
Mon, 18 May 1998 20:50:50 -0500


Hi Thomas,

Someone wrote:
> It's fairly simple to write a tool that translates an
> arbitrary binary file into an equivalent C array declaration...

Ok, I made a little sample program using gnu ld. I've appended
it as a shell script after this message.

Hope this helps somebody,

Michael Chastain
<mailto:mec@shout.net>
"love without fear"

#! /bin/sh
rm -r foo
cp /etc/issue foo
ld --format binary --oformat elf32-i386 -r -o foo.o foo
cat << 'HERE' > main.c
#include "stdio.h"
extern char _binary_foo_start;
extern char _binary_foo_end;
int main ()
{
printf( "%X %X\n", &_binary_foo_start, &_binary_foo_end );
printf( "%.*s\n",
&_binary_foo_end - &_binary_foo_start, &_binary_foo_start );
return 0;
}
HERE
cc main.c foo.o
a.out

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu