您的位置:首页 > 移动开发 > Objective-C

静态连接4-hello

2011-08-04 17:33 148 查看
 看一下hello的各个段

[root@localhost mhello]# readelf -S  hello

There are 30 section headers, starting at offset 0xadc:
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        08048134 000134 000013 00   A  0   0  1

  [ 2] .note.ABI-tag     NOTE            08048148 000148 000020 00   A  0   0  4

  [ 3] .note.gnu.build-i NOTE            08048168 000168 000024 00   A  0   0  4

  [ 4] .gnu.hash         GNU_HASH        0804818c 00018c 00003c 04   A  5   0  4

  [ 5] .dynsym           DYNSYM          080481c8 0001c8 0000e0 10   A  6   1  4

  [ 6] .dynstr           STRTAB          080482a8 0002a8 0000b1 00   A  0   0  1

  [ 7] .gnu.version      VERSYM          0804835a 00035a 00001c 02   A  5   0  2

  [ 8] .gnu.version_r    VERNEED         08048378 000378 000020 00   A  6   1  4

  [ 9] .rel.dyn          REL             08048398 000398 000008 08   A  5   0  4

  [10] .rel.plt          REL             080483a0 0003a0 000028 08   A  5  12  4

  [11] .init             PROGBITS        080483c8 0003c8 000030 00  AX  0   0  4

  [12] .plt              PROGBITS        080483f8 0003f8 000060 04  AX  0   0  4

  [13] .text             PROGBITS        08048460 000460 00021c 00  AX  0   0 16

  [14] .fini             PROGBITS        0804867c 00067c 00001c 00  AX  0   0  4

  [15] .rodata           PROGBITS        08048698 000698 000088 00   A  0   0  4

  [16] .eh_frame_hdr     PROGBITS        08048720 000720 00001c 00   A  0   0  4

  [17] .eh_frame         PROGBITS        0804873c 00073c 000058 00   A  0   0  4

  [18] .ctors            PROGBITS        08049794 000794 000008 00  WA  0   0  4

  [19] .dtors            PROGBITS        0804979c 00079c 000008 00  WA  0   0  4

  [20] .jcr              PROGBITS        080497a4 0007a4 000004 00  WA  0   0  4

  [21] .dynamic          DYNAMIC         080497a8 0007a8 0000d0 08  WA  6   0  4

  [22] .got              PROGBITS        08049878 000878 000004 04  WA  0   0  4

  [23] .got.plt          PROGBITS        0804987c 00087c 000020 04  WA  0   0  4

  [24] .data             PROGBITS        0804989c 00089c 000008 00  WA  0   0  4

  [25] .bss              NOBITS          080498a4 0008a4 000008 00  WA  0   0  4

  [26] .comment          PROGBITS        00000000 0008a4 00013b 00      0   0  1

  [27] .shstrtab         STRTAB          00000000 0009df 0000fc 00      0   0  1

  [28] .symtab           SYMTAB          00000000 000f8c 000480 10     29  46  4

  [29] .strtab           STRTAB          00000000 00140c 00025d 00      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)

看一下hello的符号表

[root@localhost mhello]# readelf -s hello

Symbol table '.dynsym' contains 14 entries:

   Num:    Value  Size Type    Bind   Vis      Ndx Name

     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND

     1: 00000000     4 OBJECT  GLOBAL DEFAULT  UND var_public_file_b

     2: 00000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__

     3: 00000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses

     4: 00000000   451 FUNC    GLOBAL DEFAULT  UND
__libc_start_main@GLIBC_2.0 (2)

     5: 00000000    54 FUNC    GLOBAL DEFAULT  UND
printf@GLIBC_2.0 (2)

     6: 00000000   460 FUNC    GLOBAL DEFAULT  UND
puts@GLIBC_2.0 (2)

     7: 00000000    96 FUNC    GLOBAL DEFAULT  UND func_file_b

     8: 080498ac     0 NOTYPE  GLOBAL DEFAULT  ABS _end

     9: 080498a4     0 NOTYPE  GLOBAL DEFAULT  ABS _edata

    10: 0804869c     4 OBJECT  GLOBAL DEFAULT   15 _IO_stdin_used

    11: 080498a4     0 NOTYPE  GLOBAL DEFAULT  ABS __bss_start

    12: 080483c8     0 FUNC    GLOBAL DEFAULT   11 _init

    13: 0804867c     0 FUNC    GLOBAL DEFAULT   14 _fini

