Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do virtual memory addresses for linux binaries start at 0x8048000?

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?

like image 262
aks Avatar asked Jun 03 '10 13:06

aks


People also ask

Why is the kernel virtual address area smaller in large memory situations?

●In a large memory situation, the kernel virtual address area is smaller, because there is more physical memory. ●An interesting case, where more memory means lessspace for kernel virtual addresses.

Is the virtual address valid in Linux?

●The virtual address is valid, but swapped out. –This is a software condition Kernel Virtual Memory Kernel Virtual Memory ●In Linux, the kernel uses virtual addresses, as user space processes do. ●This is not true of all OS's ●Virtual address space is split. ●The upper part is used for the kernel ●The lower part is used for user space

What are the limitations of 32-bit large-memory systems?

●For 32-bit large-memorysystems (more than ~1GB RAM), not all of the physical RAM can be mapped into the kernel's address space. ●Kernel address space is the top 1GB of virtual address space, by default. ●Further, ~104 MB is reserved at the top of the kernel's memory space for non-contiguous allocations –See vmalloc() described later

What is virtual memory and how it works?

●Virtual Memoryis a system that uses an address mapping ●Maps virtualaddress space to physicaladdress space –Maps virtual addresses to physical RAM –Maps virtual addresses to hardware devices ●PCI devices ●GPU RAM ●On-SoC IP blocks What is Virtual Memory? ●Advantages ●Each processes can have a different memory mapping


1 Answers

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.)

like image 137
Bastien Léonard Avatar answered Sep 23 '22 19:09

Bastien Léonard