I'm looking at at ELF on linux and I have readelf --segments ./myELF
which shows:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000040 0x0000000000400040 0x0000000000400040 0x0001f8 0x0001f8 R 0x8
INTERP 0x000238 0x0000000000400238 0x0000000000400238 0x00001c 0x00001c R 0x1
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
LOAD 0x000000 0x0000000000400000 0x0000000000400000 0x000ad8 0x000ad8 R E 0x200000
LOAD 0x000e00 0x0000000000600e00 0x0000000000600e00 0x000250 0x000260 RW 0x200000
DYNAMIC 0x000e10 0x0000000000600e10 0x0000000000600e10 0x0001e0 0x0001e0 RW 0x8
NOTE 0x000254 0x0000000000400254 0x0000000000400254 0x000044 0x000044 R 0x4
GNU_EH_FRAME 0x000940 0x0000000000400940 0x0000000000400940 0x00004c 0x00004c R 0x4
GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x10
GNU_RELRO 0x000e00 0x0000000000600e00 0x0000000000600e00 0x000200 0x000200 R 0x1
Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame
03 .init_array .fini_array .dynamic .got .got.plt .data .bss
04 .dynamic
05 .note.ABI-tag .note.gnu.build-id
06 .eh_frame_hdr
07
08 .init_array .fini_array .dynamic .got
I am trying to confirm whether or not the segments shown here correspond directly with the segment numbers shown in the section-segment mapping below such that segment 03 which contains .init_array .fini_array .dynamic .got .got.plt .data .bss
corresponds with the fourth segment down in the top table which is of type LOAD
and will thus definitely RW at runtime? What is another way to learn about the segment/section mapping at runtime? I know for example that I can use vmmap
in gdb-gef
at runtime to view where things are located in the process' virtual memory, but it seems that output shows a different set of memory spaces than the specific concept of "segments" or "sections".