amd64 process sizes

Ruslan Ermilov ru at
Sun Sep 9 02:20:04 PDT 2007

On Sat, Sep 08, 2007 at 10:53:06PM -0700, Peter Wemm wrote:
> Peter Wemm wrote:
>> 2) There is a bug in sys/kern/imgact_elf.c.  It assumes that the PT_LOAD 
>> sections are contiguous, which isn't a given.
> I think I may have outsmarted myself here.  This should be coming from 
> rtld, not the kernel.  In any case, it is still our bug.
This has to do with binutils (the section's alignment).  On i386
it's 2^12 (4KB):

: Program Header:
:     LOAD off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**12
:          filesz 0x000ca5d2 memsz 0x000ca5d2 flags r-x
:     LOAD off    0x000ca5e0 vaddr 0x000cb5e0 paddr 0x000cb5e0 align 2**12
:          filesz 0x000053f0 memsz 0x0001b404 flags rw-

But on amd64 it's 2^20 (1MB):

: Program Header:
:     LOAD off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**20
:          filesz 0x00000000000d7051 memsz 0x00000000000d7051 flags r-x
:     LOAD off    0x00000000000d7060 vaddr 0x00000000001d7060 paddr 0x00000000001d7060 align 2**20
:          filesz 0x000000000001a010 memsz 0x0000000000032df8 flags rw-

1MB gives either 255 or 256 pages when aligned.  What I don't
understand is why rtld mmaps the total sum of virtual sizes
(memsz) from the library, which often is greater than the
size of the file, but I didn't yet look close enough in the

Ruslan Ermilov
ru at
FreeBSD committer

More information about the freebsd-amd64 mailing list