为什么我的代码和数据段在一个elf64-x86-64 elf readelf中

时间:2018-02-16 02:09:29

标签: c++ linux c++11 x86-64 elf

readelf -e输出在下面。

请注意我的代码和数据段是否合并为一个?这是怎么做到的?我可以禁用吗?

我使用的是64位操作系统openSuse 42.2。我的想法已经不多了,我到处都搜索过。我能找到的唯一参考是通过这个网站https://timothylottes.github.io/20140420.html,但我没有进一步解释为什么这是我的可执行文件的行为。

ELF Header:
  Magic:   7f 45 4c 46 02 01 01 03 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - GNU
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x776ae0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          204598960 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         8
  Size of section headers:           64 (bytes)
  Number of section headers:         42
  Section header string table index: 39

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .interp           PROGBITS         0000000000048200  00048200
       000000000000001c  0000000000000000   A       0     0     1
  [ 2] .note.ABI-tag     NOTE             000000000004821c  0004821c
       0000000000000020  0000000000000000   A       0     0     4
  [ 3] .note.gnu.build-i NOTE             000000000004823c  0004823c
       0000000000000024  0000000000000000   A       0     0     4
  [ 4] .hash             HASH             0000000000048260  00048260
       0000000000063cbc  0000000000000004   A       5     0     8
  [ 5] .dynsym           DYNSYM           00000000000abf20  000abf20
       0000000000196bf0  0000000000000018   A       6     1     8
  [ 6] .dynstr           STRTAB           0000000000242b10  00242b10
       00000000004ddca0  0000000000000000   A       0     0     1
  [ 7] .gnu.version      VERSYM           00000000007207b0  007207b0
       0000000000021e54  0000000000000002   A       5     0     2
  [ 8] .gnu.version_r    VERNEED          0000000000742608  00742608
       00000000000002f0  0000000000000000   A       6    11     8
  [ 9] .rela.dyn         RELA             00000000007428f8  007428f8
       00000000000255f0  0000000000000018   A       5     0     8
  [10] .rela.plt         RELA             0000000000767ee8  00767ee8
       0000000000008d78  0000000000000018  AI       5    29     8
  [11] .init             PROGBITS         0000000000770c60  00770c60
       000000000000001a  0000000000000000  AX       0     0     4
  [12] .plt              PROGBITS         0000000000770c80  00770c80
       0000000000005e60  0000000000000010  AX       0     0     16
  [13] .text             PROGBITS         0000000000776ae0  00776ae0
       00000000011f7550  0000000000000000  AX       0     0     16
  [14] .plt.got          PROGBITS         000000000196e030  0196e030
       0000000000000138  0000000000000000  AX       0     0     8
  [15] .fini             PROGBITS         000000000196e168  0196e168
       0000000000000009  0000000000000000  AX       0     0     4
  [16] .rodata           PROGBITS         000000000196e180  0196e180
       00000000001d0528  0000000000000000   A       0     0     64
  [17] .gnu.hash         GNU_HASH         0000000001b3e6a8  01b3e6a8
       0000000000071dc8  0000000000000000   A       5     0     8
  [18] .eh_frame_hdr     PROGBITS         0000000001bb0470  01bb0470
       00000000000d69fc  0000000000000000   A       0     0     4
  [19] .eh_frame         PROGBITS         0000000001c86e70  01c86e70
       0000000000389b3c  0000000000000000   A       0     0     8
  [20] .gcc_except_table PROGBITS         00000000020109ac  020109ac
       000000000008888f  0000000000000000   A       0     0     4
  [21] .tbss             NOBITS           000000000209a240  0209923b
       0000000000000010  0000000000000000 WAT       0     0     8
  [22] .init_array       INIT_ARRAY       000000000209a240  0209a240
       0000000000000c68  0000000000000000  WA       0     0     8
  [23] .fini_array       FINI_ARRAY       000000000209aea8  0209aea8
       0000000000000008  0000000000000000  WA       0     0     8
  [24] .jcr              PROGBITS         000000000209aeb0  0209aeb0
       0000000000000008  0000000000000000  WA       0     0     8
  [25] .data.rel.ro      PROGBITS         000000000209aec0  0209aec0
       00000000000c3590  0000000000000000  WA       0     0     32
  [26] .dynamic          DYNAMIC          000000000215e450  0215e450
       00000000000004b0  0000000000000010  WA       6     0     8
  [27] .got              PROGBITS         000000000215e900  0215e900
       00000000000003f0  0000000000000008  WA       0     0     8
  [28] .data             PROGBITS         000000000215ed00  0215ed00
       000000000001c83c  0000000000000000  WA       0     0     32
  [29] .got.plt          PROGBITS         000000000217b540  0217b540
       0000000000002f40  0000000000000008  WA       0     0     8
  [30] .bss              NOBITS           000000000217e480  0217e480
       00000000004fc430  0000000000000000  WA       0     0     32
  [31] .comment          PROGBITS         0000000000000000  0217e480
       0000000000000048  0000000000000001  MS       0     0     1
  [32] .debug_aranges    PROGBITS         0000000000000000  0217e4d0
       0000000000256ea0  0000000000000000           0     0     16
  [33] .debug_info       PROGBITS         0000000000000000  023d5370
       0000000007241f51  0000000000000000           0     0     1
  [34] .debug_abbrev     PROGBITS         0000000000000000  096172c1
       000000000019ee52  0000000000000000           0     0     1
  [35] .debug_line       PROGBITS         0000000000000000  097b6113
       000000000070ea42  0000000000000000           0     0     1
  [36] .debug_str        PROGBITS         0000000000000000  09ec4b55
       000000000134d514  0000000000000001  MS       0     0     1
  [37] .debug_loc        PROGBITS         0000000000000000  0b212069
       000000000000f98e  0000000000000000           0     0     1
  [38] .debug_ranges     PROGBITS         0000000000000000  0b221a00
       000000000027d0b0  0000000000000000           0     0     16
  [39] .shstrtab         STRTAB           0000000000000000  0c31ed25
       000000000000018a  0000000000000000           0     0     1
  [40] .symtab           SYMTAB           0000000000000000  0b49eab0
       00000000003c0828  0000000000000018          41   94511     8
  [41] .strtab           STRTAB           0000000000000000  0b85f2d8
       0000000000abfa4d  0000000000000000           0     0     1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), l (large)
  I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000000040 0x0000000000000040
                 0x00000000000001c0 0x00000000000001c0  R E    8
  INTERP         0x0000000000048200 0x0000000000048200 0x0000000000048200
                 0x000000000000001c 0x000000000000001c  R      1
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
  LOAD           0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x000000000217e480 0x000000000267a8b0  RWE    200000
  DYNAMIC        0x000000000215e450 0x000000000215e450 0x000000000215e450
                 0x00000000000004b0 0x00000000000004b0  RW     8
  NOTE           0x000000000004821c 0x000000000004821c 0x000000000004821c
                 0x0000000000000044 0x0000000000000044  R      4
  TLS            0x000000000209923b 0x000000000209a240 0x000000000209a240
                 0x0000000000000000 0x0000000000000010  R      8
  GNU_EH_FRAME   0x0000000001bb0470 0x0000000001bb0470 0x0000000001bb0470
                 0x00000000000d69fc 0x00000000000d69fc  R      4
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     10

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .interp .note.ABI-tag .note.gnu.build-id .hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .plt.got .fini .rodata .gnu.hash .eh_frame_hdr .eh_frame .gcc_except_table .init_array .fini_array .jcr .data.rel.ro .dynamic .got .data .got.plt .bss 
   03     .dynamic 
   04     .note.ABI-tag .note.gnu.build-id 
   05     .tbss 
   06     .eh_frame_hdr 
   07     

0 个答案:

没有答案