linux下的ELF对象格式

1.ELF概念

       ELF(Executable and Linking Format)是unix-like系统下的一种文件格式,它是一种对象文件的格式,用于定义不同类型的对象文件(Object files)中都放了什么东西、以及都以什么样的格式去放这些东西。它自最早在 System V 系统上出现后,被unix-like世界所广泛接受,作为缺省的二进制文件格式来使用。可以说,ELF是构成众多unix-like系统的基础之一。

       在unix-like平台下,二进制对象文件格式从a.out格式演变到COFF格式,再到现在的ELF格式。

       备注,在windows平台上,动态链接库文件所使用的是称为 PE(Portable Executable)的文件格式,PE主要在 COFF 文件头部之上增加了一些专用头部信息演变而来的。


2.在unix-like平台上使用ELF格式的文件有如下类型

(1)可重定位的对象文件(Relocatable file)

        其实就是由编译器编译生成目标对象文件(.o 文件)。链接器(link editor)将会拿一个或一些 Relocatable object files 作为输入,经链接处理后,生成一个可执行的对象文件 (Executable file) 或者一个可被共享的对象文件(Shared object file)。

(2)可执行的对象文件(Executable file)

        就是二进制可执行文件,比如ping,vim等二进制文件。

(3)可被共享的对象文件(Shared object file)

        就是unix-like平台下的动态库文件,比如.so文件。

(4)core dump核心转储文件


3.ELF文件的格式

        ELF文件由几个重要的部分组成,分别是ELF头(ELF header)、程序头表(program header table)和节头表(Section header table)等。实际上,一个文件中不一定包含全部内容,而且他们的位置也没有固定顺序,只有ELF头的位置是固定的,其余各部分的位置、大小等信息都由ELF头中的各项值来决定。

(1)ELF头(ELF header) 

使用readelf  -h filename可以查看一个ELF文件的ELF头,如下:

ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x42dfe0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          67460488 (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:         40
  Section header string table index: 37

对应的数据结构是:

typedef struct
{
  		unsigned char e_ident[EI_NIDENT];     /* 魔数和相关信息 */
  		Elf32_Half    e_type;                 /* 目标文件类型 */
  		Elf32_Half    e_machine;              /* 硬件体系 */
  		Elf32_Word    e_version;              /* 目标文件版本 */
  		Elf32_Addr    e_entry;                /* 程序进入点 */
  		Elf32_Off     e_phoff;                /* 程序头部偏移量 */
  		Elf32_Off     e_shoff;                /* 节头部偏移量 */
  		Elf32_Word    e_flags;                /* 处理器特定标志 */
  		Elf32_Half    e_ehsize;               /* ELF头部长度 */
  		Elf32_Half    e_phentsize;            /* 程序头部中一个条目的长度 */
  		Elf32_Half    e_phnum;                /* 程序头部条目个数  */
  		Elf32_Half    e_shentsize;            /* 节头部中一个条目的长度 */
  		Elf32_Half    e_shnum;                /* 节头部条目个数 */
  		Elf32_Half    e_shstrndx;             /* 节头部字符表索引 */
} Elf32_Ehdr;

(2) 节头表(Section header table),自称为“节表”

        sections 是在ELF文件里头,用以装载内容数据的最小容器。在ELF文件里面,每一个 sections 内都装载了性质属性都不一样的内容,比方:
a).text section 里装载了可执行代码;
b).data section 里面装载了被初始化的数据;
c).bss section 里面装载了未被初始化的数据;
d).以.rec 打头的 sections 里面装载了重定位条目;
e).以.symtab 或者 .dynsym section 里面装载了符号信息;
f).以.strtab 或者 .dynstr section 里面装载了字符串信息;
g).其他还有为满足不同目的所设置的section,比方满足调试的目的、满足动态链接与加载的目的等等。

