Re: generating mach-o executable files by hand
Re: generating mach-o executable files by hand
- Subject: Re: generating mach-o executable files by hand
- From: Joel Reymont <email@hidden>
- Date: Fri, 9 Jan 2009 20:28:03 +0000
Terry,
On Jan 9, 2009, at 8:03 PM, Terry Lambert wrote:
Section
sectname __text
segname __TEXT
addr 0x00001308
size 0x00000039
offset 776
align 2^0 (1)
This alignment is incorrect; the linker would have specified the
correct alignment.
Yes, I decided not to bother with the "correct" alignment. The app
runs so I kept it.
You do not appear to have a section __cstring, which is where you
would keep the static string you passed to printf, since it is a
static string, which by default should not be a writeable symbol.
Yes, an oversight.
I also need writable TEXT segments for self-modifying code, which I
haven't enabled here.
You do not have an __unwind_info section; however, since that's used
to support C++, ObjC, etc. exception handling, and since you aren't
using the linker, there's no way to cause you code to be linked with
this sort of library, that's probably an acceptable omission for you
(but maybe not for your customers).
I'll add it later, thanks for pointing it out.
You are missing the __dyld __DATA section which would be normally
included as a result of linking with the linker. This means that
interfaces which did not use it would work, but interfaces which do
use it (for example, code which returns pointers to static data
areas), would crash.
Will investigate. Can you give me an example of such C code?
Better yet, could you explain why such does uses the __dylb __DATA
section?
You are missing an LC_UUID.
Yes, I decided not to bother with it.
I assume you very much understand the difference between a linker
and a loader; the ld command can act both as a linker and a loader,
but by preventing it acting as a linker, you are cutting yourself
off from linking against libraries other than the ones you already
know about.
I'm not sure what you mean. I thought I can always load other shared
libraries using dlopen and friends. Is that not so?
Again, the reason I'm doing this is that I cannot use the linker. I
don't use a C compiler or an assembler either. This is Forth (as in
OpenFirmware) and I'm building the image in memory and dumping it to
disk... On Linux!
Thanks, Joel
P.S. I'm looking to switch away from system calls once I have cross-
compiled.
--
http://wagerlabs.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden