Re: making a data file
Re: making a data file
- Subject: Re: making a data file
- From: Steve Checkoway <email@hidden>
- Date: Mon, 26 Dec 2005 10:13:04 -0800
On Dec 26, 2005, at 7:17 AM, D. Walsh wrote:
I take it there are no really knowledgeable people on this list who
know how to use GCC to compile a source file to obtain a valid data
file?
You've asked this twice before and when people have replied, you've
neglected to reply back, at least to the list.
Gcc makes object files. I suggest you take a look at the format of
mach-o object files:
http://developer.apple.com/documentation/DeveloperTools/Conceptual/
MachORuntime/MachORuntime.pdf
I don't think that gcc can do what you want but it might be possible
to write a script or program to parse the file and write the data
yourself or to use gcc to produce a mach-o object file and then strip
off the mach header and the section headers. In no tools exist to do
that directly then you could write your own or use otool -s __DATA
__data on the object file to dump the (__DATA,__data) section but
you'd have to parse that as well.
For example, I can do this on an object file I had lying around:
$ otool -s __TEXT __text name.o|perl -ne 'next unless /[\da-f]
{6}/;@_=split; shift @_; print pack "H*", $_ for (@_)' > name.text
And now I've dumped the (__TEXT,__text) section of name.o to the file
name.text.
$ xxd name.text
0000000: bfc1 fff8 9421 ffd0 7c3e 0b78 8021 0000 .....!..|>.x.!..
0000010: bbc1 fff8 4e80 0020 bfc1 fff8 9421 ffd0 ....N.. .....!..
0000020: 7c3e 0b78 907e 0048 3800 0001 7c03 0378 |>.x.~.H8...|..x
0000030: 8021 0000 bbc1 fff8 4e80 0020 bfc1 fff8 .!......N.. ....
0000040: 9421 ffd0 7c3e 0b78 d03e 0048 d85e 0018 .!..|>.x.>.H.^..
0000050: 3800 0000 7c03 0378 8021 0000 bbc1 fff8 8...|..x.!......
0000060: 4e80 0020 N..
When I just use otool, I get:
$ otool -s __TEXT __text name.o
name.o:
(__TEXT,__text) section
00000000 bfc1fff8 9421ffd0 7c3e0b78 80210000
00000010 bbc1fff8 4e800020 bfc1fff8 9421ffd0
00000020 7c3e0b78 907e0048 38000001 7c030378
00000030 80210000 bbc1fff8 4e800020 bfc1fff8
00000040 9421ffd0 7c3e0b78 d03e0048 d85e0018
00000050 38000000 7c030378 80210000 bbc1fff8
00000060 4e800020
So if you must use gcc to make data files, just run otool and pipe it
though that simple perl script.
I suggest doing it some other way.
- Steve
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden