Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are elf segments not page aligned?

Tags:

elf

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?

like image 791
user1608776 Avatar asked Nov 21 '12 13:11

user1608776


1 Answers

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.

like image 178
jkoshy Avatar answered Sep 23 '22 09:09

jkoshy