使用readelf  -S filename可以查看一个ELF文件的ELF头,如下:

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         0000000000400200  00000200
       000000000000001c  0000000000000000   A       0     0     1
  [ 2] .note.ABI-tag     NOTE             000000000040021c  0000021c
       0000000000000020  0000000000000000   A       0     0     4
  [ 3] .hash             HASH             0000000000400240  00000240
       0000000000002db4  0000000000000004   A       4     0     8
  [ 4] .dynsym           DYNSYM           0000000000402ff8  00002ff8
       000000000000b160  0000000000000018   A       5     1     8
  [ 5] .dynstr           STRTAB           000000000040e158  0000e158
       00000000000121e5  0000000000000000   A       0     0     1
  [ 6] .gnu.version      VERSYM           000000000042033e  0002033e
       0000000000000ec8  0000000000000002   A       4     0     2
  [ 7] .gnu.version_r    VERNEED          0000000000421208  00021208
       0000000000000120  0000000000000000   A       5     7     8
  [ 8] .rela.dyn         RELA             0000000000421328  00021328
       0000000000008c58  0000000000000018   A       4     0     8
  [ 9] .rela.plt         RELA             0000000000429f80  00029f80
       0000000000002688  0000000000000018   A       4    11     8
  [10] .init             PROGBITS         000000000042c608  0002c608
       0000000000000018  0000000000000000  AX       0     0     4
  [11] .plt              PROGBITS         000000000042c620  0002c620
       00000000000019c0  0000000000000010  AX       0     0     4
  [12] .text             PROGBITS         000000000042dfe0  0002dfe0
       000000000043d958  0000000000000000  AX       0     0     16
  [13] .fini             PROGBITS         000000000086b938  0046b938
       000000000000000e  0000000000000000  AX       0     0     4
  [14] .rodata           PROGBITS         000000000086b960  0046b960
       000000000013abb5  0000000000000000   A       0     0     32
  [15] .eh_frame_hdr     PROGBITS         00000000009a6518  005a6518
       0000000000027804  0000000000000000   A       0     0     4
  [16] .eh_frame         PROGBITS         00000000009cdd20  005cdd20
       00000000000a5f84  0000000000000000   A       0     0     8
  [17] .gcc_except_table PROGBITS         0000000000a73ca8  00673ca8
       0000000000056639  0000000000000000   A       0     0     8
  [18] .ctors            PROGBITS         0000000000bca2e8  006ca2e8
       00000000000004f8  0000000000000000  WA       0     0     8
  [19] .dtors            PROGBITS         0000000000bca7e0  006ca7e0
       0000000000000010  0000000000000000  WA       0     0     8
  [20] .jcr              PROGBITS         0000000000bca7f0  006ca7f0
       0000000000000008  0000000000000000  WA       0     0     8
  [21] .data.rel.ro      PROGBITS         0000000000bca800  006ca800
       0000000000009260  0000000000000000  WA       0     0     32
  [22] .dynamic          DYNAMIC          0000000000bd3a60  006d3a60
       0000000000000210  0000000000000010  WA       5     0     8
  [23] .got              PROGBITS         0000000000bd3c70  006d3c70
       0000000000002e00  0000000000000008  WA       0     0     8
  [24] .got.plt          PROGBITS         0000000000bd6a70  006d6a70
       0000000000000cf0  0000000000000008  WA       0     0     8
  [25] .data             PROGBITS         0000000000bd7760  006d7760
       00000000000554f8  0000000000000000  WA       0     0     32
  [26] .bss              NOBITS           0000000000c2cc60  0072cc58
       0000000000371358  0000000000000000  WA       0     0     32
  [27] .comment          PROGBITS         0000000000000000  0072cc58
       0000000000003516  0000000000000000           0     0     1
  [28] .debug_aranges    PROGBITS         0000000000000000  0073016e
       00000000000933e0  0000000000000000           0     0     1
  [29] .debug_pubnames   PROGBITS         0000000000000000  007c354e
       00000000003eccfb  0000000000000000           0     0     1
  [30] .debug_info       PROGBITS         0000000000000000  00bb0249
       00000000026fcafd  0000000000000000           0     0     1
  [31] .debug_abbrev     PROGBITS         0000000000000000  032acd46
       000000000008ac3d  0000000000000000           0     0     1
  [32] .debug_line       PROGBITS         0000000000000000  03337983
       00000000001e952d  0000000000000000           0     0     1
  [33] .debug_frame      PROGBITS         0000000000000000  03520eb0
       0000000000181240  0000000000000000           0     0     8
  [34] .debug_str        PROGBITS         0000000000000000  036a20f0
       000000000029c013  0000000000000000           0     0     1
  [35] .debug_loc        PROGBITS         0000000000000000  0393e103
       0000000000634fc5  0000000000000000           0     0     1
  [36] .debug_ranges     PROGBITS         0000000000000000  03f730c8
       00000000000e2b40  0000000000000000           0     0     1
  [37] .shstrtab         STRTAB           0000000000000000  04055c08
       000000000000017c  0000000000000000           0     0     1
  [38] .symtab           SYMTAB           0000000000000000  04056788
       0000000000100890  0000000000000018          39   21532     8
  [39] .strtab           STRTAB           0000000000000000  04157018
       000000000019008a  0000000000000000           0     0     1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

