I am learning about memory management and I am trying to identify what the second read only memory segment, specific to my program, is storing.

00400000-00401000 r-xp 00000000 00:28 144 /a.out
00600000-00601000 r--p 00000000 00:28 144 /a.out
00601000-00602000 rw-p 00001000 00:28 144 /a.out

I've, I think, Identified the lower range segment to be the code-segment (or text-segment) where the executing code, and constant global variables are stored. I also believe that the third segment, with read/write access, is the data-segment where we store global and static variables.

My research tells me that there is a segment called BSS where uninitialized variables are stored. But the second memory segment between address 00600000-00601000 is shown as read-only, surely one would have uninitialized variables there, (how would one initialize them?).

My theory was that we stored global constant variables here but research and experimenting showed me this is not the case, as it is stored in text-segment.

I also read about a read-only data-segment (rodata) which, from what I understand, should contain static constant data, Is this it? and why are my constant globals stored here?

I'm using gcc to compile my test program.

1 Answer 1


r--p indicates a segment that is read-only and not executable. With a typical ELF executable, this contains some linker information. You can run objdump -D a.out or readelf -a a.out to get an idea of what is in that segment. For example, readelf -a /bin/sleep on x86_64 on Debian Linux shows the following sections in that segment:

  [18] .init_array       INIT_ARRAY       0000000000606e10  00006e10
       0000000000000008  0000000000000000  WA       0     0     8
  [19] .fini_array       FINI_ARRAY       0000000000606e18  00006e18
       0000000000000008  0000000000000000  WA       0     0     8
  [20] .jcr              PROGBITS         0000000000606e20  00006e20
       0000000000000008  0000000000000000  WA       0     0     8
  [21] .dynamic          DYNAMIC          0000000000606e28  00006e28
       00000000000001d0  0000000000000010  WA       6     0     8
  [22] .got              PROGBITS         0000000000606ff8  00006ff8
       0000000000000008  0000000000000008  WA       0     0     8

The LSB documents these sections.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .