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:
1 | ====================================
|
2 | ** Program header #1
|
3 | Type : PT_LOAD (1)
|
4 | File Offset : 0 (0x0)
|
5 | Virtual Addr : 0x00000000
|
6 | Physical Addr : 0x00000000
|
7 | Size in file : 20468 bytes (0x4ff4)
|
8 | Size in memory: 20468 bytes (0x4ff4)
|
9 | Flags : PF_X + PF_R (0x5)
|
10 | Alignment : 32768
|
11 | ====================================
|
12 | ** Program header #2
|
13 | Type : PT_LOAD (1)
|
14 | File Offset : 20468 (0x4ff4)
|
15 | Virtual Addr : 0x0000cff4
|
16 | Physical Addr : 0x0000cff4
|
17 | Size in file : 264 bytes (0x108)
|
18 | Size in memory: 40608 bytes (0x9ea0)
|
19 | Flags : PF_W + PF_R (0x6)
|
20 | Alignment : 32768
|
21 | ====================================
|
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.