Disassembling an ELF binary on a Ubuntu x86 system I couldn’t help but notice that the code(.text) section starts from the virtual address 0x8048000 and all lower memory addresses seem to be unused.
This seems to be rather wasteful and all Google turns up is either folklore involving STACK_TOP or protection against null-pointer dereferences. The latter case looks like it can be fixed by using a single page instead of leaving a 128MB gap.
So my question is this – is there a definitive answer to why the layout has been fixed to these values or is it just an arbitrary choice?
From the Linkers and loaders book:
On 386 systems, the text base address is 0x08048000, which permits a reasonably large stack below the text while still staying above address 0x08000000, permitting most programs to use a single second-level page table. (Recall that on the 386, each second-level table maps 0x00400000 addresses.)