linker load elf (2)

 

// SimpleSection.o
0000000: 7f45 4c46 0201 0100 0000 0000 0000 0000  .ELF............
0000010: 0100 3e00 0100 0000 0000 0000 0000 0000  ..>.............
0000020: 0000 0000 0000 0000 9001 0000 0000 0000  ................
0000030: 0000 0000 4000 0000 0000 4000 0d00 0a00  ....@.....@.....
0000040: 5548 89e5 4883 ec10 897d fcb8 0000 0000  UH..H....}......
0000050: 8b55 fc89 d648 89c7 b800 0000 00e8 0000  .U...H..........
0000060: 0000 c9c3 5548 89e5 4883 ec10 c745 f801  ....UH..H....E..
0000070: 0000 008b 1500 0000 008b 0500 0000 0001  ................
0000080: d003 45f8 0345 fc89 c7e8 0000 0000 8b45  ..E..E.........E
0000090: f8c9 c300 5400 0000 5500 0000 2564 0a00  ....T...U...%d..
00000a0: 0047 4343 3a20 2855 6275 6e74 752f 4c69  .GCC: (Ubuntu/Li
00000b0: 6e61 726f 2034 2e36 2e33 2d31 7562 756e  naro 4.6.3-1ubun
00000c0: 7475 3529 2034 2e36 2e33 0000 0000 0000  tu5) 4.6.3......
00000d0: 1400 0000 0000 0000 017a 5200 0178 1001  .........zR..x..
00000e0: 1b0c 0708 9001 0000 1c00 0000 1c00 0000  ................
00000f0: 0000 0000 2400 0000 0041 0e10 8602 430d  ....$....A....C.
0000100: 065f 0c07 0800 0000 1c00 0000 3c00 0000  ._..........<...
0000110: 0000 0000 2f00 0000 0041 0e10 8602 430d  ..../....A....C.
0000120: 066a 0c07 0800 0000 002e 7379 6d74 6162  .j........symtab
0000130: 002e 7374 7274 6162 002e 7368 7374 7274  ..strtab..shstrt
0000140: 6162 002e 7265 6c61 2e74 6578 7400 2e64  ab..rela.text..d
0000150: 6174 6100 2e62 7373 002e 726f 6461 7461  ata..bss..rodata
0000160: 002e 636f 6d6d 656e 7400 2e6e 6f74 652e  ..comment..note.
0000170: 474e 552d 7374 6163 6b00 2e72 656c 612e  GNU-stack..rela.
0000180: 6568 5f66 7261 6d65 0000 0000 0000 0000  eh_frame........
0000190: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00001a0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00001b0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00001c0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00001d0: 2000 0000 0100 0000 0600 0000 0000 0000   ...............
00001e0: 0000 0000 0000 0000 4000 0000 0000 0000  ........@.......
00001f0: 5300 0000 0000 0000 0000 0000 0000 0000  S...............
0000200: 0400 0000 0000 0000 0000 0000 0000 0000  ................
0000210: 1b00 0000 0400 0000 0000 0000 0000 0000  ................
0000220: 0000 0000 0000 0000 b806 0000 0000 0000  ................
0000230: 7800 0000 0000 0000 0b00 0000 0100 0000  x...............
0000240: 0800 0000 0000 0000 1800 0000 0000 0000  ................
0000250: 2600 0000 0100 0000 0300 0000 0000 0000  &...............
0000260: 0000 0000 0000 0000 9400 0000 0000 0000  ................
0000270: 0800 0000 0000 0000 0000 0000 0000 0000  ................
0000280: 0400 0000 0000 0000 0000 0000 0000 0000  ................
0000290: 2c00 0000 0800 0000 0300 0000 0000 0000  ,...............
00002a0: 0000 0000 0000 0000 9c00 0000 0000 0000  ................
00002b0: 0400 0000 0000 0000 0000 0000 0000 0000  ................
00002c0: 0400 0000 0000 0000 0000 0000 0000 0000  ................
00002d0: 3100 0000 0100 0000 0200 0000 0000 0000  1...............
00002e0: 0000 0000 0000 0000 9c00 0000 0000 0000  ................
00002f0: 0400 0000 0000 0000 0000 0000 0000 0000  ................
0000300: 0100 0000 0000 0000 0000 0000 0000 0000  ................
0000310: 3900 0000 0100 0000 3000 0000 0000 0000  9.......0.......
0000320: 0000 0000 0000 0000 a000 0000 0000 0000  ................
0000330: 2b00 0000 0000 0000 0000 0000 0000 0000  +...............
0000340: 0100 0000 0000 0000 0100 0000 0000 0000  ................
0000350: 4200 0000 0100 0000 0000 0000 0000 0000  B...............
0000360: 0000 0000 0000 0000 cb00 0000 0000 0000  ................
0000370: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000380: 0100 0000 0000 0000 0000 0000 0000 0000  ................
0000390: 5700 0000 0100 0000 0200 0000 0000 0000  W...............
00003a0: 0000 0000 0000 0000 d000 0000 0000 0000  ................
00003b0: 5800 0000 0000 0000 0000 0000 0000 0000  X...............
00003c0: 0800 0000 0000 0000 0000 0000 0000 0000  ................
00003d0: 5200 0000 0400 0000 0000 0000 0000 0000  R...............
00003e0: 0000 0000 0000 0000 3007 0000 0000 0000  ........0.......
00003f0: 3000 0000 0000 0000 0b00 0000 0800 0000  0...............
0000400: 0800 0000 0000 0000 1800 0000 0000 0000  ................
0000410: 1100 0000 0300 0000 0000 0000 0000 0000  ................
0000420: 0000 0000 0000 0000 2801 0000 0000 0000  ........(.......
0000430: 6100 0000 0000 0000 0000 0000 0000 0000  a...............
0000440: 0100 0000 0000 0000 0000 0000 0000 0000  ................
0000450: 0100 0000 0200 0000 0000 0000 0000 0000  ................
0000460: 0000 0000 0000 0000 d004 0000 0000 0000  ................
0000470: 8001 0000 0000 0000 0c00 0000 0b00 0000  ................
0000480: 0800 0000 0000 0000 1800 0000 0000 0000  ................
0000490: 0900 0000 0300 0000 0000 0000 0000 0000  ................
00004a0: 0000 0000 0000 0000 5006 0000 0000 0000  ........P.......
00004b0: 6600 0000 0000 0000 0000 0000 0000 0000  f...............
00004c0: 0100 0000 0000 0000 0000 0000 0000 0000  ................
00004d0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00004e0: 0000 0000 0000 0000 0100 0000 0400 f1ff  ................
00004f0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000500: 0000 0000 0300 0100 0000 0000 0000 0000  ................
0000510: 0000 0000 0000 0000 0000 0000 0300 0300  ................
0000520: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000530: 0000 0000 0300 0400 0000 0000 0000 0000  ................
0000540: 0000 0000 0000 0000 0000 0000 0300 0500  ................
0000550: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000560: 1100 0000 0100 0300 0400 0000 0000 0000  ................
0000570: 0400 0000 0000 0000 2100 0000 0100 0400  ........!.......
0000580: 0000 0000 0000 0000 0400 0000 0000 0000  ................
0000590: 0000 0000 0300 0700 0000 0000 0000 0000  ................
00005a0: 0000 0000 0000 0000 0000 0000 0300 0800  ................
00005b0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00005c0: 0000 0000 0300 0600 0000 0000 0000 0000  ................
00005d0: 0000 0000 0000 0000 3200 0000 1100 0300  ........2.......
00005e0: 0000 0000 0000 0000 0400 0000 0000 0000  ................
00005f0: 4200 0000 1100 f2ff 0400 0000 0000 0000  B...............
0000600: 0400 0000 0000 0000 5400 0000 1200 0100  ........T.......
0000610: 0000 0000 0000 0000 2400 0000 0000 0000  ........$.......
0000620: 5a00 0000 1000 0000 0000 0000 0000 0000  Z...............
0000630: 0000 0000 0000 0000 6100 0000 1200 0100  ........a.......
0000640: 2400 0000 0000 0000 2f00 0000 0000 0000  $......./.......
0000650: 0053 696d 706c 6553 6563 7469 6f6e 2e63  .SimpleSection.c
0000660: 0073 7461 7469 635f 7661 722e 3230 3439  .static_var.2049
0000670: 0073 7461 7469 635f 7661 7232 2e32 3035  .static_var2.205
0000680: 3000 676c 6f62 616c 5f69 6e69 745f 7661  0.global_init_va
0000690: 7200 676c 6f62 616c 5f75 6e69 6e69 745f  r.global_uninit_
00006a0: 7661 7200 6675 6e63 3100 7072 696e 7466  var.func1.printf
00006b0: 006d 6169 6e00 0000 0c00 0000 0000 0000  .main...........
00006c0: 0a00 0000 0500 0000 0000 0000 0000 0000  ................
00006d0: 1e00 0000 0000 0000 0200 0000 0e00 0000  ................
00006e0: fcff ffff ffff ffff 3500 0000 0000 0000  ........5.......
00006f0: 0200 0000 0300 0000 0000 0000 0000 0000  ................
0000700: 3b00 0000 0000 0000 0200 0000 0400 0000  ;...............
0000710: fcff ffff ffff ffff 4a00 0000 0000 0000  ........J.......
0000720: 0200 0000 0d00 0000 fcff ffff ffff ffff  ................
0000730: 2000 0000 0000 0000 0200 0000 0200 0000   ...............
0000740: 0000 0000 0000 0000 4000 0000 0000 0000  ........@.......
0000750: 0200 0000 0200 0000 2400 0000 0000 0000  ........$.......
0000760: 0a                                       .

  Elf64_Ehdr描述elf header

typedef struct
{
  unsigned char e_ident[EI_NIDENT];     /* 16 Magic number and other info */
  Elf64_Half    e_type;                 /* 2 Object file type */
  Elf64_Half    e_machine;              /* 2 Architecture */
  Elf64_Word    e_version;              /* 4 Object file version */
  Elf64_Addr    e_entry;                /* 8 Entry point virtual address */
  Elf64_Off     e_phoff;                /* 8 Program header table file offset */
  Elf64_Off     e_shoff;                /* 8 Section header table file offset */ section table offset address
  Elf64_Word    e_flags;                /* 4 Processor-specific flags */
  Elf64_Half    e_ehsize;               /* 2 ELF header size in bytes */ 段描述符的大小,也就是sizeof(Elf64_Ehdr) = 64
  Elf64_Half    e_phentsize;            /* 2 Program header table entry size */
  Elf64_Half    e_phnum;                /* 2 Program header table entry count */
  Elf64_Half    e_shentsize;            /* 2 Section header table entry size */
  Elf64_Half    e_shnum;                /* 2 Section header table entry count */ 段的个数
  Elf64_Half    e_shstrndx;             /* 2 Section header string table index */
} Elf64_Ehdr;
0000000: 7f45 4c46 0201 0100 0000 0000 0000 0000  .ELF............
0000010: 0100 3e00 0100 0000 0000 0000 0000 0000  ..>.............
0000020: 0000 0000 0000 0000 9001 0000 0000 0000  ................
0000030: 0000 0000 4000 0000 0000 4000 0d00 0a00  ....@.....@.....
Elf64_Off     e_shoff = 0x0000000000000190 = 400
也就是说section table offset = 0x190 = 400
段的个数为0x000d = 13    e_shstrndx = 0x000a = 10 表示段表字符串在第10个段中

-----------------------
|      ELF Header     | e_shoff----
-----------------------           | 0x190 = 400
|       .text         |           |
-----------------------           |
|       .data         |           |
-----------------------           |
|       .bss          |           |
----------------------- |
|       .rodata       | |
----------------------- |
|    .  comment       | |
----------------------- |
|   .other sections.  | |
-----------------------<-----------
|    Section table    |
-----------------------
|    String Tables    |
-----------------------
|    Symbol Tables    |
-----------------------
|   ..............    |
-----------------------        


// 段表有很多个段描述,段描述的数据结构为Elf64_Shdr
typedef struct { Elf64_Word sh_name; /* 4 Section name (string tbl index) */ Elf64_Word sh_type; /* 4 Section type */ Elf64_Xword sh_flags; /* 8 Section flags */ Elf64_Addr sh_addr; /* 8 Section virtual addr at execution */ Elf64_Off sh_offset; /* 8 Section file offset */ Elf64_Xword sh_size; /* 8 Section size in bytes */ Elf64_Word sh_link; /* 4 Link to another section */ Elf64_Word sh_info; /* 4 Additional section information */ Elf64_Xword sh_addralign; /* 8 Section alignment */ Elf64_Xword sh_entsize; /* 8 Entry size if section holds table */ } Elf64_Shdr;

mutian@mutian:~/share/test$ readelf -S SimpleSection.o
There are 13 section headers, starting at offset 0x190:

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .text             PROGBITS         0000000000000000  00000040
       0000000000000053  0000000000000000  AX       0     0     4
  [ 2] .rela.text        RELA             0000000000000000  000006b8
       0000000000000078  0000000000000018          11     1     8
  [ 3] .data             PROGBITS         0000000000000000  00000094
       0000000000000008  0000000000000000  WA       0     0     4
  [ 4] .bss              NOBITS           0000000000000000  0000009c
       0000000000000004  0000000000000000  WA       0     0     4
  [ 5] .rodata           PROGBITS         0000000000000000  0000009c
       0000000000000004  0000000000000000   A       0     0     1
  [ 6] .comment          PROGBITS         0000000000000000  000000a0
       000000000000002b  0000000000000001  MS       0     0     1
  [ 7] .note.GNU-stack   PROGBITS         0000000000000000  000000cb
       0000000000000000  0000000000000000           0     0     1
  [ 8] .eh_frame         PROGBITS         0000000000000000  000000d0
       0000000000000058  0000000000000000   A       0     0     8
  [ 9] .rela.eh_frame    RELA             0000000000000000  00000730
       0000000000000030  0000000000000018          11     8     8
  [10] .shstrtab         STRTAB           0000000000000000  00000128
       0000000000000061  0000000000000000           0     0     1
  [11] .symtab           SYMTAB           0000000000000000  000004d0
       0000000000000180  0000000000000018          12    11     8
  [12] .strtab           STRTAB           0000000000000000  00000650
       0000000000000066  0000000000000000           0     0     1

 

// 第一段是无效的段
0000190: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00001a0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00001b0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00001c0: 0000 0000 0000 0000 0000 0000 0000 0000  ................

// 第二段
00001d0: 2000 0000 0100 0000 0600 0000 0000 0000   ...............
00001e0: 0000 0000 0000 0000 4000 0000 0000 0000  ........@.......
00001f0: 5300 0000 0000 0000 0000 0000 0000 0000  S...............
0000200: 0400 0000 0000 0000 0000 0000 0000 0000  ................
// sh_name = 0x20  sh_type = 0x1  sh_flags = 0x6地址sh_offset = 0x40
// sh_size = 0x53  sh_addralign = 0x04 按4字节对齐
// 第三段 0000210: 1b00 0000 0400 0000 0000 0000 0000 0000 ................ 0000220: 0000 0000 0000 0000 b806 0000 0000 0000 ................ 0000230: 7800 0000 0000 0000 0b00 0000 0100 0000 x............... 0000240: 0800 0000 0000 0000 1800 0000 0000 0000 ................ // 偏移地址sh_offset = 0x6b8 sh_size = 0x78 // 第四段 0000250: 2600 0000 0100 0000 0300 0000 0000 0000 &............... 0000260: 0000 0000 0000 0000 9400 0000 0000 0000 ................ 0000270: 0800 0000 0000 0000 0000 0000 0000 0000 ................ 0000280: 0400 0000 0000 0000 0000 0000 0000 0000 ................ // 偏移地址sh_offset = 0x94 sh_size = 0x8 ...........................................


/* Legal values for sh_type (section type).  */

#define SHT_NULL          0             /* Section header table entry unused */
#define SHT_PROGBITS      1             /* Program data */
#define SHT_SYMTAB        2             /* Symbol table */
#define SHT_STRTAB        3             /* String table */
#define SHT_RELA          4             /* Relocation entries with addends */
#define SHT_HASH          5             /* Symbol hash table */
#define SHT_DYNAMIC       6             /* Dynamic linking information */
#define SHT_NOTE          7             /* Notes */
#define SHT_NOBITS        8             /* Program space with no data (bss) */
#define SHT_REL           9             /* Relocation entries, no addends */
#define SHT_SHLIB         10            /* Reserved */
#define SHT_DYNSYM        11            /* Dynamic linker symbol table */
#define SHT_INIT_ARRAY    14            /* Array of constructors */
#define SHT_FINI_ARRAY    15            /* Array of destructors */
#define SHT_PREINIT_ARRAY 16            /* Array of pre-constructors */
#define SHT_GROUP         17            /* Section group */
#define SHT_SYMTAB_SHNDX  18            /* Extended section indeces */
#define SHT_NUM           19            /* Number of defined types.  */
#define SHT_LOOS          0x60000000    /* Start OS-specific.  */
#define SHT_GNU_ATTRIBUTES 0x6ffffff5   /* Object attributes.  */
#define SHT_GNU_HASH      0x6ffffff6    /* GNU-style hash table.  */
#define SHT_GNU_LIBLIST   0x6ffffff7    /* Prelink library list */
#define SHT_CHECKSUM      0x6ffffff8    /* Checksum for DSO content.  */
#define SHT_LOSUNW        0x6ffffffa    /* Sun-specific low bound.  */
#define SHT_SUNW_move     0x6ffffffa
#define SHT_SUNW_COMDAT   0x6ffffffb
#define SHT_SUNW_syminfo  0x6ffffffc
#define SHT_GNU_verdef    0x6ffffffd    /* Version definition section.  */
#define SHT_GNU_verneed   0x6ffffffe    /* Version needs section.  */
#define SHT_GNU_versym    0x6fffffff    /* Version symbol table.  */
#define SHT_HISUNW        0x6fffffff    /* Sun-specific high bound.  */
#define SHT_HIOS          0x6fffffff    /* End OS-specific type */
#define SHT_LOPROC        0x70000000    /* Start of processor-specific */
#define SHT_HIPROC        0x7fffffff    /* End of processor-specific */
#define SHT_LOUSER        0x80000000    /* Start of application-specific */
#define SHT_HIUSER        0x8fffffff    /* End of application-specific */


/* Legal values for sh_flags (section flags).  */

#define SHF_WRITE            (1 << 0)   /* Writable */
#define SHF_ALLOC            (1 << 1)   /* Occupies memory during execution */
#define SHF_EXECINSTR        (1 << 2)   /* Executable */
#define SHF_MERGE            (1 << 4)   /* Might be merged */
#define SHF_STRINGS          (1 << 5)   /* Contains nul-terminated strings */
#define SHF_INFO_LINK        (1 << 6)   /* `sh_info' contains SHT index */
#define SHF_LINK_ORDER       (1 << 7)   /* Preserve order after combining */
#define SHF_OS_NONCONFORMING (1 << 8)   /* Non-standard OS specific handling
                                           required */
#define SHF_GROUP            (1 << 9)   /* Section is member of a group.  */
#define SHF_TLS              (1 << 10)  /* Section hold thread-local data.  */
#define SHF_MASKOS           0x0ff00000 /* OS-specific.  */
#define SHF_MASKPROC         0xf0000000 /* Processor-specific */
#define SHF_ORDERED          (1 << 30)  /* Special ordering requirement
                                           (Solaris).  */
#define SHF_EXCLUDE          (1 << 31)  /* Section is excluded unless
                                           referenced or allocated (Solaris).*/

 .shstrtab段包含的是段表需要的字符串,分析.shstrtab段的内容

0000120:                     002e 7379 6d74 6162          ..symtab
0000130: 002e 7374 7274 6162 002e 7368 7374 7274  ..strtab..shstrt
0000140: 6162 002e 7265 6c61 2e74 6578 7400 2e64  ab..rela.text..d
0000150: 6174 6100 2e62 7373 002e 726f 6461 7461  ata..bss..rodata
0000160: 002e 636f 6d6d 656e 7400 2e6e 6f74 652e  ..comment..note.
0000170: 474e 552d 7374 6163 6b00 2e72 656c 612e  GNU-stack..rela.
0000180: 6568 5f66 7261 6d65 00                   eh_frame........

以002e开始一个字符串,取字符串的时候只需要知道字符串在该表中的偏移地址即可。

mutian@mutian:~/share/test$ readelf -x .shstrtab SimpleSection.o
Hex dump of section '.shstrtab':
  0x00000000 002e7379 6d746162 002e7374 72746162 ..symtab..strtab
  0x00000010 002e7368 73747274 6162002e 72656c61 ..shstrtab..rela
  0x00000020 2e746578 74002e64 61746100 2e627373 .text..data..bss
  0x00000030 002e726f 64617461 002e636f 6d6d656e ..rodata..commen
  0x00000040 74002e6e 6f74652e 474e552d 73746163 t..note.GNU-stac
  0x00000050 6b002e72 656c612e 65685f66 72616d65 k..rela.eh_frame
  0x00000060 00 

 

每个目标文件都会有一个符号表(Symbol Table), 也就是.strtab段
.strtab段记录的是符号名,也就是变量名和函数名的字符串。每个定义的符号都有一个符号值(Symbol Value),也就是变量或者函数的地址。如果这个符号在本源文件中没有找到,那么称这个符号为外部符号(External symbol)

0000650: 0053 696d 706c 6553 6563 7469 6f6e 2e63  .SimpleSection.c
0000660: 0073 7461 7469 635f 7661 722e 3230 3439  .static_var.2049
0000670: 0073 7461 7469 635f 7661 7232 2e32 3035  .static_var2.205
0000680: 3000 676c 6f62 616c 5f69 6e69 745f 7661  0.global_init_va
0000690: 7200 676c 6f62 616c 5f75 6e69 6e69 745f  r.global_uninit_
00006a0: 7661 7200 6675 6e63 3100 7072 696e 7466  var.func1.printf
00006b0: 006d 6169 6e00                           .main.

 

.symtab

/* Type for section indices, which are 16-bit quantities.  */
typedef uint16_t Elf32_Section;
typedef uint16_t Elf64_Section;

/* Symbol table entry.  */
typedef struct
{
  Elf32_Word    st_name;                /* Symbol name (string tbl index) */
  Elf32_Addr    st_value;               /* Symbol value */
  Elf32_Word    st_size;                /* Symbol size */
  unsigned char st_info;                /* Symbol type and binding */
  unsigned char st_other;               /* Symbol visibility */
  Elf32_Section st_shndx;               /* Section index */
} Elf32_Sym;

typedef struct
{
  Elf64_Word    st_name;                /* 4 Symbol name (string tbl index) */
  unsigned char st_info;                /* 1 Symbol type and binding */
  unsigned char st_other;               /* 1 Symbol visibility */
  Elf64_Section st_shndx;               /* 2 Section index */
  Elf64_Addr    st_value;               /* 8 Symbol value */
  Elf64_Xword   st_size;                /* 8 Symbol size */
} Elf64_Sym;

 

mutian@mutian:~/share/test$ readelf -s SimpleSection.o
Symbol table '.symtab' contains 16 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS SimpleSection.c
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT    1 
     3: 0000000000000000     0 SECTION LOCAL  DEFAULT    3 
     4: 0000000000000000     0 SECTION LOCAL  DEFAULT    4 
     5: 0000000000000000     0 SECTION LOCAL  DEFAULT    5 
     6: 0000000000000004     4 OBJECT  LOCAL  DEFAULT    3 static_var.2049
     7: 0000000000000000     4 OBJECT  LOCAL  DEFAULT    4 static_var2.2050
     8: 0000000000000000     0 SECTION LOCAL  DEFAULT    7 
     9: 0000000000000000     0 SECTION LOCAL  DEFAULT    8 
    10: 0000000000000000     0 SECTION LOCAL  DEFAULT    6 
    11: 0000000000000000     4 OBJECT  GLOBAL DEFAULT    3 global_init_var
    12: 0000000000000004     4 OBJECT  GLOBAL DEFAULT  COM global_uninit_var
    13: 0000000000000000    36 FUNC    GLOBAL DEFAULT    1 func1
    14: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND printf
    15: 0000000000000024    47 FUNC    GLOBAL DEFAULT    1 main

每一个符号用24个字节表示,第一个字节是无效的字节。

00004d0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00004e0: 0000 0000 0000 0000 0100 0000 0400 f1ff  ................
00004f0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000500: 0000 0000 0300 0100 0000 0000 0000 0000  ................
0000510: 0000 0000 0000 0000 0000 0000 0300 0300  ................
0000520: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000530: 0000 0000 0300 0400 0000 0000 0000 0000  ................
0000540: 0000 0000 0000 0000 0000 0000 0300 0500  ................
0000550: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000560: 1100 0000 0100 0300 0400 0000 0000 0000  ................
0000570: 0400 0000 0000 0000 2100 0000 0100 0400  ........!.......
0000580: 0000 0000 0000 0000 0400 0000 0000 0000  ................
..............

 

ELF是采用一个叫DWARF(Debug with Arbitrary Record Format)的标准的调试信息格式。

 MicroSoft也有自己相应的调试信息格式标准,叫Code View

posted @ 2016-04-21 17:34  牧 天  阅读(597)  评论(0)    收藏  举报