对应的数据结构是:

linux下的ELF对象格式_第1张图片

     

(3)程序头表(program header table),自称为“段表”

        section是作为输入,给链接器那去做链接用的,所以这些section也经常被称做输入section。链接器在链接可执行文件或动态库的过程中,它会把来自不同对象文件中的相同名称的 section 合并起来构成同名的 section。接着,它又会把带有相同属性(比方都是只读并可加载的)的 section 都合并成所谓 segment。segment作为链接器的输出,常被称为输出segment。

         一个单独的 segment 通常会包含几个不同的 section,比方一个可被加载的、只读的segment 通常就会包括可执行代码.text section、只读的数据.rodata section 以及给动态链接器使用的符号.dymsym section等等。section是被链接器使用的,但是segment是被加载器所使用的。加载器会将所需要的segment加载到内存空间中运行。和用sections header table来指定一个ELF对象文件中到底有哪些section一样。也需要有一种信息结构来指出包含ELF对象文件有哪些segments,这种信息结构就是program header table。

使用readelf  -l filename可以查看一个ELF文件的程序头表,如下:

Elf file type is EXEC (Executable file)
Entry point 0x42dfe0
There are 8 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000400040 0x0000000000400040
                 0x00000000000001c0 0x00000000000001c0  R E    8
  INTERP         0x0000000000000200 0x0000000000400200 0x0000000000400200
                 0x000000000000001c 0x000000000000001c  R      1
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
                 0x00000000006ca2e1 0x00000000006ca2e1  R E    100000
  LOAD           0x00000000006ca2e8 0x0000000000bca2e8 0x0000000000bca2e8
                 0x0000000000062970 0x00000000003d3cd0  RW     100000
  DYNAMIC        0x00000000006d3a60 0x0000000000bd3a60 0x0000000000bd3a60
                 0x0000000000000210 0x0000000000000210  RW     8
  NOTE           0x000000000000021c 0x000000000040021c 0x000000000040021c
                 0x0000000000000020 0x0000000000000020  R      4
  GNU_EH_FRAME   0x00000000005a6518 0x00000000009a6518 0x00000000009a6518
                 0x0000000000027804 0x0000000000027804  R      4
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     8

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

备注,上面的Section to Segmet mapping,就表示的段segment和节section的映射关系。

对应的数据结构是:

typedef struct {
      Elf32_Word  p_type;				/* 段类型 */
      Elf32_Off   p_offset;     	 	        /* 段位置相对于文件开始处的偏移量 */
      Elf32_Addr  p_vaddr;   			        /* 段在内存中的地址 */
      Elf32_Addr  p_paddr;   			        /* 段的物理地址 */
      Elf32_Word  p_filesz;				/* 段在文件中的长度 */
      Elf32_Word  p_memsz;				/* 段在内存中的长度 */
      Elf32_Word  p_flags;				/* 段的标记 */
      Elf32_Word  p_align;				/* 段在内存中对齐标记 */
  } Elf32_Phdr;

4.一个readelf完整输出的例子