Symbol table '.symtab' contains 72 entries:

   Num:    Value  Size Type    Bind   Vis      Ndx Name

     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND

     1: 08048134     0 SECTION LOCAL  DEFAULT    1

     2: 08048148     0 SECTION LOCAL  DEFAULT    2

     3: 08048168     0 SECTION LOCAL  DEFAULT    3

     4: 0804818c     0 SECTION LOCAL  DEFAULT    4

     5: 080481c8     0 SECTION LOCAL  DEFAULT    5

     6: 080482a8     0 SECTION LOCAL  DEFAULT    6

     7: 0804835a     0 SECTION LOCAL  DEFAULT    7

     8: 08048378     0 SECTION LOCAL  DEFAULT    8

     9: 08048398     0 SECTION LOCAL  DEFAULT    9

    10: 080483a0     0 SECTION LOCAL  DEFAULT   10

    11: 080483c8     0 SECTION LOCAL  DEFAULT   11

    12: 080483f8     0 SECTION LOCAL  DEFAULT   12

    13: 08048460     0 SECTION LOCAL  DEFAULT   13

    14: 0804867c     0 SECTION LOCAL  DEFAULT   14

    15: 08048698     0 SECTION LOCAL  DEFAULT   15

    16: 08048720     0 SECTION LOCAL  DEFAULT   16

    17: 0804873c     0 SECTION LOCAL  DEFAULT   17

    18: 08049794     0 SECTION LOCAL  DEFAULT   18

    19: 0804979c     0 SECTION LOCAL  DEFAULT   19

    20: 080497a4     0 SECTION LOCAL  DEFAULT   20

    21: 080497a8     0 SECTION LOCAL  DEFAULT   21

    22: 08049878     0 SECTION LOCAL  DEFAULT   22

    23: 0804987c     0 SECTION LOCAL  DEFAULT   23

    24: 0804989c     0 SECTION LOCAL  DEFAULT   24

    25: 080498a4     0 SECTION LOCAL  DEFAULT   25

    26: 00000000     0 SECTION LOCAL  DEFAULT   26

    27: 00000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c

    28: 08049794     0 OBJECT  LOCAL  DEFAULT   18 __CTOR_LIST__

    29: 0804979c     0 OBJECT  LOCAL  DEFAULT   19 __DTOR_LIST__

    30: 080497a4     0 OBJECT  LOCAL  DEFAULT   20 __JCR_LIST__

    31: 08048490     0 FUNC    LOCAL  DEFAULT   13 __do_global_dtors_aux

    32: 080498a4     1 OBJECT  LOCAL  DEFAULT   25 completed.5699

    33: 080498a8     4 OBJECT  LOCAL  DEFAULT   25 dtor_idx.5701

    34: 080484f0     0 FUNC    LOCAL  DEFAULT   13 frame_dummy

    35: 00000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c

    36: 08049798     0 OBJECT  LOCAL  DEFAULT   18 __CTOR_END__

    37: 08048790     0 OBJECT  LOCAL  DEFAULT   17 __FRAME_END__

    38: 080497a4     0 OBJECT  LOCAL  DEFAULT   20 __JCR_END__

    39: 08048650     0 FUNC    LOCAL  DEFAULT   13 __do_global_ctors_aux

    40: 00000000     0 FILE    LOCAL  DEFAULT  ABS hello.c

    41: 00000000     0 FILE    LOCAL  DEFAULT  ABS file_a.c

    42: 0804987c     0 OBJECT  LOCAL  HIDDEN   23 _GLOBAL_OFFSET_TABLE_

    43: 08049794     0 NOTYPE  LOCAL  HIDDEN   18 __init_array_end

    44: 08049794     0 NOTYPE  LOCAL  HIDDEN   18 __init_array_start

    45: 080497a8     0 OBJECT  LOCAL  HIDDEN   21 _DYNAMIC

    46: 0804989c     0 NOTYPE  WEAK   DEFAULT   24 data_start

    47: 080485e0     5 FUNC    GLOBAL DEFAULT   13 __libc_csu_fini

    48: 08048460     0 FUNC    GLOBAL DEFAULT   13 _start

    49: 00000000     4 OBJECT  GLOBAL DEFAULT  UND var_public_file_b
    50: 00000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__

    51: 00000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses

    52: 08048698     4 OBJECT  GLOBAL DEFAULT   15 _fp_hw

    53: 0804867c     0 FUNC    GLOBAL DEFAULT   14 _fini

    54: 0804857c    96 FUNC    GLOBAL DEFAULT   13 func_file_a
    55: 00000000   451 FUNC    GLOBAL DEFAULT  UND
__libc_start_main@@GLIBC_

    56: 0804869c     4 OBJECT  GLOBAL DEFAULT   15 _IO_stdin_used

    57: 0804989c     0 NOTYPE  GLOBAL DEFAULT   24 __data_start

    58: 080498a0     4 OBJECT  GLOBAL DEFAULT   24 var_public_file_a
    59: 080486a0     0 OBJECT  GLOBAL HIDDEN   15 __dso_handle

    60: 080497a0     0 OBJECT  GLOBAL HIDDEN   19 __DTOR_END__

    61: 080485f0    90 FUNC    GLOBAL DEFAULT   13 __libc_csu_init

    62: 00000000    54 FUNC    GLOBAL DEFAULT  UND
printf@@GLIBC_2.0

    63: 080498a4     0 NOTYPE  GLOBAL DEFAULT  ABS __bss_start

    64: 08048514    20 FUNC    GLOBAL DEFAULT   13 func_hello
    65: 080498ac     0 NOTYPE  GLOBAL DEFAULT  ABS _end

    66: 00000000   460 FUNC    GLOBAL DEFAULT  UND
puts@@GLIBC_2.0

    67: 080498a4     0 NOTYPE  GLOBAL DEFAULT  ABS _edata

    68: 00000000    96 FUNC    GLOBAL DEFAULT  UND func_file_b
    69: 0804864a     0 FUNC    GLOBAL HIDDEN   13 __i686.get_pc_thunk.bx

    70: 08048528    84 FUNC    GLOBAL DEFAULT   13 main
    71: 080483c8     0 FUNC    GLOBAL DEFAULT   11 _init

看一下hello的重定位表

[root@localhost mhello]# readelf -r hello

Relocation section '.rel.dyn' at offset 0x398 contains 1 entries:

 Offset     Info    Type            Sym.Value  Sym. Name

08049878  00000206 R_386_GLOB_DAT    00000000   __gmon_start__

Relocation section '.rel.plt' at offset 0x3a0 contains 5 entries:

 Offset     Info    Type            Sym.Value  Sym. Name

08049888  00000207 R_386_JUMP_SLOT   00000000   __gmon_start__

0804988c  00000407 R_386_JUMP_SLOT   00000000   __libc_start_main
08049890  00000507 R_386_JUMP_SLOT   00000000   printf

08049894  00000607 R_386_JUMP_SLOT   00000000   puts

08049898  00000707 R_386_JUMP_SLOT   00000000   func_file_b 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息