1

I was reading the man page for the ancient a.out format (located here), trying to understand the evolution of Unix executable formats. I was wondering about something. The man page says that if the magic number is OMAGIC, then the text segment is not shared with other processes and no write-protection is placed on it, and the data segment begins immediately after it in memory (at the next byte). But if the magic number is NMAGIC or ZMAGIC, the text segment is write-protected and shared with other processes running the same program, and in this case the data segment begins at the beginning of the next 1024-byte block. Why is this so? Why does the sharing of the text segment necessitate the data segment beginning on a 1024-byte boundary? I have a feeling this is something that applies generally and is not specific to the a.out format.

1

That is done to align the data segment on a page boundary (which automatically forces it to be in a different page from the text segment). With that clue, you should be able find further information such as John Levine's explanation in Linkers and Loaders.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.