Why are elf segments not page aligned?

elf

Solution

Assuming a page size of 4096 (0x1000) bytes and rounding addresses to page granularities:

- The first loadable segment would use the address range [0x8048000--0x8060FFF], both ends inclusive.

- The second loadable segment would use the address range [0x8061000--0x8062FFF], of which 0x3F4 bytes starting at address 0x8061EEC would come from the executable, with the rest being zero-filled at load time.

There is no overlap.

Problem

`readelf -l /bin/ls`: ``` LOAD 0x000000 0x08048000 0x08048000 0x18ff8 0x18ff8 R E 0x1000 LOAD 0x019eec 0x08061eec 0x08061eec 0x003f4 0x01014 RW 0x1000 ``` So the boundary page between the two segments is both read-only and read-writable, how is this possible?

Original source