Forum: ARM programming with GCC/GNU tools The gap between RO and RW segments

Author: liang ma (Company: TK) (etarip)
Posted on:

Rate this post
0 useful
not useful
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.


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.