$readelf -all a.out
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Intel 80386
  Version:                           0x1
  Entry point address:               0x8048330
  Start of program headers:          52 (bytes into file)
  Start of section headers:          4412 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         9
  Size of section headers:           40 (bytes)
  Number of section headers:         30
  Section header string table index: 27

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .interp           PROGBITS        08048154 000154 000013 00   A  0   0  1
  [ 2] .note.ABI-tag     NOTE            08048168 000168 000020 00   A  0   0  4
  [ 3] .note.gnu.build-i NOTE            08048188 000188 000024 00   A  0   0  4
  [ 4] .gnu.hash         GNU_HASH        080481ac 0001ac 000020 04   A  5   0  4
  [ 5] .dynsym           DYNSYM          080481cc 0001cc 000050 10   A  6   1  4
  [ 6] .dynstr           STRTAB          0804821c 00021c 00004c 00   A  0   0  1
  [ 7] .gnu.version      VERSYM          08048268 000268 00000a 02   A  5   0  2
  [ 8] .gnu.version_r    VERNEED         08048274 000274 000020 00   A  6   1  4
  [ 9] .rel.dyn          REL             08048294 000294 000008 08   A  5   0  4
  [10] .rel.plt          REL             0804829c 00029c 000018 08   A  5  12  4
  [11] .init             PROGBITS        080482b4 0002b4 00002e 00  AX  0   0  4
  [12] .plt              PROGBITS        080482f0 0002f0 000040 04  AX  0   0 16
  [13] .text             PROGBITS        08048330 000330 00018c 00  AX  0   0 16
  [14] .fini             PROGBITS        080484bc 0004bc 00001a 00  AX  0   0  4
  [15] .rodata           PROGBITS        080484d8 0004d8 000011 00   A  0   0  4
  [16] .eh_frame_hdr     PROGBITS        080484ec 0004ec 000034 00   A  0   0  4
  [17] .eh_frame         PROGBITS        08048520 000520 0000c4 00   A  0   0  4
  [18] .ctors            PROGBITS        08049f14 000f14 000008 00  WA  0   0  4
  [19] .dtors            PROGBITS        08049f1c 000f1c 000008 00  WA  0   0  4
  [20] .jcr              PROGBITS        08049f24 000f24 000004 00  WA  0   0  4
  [21] .dynamic          DYNAMIC         08049f28 000f28 0000c8 08  WA  6   0  4
  [22] .got              PROGBITS        08049ff0 000ff0 000004 04  WA  0   0  4
  [23] .got.plt          PROGBITS        08049ff4 000ff4 000018 04  WA  0   0  4
  [24] .data             PROGBITS        0804a00c 00100c 000008 00  WA  0   0  4
  [25] .bss              NOBITS          0804a014 001014 000008 00  WA  0   0  4
  [26] .comment          PROGBITS        00000000 001014 00002a 01  MS  0   0  1
  [27] .shstrtab         STRTAB          00000000 00103e 0000fc 00      0   0  1
  [28] .symtab           SYMTAB          00000000 0015ec 000410 10     29  45  4
  [29] .strtab           STRTAB          00000000 0019fc 0001f9 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

There are no section groups in this file.

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x08048034 0x08048034 0x00120 0x00120 R E 0x4
  INTERP         0x000154 0x08048154 0x08048154 0x00013 0x00013 R   0x1
      [Requesting program interpreter: /lib/ld-linux.so.2]
  LOAD           0x000000 0x08048000 0x08048000 0x005e4 0x005e4 R E 0x1000
  LOAD           0x000f14 0x08049f14 0x08049f14 0x00100 0x00108 RW  0x1000
  DYNAMIC        0x000f28 0x08049f28 0x08049f28 0x000c8 0x000c8 RW  0x4
  NOTE           0x000168 0x08048168 0x08048168 0x00044 0x00044 R   0x4
  GNU_EH_FRAME   0x0004ec 0x080484ec 0x080484ec 0x00034 0x00034 R   0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x4
  GNU_RELRO      0x000f14 0x08049f14 0x08049f14 0x000ec 0x000ec 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 .rel.dyn .rel.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame
   03     .ctors .dtors .jcr .dynamic .got .got.plt .data .bss
   04     .dynamic
   05     .note.ABI-tag .note.gnu.build-id
   06     .eh_frame_hdr
   07
   08     .ctors .dtors .jcr .dynamic .got

