Why can a section be mapped to multiple segments?

Peng Yu pengyu.ut@gmail.com
Wed May 5 00:07:26 GMT 2021


Hi,

I see .tdata is mapped to multiple segments. Why a section can be
mapped to multiple segments? Isn't that it is sufficient to map a
section to a segment once so that when the program run, the program
can access the data in the section? Thanks.

$ readelf -W -l -S /usr/lib/x86_64-linux-gnu/libc.so
There are 65 section headers, starting at offset 0x1c0270:

Section Headers:
  [Nr] Name              Type            Address          Off    Size
 ES Flg Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000
000000 00      0   0  0
  [ 1] .note.gnu.build-id NOTE            00000000000002e0 0002e0
000024 00   A  0   0  4
  [ 2] .note.ABI-tag     NOTE            0000000000000304 000304
000020 00   A  0   0  4
  [ 3] .hash             HASH            0000000000000328 000328
0034f4 04   A  5   0  8
  [ 4] .gnu.hash         GNU_HASH        0000000000003820 003820
003cb4 00   A  5   0  8
  [ 5] .dynsym           DYNSYM          00000000000074d8 0074d8
00de30 18   A  6   1  8
  [ 6] .dynstr           STRTAB          0000000000015308 015308
0060c1 00   A  0   0  1
  [ 7] .gnu.version      VERSYM          000000000001b3ca 01b3ca
001284 02   A  5   0  2
  [ 8] .gnu.version_d    VERDEF          000000000001c650 01c650
000470 00   A  6  32  8
  [ 9] .gnu.version_r    VERNEED         000000000001cac0 01cac0
000030 00   A  6   1  8
  [10] .rela.dyn         RELA            000000000001caf0 01caf0
007a28 18   A  5   0  8
  [11] .rela.plt         RELA            0000000000024518 024518
000468 18  AI  5  27  8
  [12] .plt              PROGBITS        0000000000025000 025000
000300 10  AX  0   0 16
  [13] .plt.got          PROGBITS        0000000000025300 025300
000020 08  AX  0   0  8
  [14] .text             PROGBITS        0000000000025320 025320
149369 00  AX  0   0 16
  [15] __libc_freeres_fn PROGBITS        000000000016e690 16e690
000e4c 00  AX  0   0 16
  [16] .rodata           PROGBITS        0000000000170000 170000
023f18 00   A  0   0 32
  [17] .interp           PROGBITS        0000000000193f20 193f20
00001c 00   A  0   0 16
  [18] .eh_frame_hdr     PROGBITS        0000000000193f3c 193f3c
0061ac 00   A  0   0  4
  [19] .eh_frame         PROGBITS        000000000019a0e8 19a0e8
01fac8 00   A  0   0  8
  [20] .gcc_except_table PROGBITS        00000000001b9bb0 1b9bb0
00041b 00   A  0   0  1
  [21] .tdata            PROGBITS        00000000001bb5e0 1ba5e0
000010 00 WAT  0   0  8
  [22] .tbss             NOBITS          00000000001bb5f0 1ba5f0
000080 00 WAT  0   0  8
  [23] .init_array       INIT_ARRAY      00000000001bb5f0 1ba5f0
000010 08  WA  0   0  8
  [24] .data.rel.ro      PROGBITS        00000000001bb600 1ba600
002580 00  WA  0   0 32
  [25] .dynamic          DYNAMIC         00000000001bdb80 1bcb80
0001e0 10  WA  6   0  8
  [26] .got              PROGBITS        00000000001bdd60 1bcd60
000298 08  WA  0   0  8
  [27] .got.plt          PROGBITS        00000000001be000 1bd000
000190 08  WA  0   0  8
  [28] .data             PROGBITS        00000000001be1a0 1bd1a0
001600 00  WA  0   0 32
  [29] __libc_subfreeres PROGBITS        00000000001bf7a0 1be7a0
0000f0 00  WA  0   0  8
  [30] __libc_IO_vtables PROGBITS        00000000001bf8a0 1be8a0
000d68 00  WA  0   0 32
  [31] __libc_atexit     PROGBITS        00000000001c0608 1bf608
000008 00  WA  0   0  8
  [32] .bss              NOBITS          00000000001c0620 1bf610
003d50 00  WA  0   0 32
  [33] __libc_freeres_ptrs NOBITS          00000000001c4370 1bf610
000198 00  WA  0   0  8
  [34] .gnu.warning.sigstack PROGBITS        0000000000000000 1bf620
00004d 00      0   0 32
  [35] .gnu.warning.sigreturn PROGBITS        0000000000000000 1bf680
000032 00      0   0 32
  [36] .gnu.warning.siggetmask PROGBITS        0000000000000000 1bf6c0
000039 00      0   0 32
  [37] .gnu.warning.tmpnam PROGBITS        0000000000000000 1bf700
000037 00      0   0 32
  [38] .gnu.warning.tmpnam_r PROGBITS        0000000000000000 1bf740
000039 00      0   0 32
  [39] .gnu.warning.tempnam PROGBITS        0000000000000000 1bf780
000038 00      0   0 32
  [40] .gnu.warning.sys_errlist PROGBITS        0000000000000000
1bf7c0 000044 00      0   0 32
  [41] .gnu.warning.sys_nerr PROGBITS        0000000000000000 1bf820
