lkml.org 
[lkml]   [1998]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: some tiny and dumb questions
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

\
 
 \ /
  Last update: 2005-03-22 13:42    [W:0.153 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site