Dynamic section at offset 0xf28 contains 20 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x0000000c (INIT)                       0x80482b4
 0x0000000d (FINI)                       0x80484bc
 0x6ffffef5 (GNU_HASH)                   0x80481ac
 0x00000005 (STRTAB)                     0x804821c
 0x00000006 (SYMTAB)                     0x80481cc
 0x0000000a (STRSZ)                      76 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000015 (DEBUG)                      0x0
 0x00000003 (PLTGOT)                     0x8049ff4
 0x00000002 (PLTRELSZ)                   24 (bytes)
 0x00000014 (PLTREL)                     REL
 0x00000017 (JMPREL)                     0x804829c
 0x00000011 (REL)                        0x8048294
 0x00000012 (RELSZ)                      8 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x6ffffffe (VERNEED)                    0x8048274
 0x6fffffff (VERNEEDNUM)                 1
 0x6ffffff0 (VERSYM)                     0x8048268
 0x00000000 (NULL)                       0x0

Relocation section '.rel.dyn' at offset 0x294 contains 1 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
08049ff0  00000206 R_386_GLOB_DAT    00000000   __gmon_start__

Relocation section '.rel.plt' at offset 0x29c contains 3 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
0804a000  00000107 R_386_JUMP_SLOT   00000000   printf
0804a004  00000207 R_386_JUMP_SLOT   00000000   __gmon_start__
0804a008  00000307 R_386_JUMP_SLOT   00000000   __libc_start_main

There are no unwind sections in this file.

Symbol table '.dynsym' contains 5 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000000     0 FUNC    GLOBAL DEFAULT  UND printf@GLIBC_2.0 (2)
     2: 00000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
     3: 00000000     0 FUNC    GLOBAL DEFAULT  UND __libc_start_main@GLIBC_2.0 (2)
     4: 080484dc     4 OBJECT  GLOBAL DEFAULT   15 _IO_stdin_used

Symbol table '.symtab' contains 65 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 08048154     0 SECTION LOCAL  DEFAULT    1
     2: 08048168     0 SECTION LOCAL  DEFAULT    2
     3: 08048188     0 SECTION LOCAL  DEFAULT    3
     4: 080481ac     0 SECTION LOCAL  DEFAULT    4
     5: 080481cc     0 SECTION LOCAL  DEFAULT    5
     6: 0804821c     0 SECTION LOCAL  DEFAULT    6
     7: 08048268     0 SECTION LOCAL  DEFAULT    7
     8: 08048274     0 SECTION LOCAL  DEFAULT    8
     9: 08048294     0 SECTION LOCAL  DEFAULT    9
    10: 0804829c     0 SECTION LOCAL  DEFAULT   10
    11: 080482b4     0 SECTION LOCAL  DEFAULT   11
    12: 080482f0     0 SECTION LOCAL  DEFAULT   12
    13: 08048330     0 SECTION LOCAL  DEFAULT   13
    14: 080484bc     0 SECTION LOCAL  DEFAULT   14
    15: 080484d8     0 SECTION LOCAL  DEFAULT   15
    16: 080484ec     0 SECTION LOCAL  DEFAULT   16
    17: 08048520     0 SECTION LOCAL  DEFAULT   17
    18: 08049f14     0 SECTION LOCAL  DEFAULT   18
    19: 08049f1c     0 SECTION LOCAL  DEFAULT   19
    20: 08049f24     0 SECTION LOCAL  DEFAULT   20
    21: 08049f28     0 SECTION LOCAL  DEFAULT   21
    22: 08049ff0     0 SECTION LOCAL  DEFAULT   22
    23: 08049ff4     0 SECTION LOCAL  DEFAULT   23
    24: 0804a00c     0 SECTION LOCAL  DEFAULT   24
    25: 0804a014     0 SECTION LOCAL  DEFAULT   25
    26: 00000000     0 SECTION LOCAL  DEFAULT   26
    27: 00000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
    28: 08049f14     0 OBJECT  LOCAL  DEFAULT   18 __CTOR_LIST__
    29: 08049f1c     0 OBJECT  LOCAL  DEFAULT   19 __DTOR_LIST__
    30: 08049f24     0 OBJECT  LOCAL  DEFAULT   20 __JCR_LIST__
    31: 08048360     0 FUNC    LOCAL  DEFAULT   13 __do_global_dtors_aux
    32: 0804a014     1 OBJECT  LOCAL  DEFAULT   25 completed.6086
    33: 0804a018     4 OBJECT  LOCAL  DEFAULT   25 dtor_idx.6088
    34: 080483c0     0 FUNC    LOCAL  DEFAULT   13 frame_dummy
    35: 00000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
    36: 08049f18     0 OBJECT  LOCAL  DEFAULT   18 __CTOR_END__
    37: 080485e0     0 OBJECT  LOCAL  DEFAULT   17 __FRAME_END__
    38: 08049f24     0 OBJECT  LOCAL  DEFAULT   20 __JCR_END__
    39: 08048490     0 FUNC    LOCAL  DEFAULT   13 __do_global_ctors_aux
    40: 00000000     0 FILE    LOCAL  DEFAULT  ABS a.c
    41: 08049f14     0 NOTYPE  LOCAL  DEFAULT   18 __init_array_end
    42: 08049f28     0 OBJECT  LOCAL  DEFAULT   21 _DYNAMIC
    43: 08049f14     0 NOTYPE  LOCAL  DEFAULT   18 __init_array_start
    44: 08049ff4     0 OBJECT  LOCAL  DEFAULT   23 _GLOBAL_OFFSET_TABLE_
    45: 08048480     2 FUNC    GLOBAL DEFAULT   13 __libc_csu_fini
    46: 08048482     0 FUNC    GLOBAL HIDDEN    13 __i686.get_pc_thunk.bx
    47: 0804a00c     0 NOTYPE  WEAK   DEFAULT   24 data_start
    48: 00000000     0 FUNC    GLOBAL DEFAULT  UND printf@@GLIBC_2.0
    49: 0804a014     0 NOTYPE  GLOBAL DEFAULT  ABS _edata
    50: 080484bc     0 FUNC    GLOBAL DEFAULT   14 _fini
    51: 08049f20     0 OBJECT  GLOBAL HIDDEN    19 __DTOR_END__
    52: 0804a00c     0 NOTYPE  GLOBAL DEFAULT   24 __data_start
    53: 00000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
    54: 0804a010     0 OBJECT  GLOBAL HIDDEN    24 __dso_handle
    55: 080484dc     4 OBJECT  GLOBAL DEFAULT   15 _IO_stdin_used
    56: 00000000     0 FUNC    GLOBAL DEFAULT  UND __libc_start_main@@GLIBC_
    57: 08048410    97 FUNC    GLOBAL DEFAULT   13 __libc_csu_init
    58: 0804a01c     0 NOTYPE  GLOBAL DEFAULT  ABS _end
    59: 08048330     0 FUNC    GLOBAL DEFAULT   13 _start
    60: 080484d8     4 OBJECT  GLOBAL DEFAULT   15 _fp_hw
    61: 0804a014     0 NOTYPE  GLOBAL DEFAULT  ABS __bss_start
    62: 080483e4    40 FUNC    GLOBAL DEFAULT   13 main
    63: 00000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses
    64: 080482b4     0 FUNC    GLOBAL DEFAULT   11 _init