000041 00      0   0 32
  [42] .gnu.warning.gets PROGBITS        0000000000000000 1bf880
000039 00      0   0 32
  [43] .gnu.warning.getpw PROGBITS        0000000000000000 1bf8c0
00003a 00      0   0 32
  [44] .gnu.warning.re_max_failures PROGBITS        0000000000000000
1bf900 00003d 00      0   0 32
  [45] .gnu.warning.lchmod PROGBITS        0000000000000000 1bf940
00002f 00      0   0 32
  [46] .gnu.warning.getwd PROGBITS        0000000000000000 1bf980
00007a 00      0   0 32
  [47] .gnu.warning.sstk PROGBITS        0000000000000000 1bfa00
00002d 00      0   0 32
  [48] .gnu.warning.revoke PROGBITS        0000000000000000 1bfa40
00002f 00      0   0 32
  [49] .gnu.warning.mktemp PROGBITS        0000000000000000 1bfa80
000044 00      0   0 32
  [50] .gnu.warning.gtty PROGBITS        0000000000000000 1bfae0
00002d 00      0   0 32
  [51] .gnu.warning.stty PROGBITS        0000000000000000 1bfb20
00002d 00      0   0 32
  [52] .gnu.warning.chflags PROGBITS        0000000000000000 1bfb60
000030 00      0   0 32
  [53] .gnu.warning.fchflags PROGBITS        0000000000000000 1bfba0
000031 00      0   0 32
  [54] .gnu.warning.__compat_bdflush PROGBITS        0000000000000000
1bfbe0 000039 00      0   0 32
  [55] .gnu.warning.__gets_chk PROGBITS        0000000000000000 1bfc20
000039 00      0   0 32
  [56] .gnu.warning.inet6_option_space PROGBITS
0000000000000000 1bfc60 00003c 00      0   0 32
  [57] .gnu.warning.inet6_option_init PROGBITS        0000000000000000
1bfca0 00003b 00      0   0 32
  [58] .gnu.warning.inet6_option_append PROGBITS
0000000000000000 1bfce0 00003d 00      0   0 32
  [59] .gnu.warning.inet6_option_alloc PROGBITS
0000000000000000 1bfd20 00003c 00      0   0 32
  [60] .gnu.warning.inet6_option_next PROGBITS        0000000000000000
1bfd60 00003b 00      0   0 32
  [61] .gnu.warning.inet6_option_find PROGBITS        0000000000000000
1bfda0 00003b 00      0   0 32
  [62] .gnu.warning.setlogin PROGBITS        0000000000000000 1bfde0
000031 00      0   0 32
  [63] .gnu_debuglink    PROGBITS        0000000000000000 1bfe14
000034 00      0   0  4
  [64] .shstrtab         STRTAB          0000000000000000 1bfe48
000427 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  l (large), p (processor specific)

Elf file type is DYN (Shared object file)
Entry point 0x26e40
There are 12 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr
FileSiz  MemSiz   Flg Align
  PHDR           0x000040 0x0000000000000040 0x0000000000000040
0x0002a0 0x0002a0 R   0x8
  INTERP         0x193f20 0x0000000000193f20 0x0000000000193f20
0x00001c 0x00001c R   0x10
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
  LOAD           0x000000 0x0000000000000000 0x0000000000000000
0x024980 0x024980 R   0x1000
  LOAD           0x025000 0x0000000000025000 0x0000000000025000
0x14a4dc 0x14a4dc R E 0x1000
  LOAD           0x170000 0x0000000000170000 0x0000000000170000
0x049fcb 0x049fcb R   0x1000
  LOAD           0x1ba5e0 0x00000000001bb5e0 0x00000000001bb5e0
0x005030 0x008f28 RW  0x1000
  DYNAMIC        0x1bcb80 0x00000000001bdb80 0x00000000001bdb80
0x0001e0 0x0001e0 RW  0x8
  NOTE           0x0002e0 0x00000000000002e0 0x00000000000002e0
0x000044 0x000044 R   0x4
  TLS            0x1ba5e0 0x00000000001bb5e0 0x00000000001bb5e0
0x000010 0x000090 R   0x8
  GNU_EH_FRAME   0x193f3c 0x0000000000193f3c 0x0000000000193f3c
0x0061ac 0x0061ac R   0x4
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000
0x000000 0x000000 RW  0x10
  GNU_RELRO      0x1ba5e0 0x00000000001bb5e0 0x00000000001bb5e0
0x002a20 0x002a20 R   0x1

 Section to Segment mapping:
  Segment Sections...
   00
   01     .interp
   02     .note.gnu.build-id .note.ABI-tag .hash .gnu.hash .dynsym
.dynstr .gnu.version .gnu.version_d .gnu.version_r .rela.dyn .rela.plt
   03     .plt .plt.got .text __libc_freeres_fn
   04     .rodata .interp .eh_frame_hdr .eh_frame .gcc_except_table
   05     .tdata .init_array .data.rel.ro .dynamic .got .got.plt .data
__libc_subfreeres __libc_IO_vtables __libc_atexit .bss
__libc_freeres_ptrs
   06     .dynamic
   07     .note.gnu.build-id .note.ABI-tag
   08     .tdata .tbss
   09     .eh_frame_hdr
   10
   11     .tdata .init_array .data.rel.ro .dynamic .got


-- 
Regards,
Peng


More information about the Binutils mailing list