Re: mach-o: why is code placed towards the end of a page?
Re: mach-o: why is code placed towards the end of a page?
- Subject: Re: mach-o: why is code placed towards the end of a page?
- From: Andrew Myrick <email@hidden>
- Date: Thu, 08 Jan 2009 16:08:02 -0800
I neglected to reply to the list. Here is my complete reply for
context:
Joel,
The linker always places code on a power-of-2 boundary towards the
end of the page. Is there a reason for this?
The Mach-O headers are indeed at the beginning of the file, but when
they are mapped into a program's address space, those headers are
placed at the start of the __TEXT segment, and the actual text follows
those headers. When the text is smaller than the available remaining
space in the first page, it is placed at the end of the page as you
have noticed. When the text is larger than the remaining space, it
will begin at the end of the headers and continue on into the next page.
I can't say for certain why it is implemented this way, but I can
speculate that it is so that the text is adjacent to the __DATA
segment on the following page.
Can the code be placed at the beginning of the page instead?
The headers are always placed at the beginning of the __TEXT segment,
so the actual code will never be at the first byte of that segment,
regardless of whether the text is placed at the end of the headers or
the end of the page.
Is this layout preventing you from doing something?
-Andrew
_______________________________________________
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