Histogram for `.gnu.hash' bucket list length (total of 2 buckets):
 Length  Number     % of total  Coverage
      0  1          ( 50.0%)
      1  1          ( 50.0%)    100.0%

Version symbols section '.gnu.version' contains 5 entries:
 Addr: 0000000008048268  Offset: 0x000268  Link: 5 (.dynsym)
  000:   0 (*local*)       2 (GLIBC_2.0)     0 (*local*)       2 (GLIBC_2.0)
  004:   1 (*global*)

Version needs section '.gnu.version_r' contains 1 entries:
 Addr: 0x0000000008048274  Offset: 0x000274  Link: 6 (.dynstr)
  000000: Version: 1  File: libc.so.6  Cnt: 1
  0x0010:   Name: GLIBC_2.0  Flags: none  Version: 2

Notes at offset 0x00000168 with length 0x00000020:
  Owner                 Data size   Description
  GNU                  0x00000010   NT_GNU_ABI_TAG (ABI version tag)
    OS: Linux, ABI: 2.6.15

Notes at offset 0x00000188 with length 0x00000024:
  Owner                 Data size   Description
  GNU                  0x00000014   NT_GNU_BUILD_ID (unique build ID bitstring)
    Build ID: 17fb9651029b6a8543bfafec9eea23bd16454e65


学习资料来源于:

http://www.cnblogs.com/xmphoenix/archive/2011/10/23/2221879.html

https://www.ibm.com/developerworks/cn/linux/l-excutff/#resources

你可能感兴趣的:(linux下的ELF对象格式)