I'm doing something in memory lacking situations. When a shared object is loaded, there will be a memory gap between RO and RW segments. Running fromelf on a so file, I could get these:
==================================== ** Program header #1 Type : PT_LOAD (1) File Offset : 0 (0x0) Virtual Addr : 0x00000000 Physical Addr : 0x00000000 Size in file : 20468 bytes (0x4ff4) Size in memory: 20468 bytes (0x4ff4) Flags : PF_X + PF_R (0x5) Alignment : 32768 ==================================== ** Program header #2 Type : PT_LOAD (1) File Offset : 20468 (0x4ff4) Virtual Addr : 0x0000cff4 Physical Addr : 0x0000cff4 Size in file : 264 bytes (0x108) Size in memory: 40608 bytes (0x9ea0) Flags : PF_W + PF_R (0x6) Alignment : 32768 ====================================
The gap is 32K (from 0x4ff4 to 0x0000cff4). I've tried RVCT armlink and yagarto arm-none-eabi-ld, they are both 32K. And using Sourcery G++ arm-uclinuxeabi-ld, it's just a little bigger. When I tried arm-eabi-ld from Android ndk r5, it's only 4K. So I finally choose Android ndk r5 arm-eabi-ld as my linker to save memory. But I couldn't figure out why there will be such a big gap. Are there any options to control its size? Please help me out, thank you very much.