Re: Section Alignment in mach-o files
Re: Section Alignment in mach-o files
- Subject: Re: Section Alignment in mach-o files
- From: Terry Lambert <email@hidden>
- Date: Wed, 14 May 2008 12:56:04 -0700
According to the documentation on <http://developer.apple.com>, which
you should probably read before you get too far into manipulating Mach-
o files, the alignment is in memory.
However, be aware that many people deal with "what works" rather than
"what's documented", and therefore there could be all sorts of code
making assumptions about physical layout of the file.
As an example, when I did the 64 bit exec bringip in the kernel, I had
the chicken and egg problem of not having 64 bit Mach-o binaries to
load, and not being able to create them because I didn't have anything
to load them with to know they had been created correctly.
So I cheated; I "knew" that the Mach-o header was written in the first
4K, and I "knew" that the first 4K was incompletely used, and I "knew"
that the first section after the header was aligned to a 4K boundary.
Using these three assumptions not actually guaranteed anywhere in the
ABI, I wrote a program to take a 32 bit Mach-o, convert the sections
and load commands to 64 bit versions of themselves, and then proceeded
to write code to load the resulting 32-in-64 binaries. The entire
bringup of 64 bit exec was done on a dual G4, months before I had real
G5 hardware.
The normal admonition in these cases has been floationg around the
IETF for years, but I'll repeat it here: be very strict in the data
you generate, and as liberal as possible in the data you accept, if
you want to ensure the highest probability of interoperability.
-- Terry
On May 14, 2008, at 2:06 AM, MT <email@hidden> wrote:
I have a question about the section alignment specified in the load
command in a mach-o file.
Is the alignment only relevant for the virtual address, or also for
the file offset? Some tests with otool seem to indicate that both
the virtual address and the file offset seem to respect that
alignment normally, but does it need to be this way?
Thanks for any insight
Mark
_______________________________________________
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
_______________________________________________
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