分页: 1 / 1

[问题]如何查看一个so文件里面提供的所有函数(symbols)?

发表于 : 2007-04-02 13:18
hyfans
例如ati fglrx自己的libGL.so,我想知道这个文件里面提供的所有函数,如何查看呢?

发表于 : 2007-04-02 13:43
hyfans
难不成是readelf -a xxx.so

发表于 : 2007-04-18 10:51
fuhuizn
nm xxx.so

发表于 : 2007-04-18 11:34
eexpress
readelf可以啊。ldd可以看调用库啊。

发表于 : 2007-04-19 13:44
stlxv
eexpress 写了:readelf可以啊。ldd可以看调用库啊。
ldd看的是连接的库

发表于 : 2007-04-19 13:51
stlxv

代码: 全选

stlxv@stlxvcomputer:~/ds-gui/libdld/diassembler$ readelf -a libdld.so
ELF 头:
  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:                              DYN (共享目标文件)
  Machine:                           Intel 80386
  Version:                           0x1
  入口点地址:               0x570
  程序头起点:          52 (bytes into file)
  Start of section headers:          5168 (bytes into file)
  标志:             0x0
  本头的大小:       52 (字节)
  程序头大小:       32 (字节)
  程序头数量:       4
  节头大小:         40 (字节)
  节头数量:         24
  字符串表索引节头: 23

节头:
  [Nr] Name              Type            Addr     Off    Size   ES 囗囗囗 Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .hash             HASH            000000b4 0000b4 0000b8 04   A  2   0  4
  [ 2] .dynsym           DYNSYM          0000016c 00016c 0001b0 10   A  3  11  4
  [ 3] .dynstr           STRTAB          0000031c 00031c 0000e4 00   A  0   0  1
  [ 4] .gnu.version      VERSYM          00000400 000400 000036 02   A  2   0  2
  [ 5] .gnu.version_r    VERNEED         00000438 000438 000030 00   A  3   1  4
  [ 6] .rel.dyn          REL             00000468 000468 000038 08   A  2   0  4
  [ 7] .rel.plt          REL             000004a0 0004a0 000038 08   A  2   9  4
  [ 8] .init             PROGBITS        000004d8 0004d8 000017 00  AX  0   0  4
  [ 9] .plt              PROGBITS        000004f0 0004f0 000080 04  AX  0   0  4
  [10] .text             PROGBITS        00000570 000570 0009f4 00  AX  0   0 16
  [11] .fini             PROGBITS        00000f64 000f64 00001c 00  AX  0   0  4
  [12] .rodata           PROGBITS        00000f80 000f80 000152 00   A  0   0  1
  [13] .eh_frame         PROGBITS        000010d4 0010d4 000004 00   A  0   0  4
  [14] .ctors            PROGBITS        000020d8 0010d8 000008 00  WA  0   0  4
  [15] .dtors            PROGBITS        000020e0 0010e0 000008 00  WA  0   0  4
  [16] .jcr              PROGBITS        000020e8 0010e8 000004 00  WA  0   0  4
  [17] .dynamic          DYNAMIC         000020ec 0010ec 0000c8 08  WA  3   0  4
  [18] .got              PROGBITS        000021b4 0011b4 000014 04  WA  0   0  4
  [19] .got.plt          PROGBITS        000021c8 0011c8 000028 04  WA  0   0  4
  [20] .data             PROGBITS        000021f0 0011f0 000008 00  WA  0   0  4
  [21] .bss              NOBITS          00002200 0011f8 00041c 00  WA  0   0 32
  [22] .comment          PROGBITS        00000000 0011f8 000186 00      0   0  1
  [23] .shstrtab         STRTAB          00000000 00137e 0000b1 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)

There are no section groups in this file.

程序头:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  囗囗囗 Align
  LOAD           0x000000 0x00000000 0x00000000 0x010d8 0x010d8 R E 0x1000
  LOAD           0x0010d8 0x000020d8 0x000020d8 0x00120 0x00544 RW  0x1000
  DYNAMIC        0x0010ec 0x000020ec 0x000020ec 0x000c8 0x000c8 RW  0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x4

 Section to Segment mapping:
  段节...
   00     .hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .eh_frame 
   01     .ctors .dtors .jcr .dynamic .got .got.plt .data .bss 
   02     .dynamic 
   03     

Dynamic section at offset 0x10ec contains 21 entries:
  标记        类型                         名称/值
 0x00000001 (NEEDED)                     共享库:[libc.so.6]
 0x0000000e (SONAME)                     Library soname: [libdld.so.0]
 0x0000000c (INIT)                       0x4d8
 0x0000000d (FINI)                       0xf64
 0x00000004 (HASH)                       0xb4
 0x00000005 (STRTAB)                     0x31c
 0x00000006 (SYMTAB)                     0x16c
 0x0000000a (STRSZ)                      228 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000003 (PLTGOT)                     0x21c8
 0x00000002 (PLTRELSZ)                   56 (bytes)
 0x00000014 (PLTREL)                     REL
 0x00000017 (JMPREL)                     0x4a0
 0x00000011 (REL)                        0x468
 0x00000012 (RELSZ)                      56 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x6ffffffe (VERNEED)                    0x438
 0x6fffffff (VERNEEDNUM)                 1
 0x6ffffff0 (VERSYM)                     0x400
 0x6ffffffa (RELCOUNT)                   2
 0x00000000 (NULL)                       0x0

重定位节 “.rel.dyn” 位于偏移量 0x468 含有 7 个条目:
 Offset     Info    Type            Sym.Value  Sym. Name
000021f0  00000008 R_386_RELATIVE   
000021f4  00000008 R_386_RELATIVE   
000021b4  00000d06 R_386_GLOB_DAT    00002204   __initialized
000021b8  00001306 R_386_GLOB_DAT    00000000   __cxa_finalize
000021bc  00001706 R_386_GLOB_DAT    00002220   __instructions
000021c0  00001806 R_386_GLOB_DAT    00000000   _Jv_RegisterClasses
000021c4  00001906 R_386_GLOB_DAT    00000000   __gmon_start__

重定位节 “.rel.plt” 位于偏移量 0x4a0 含有 7 个条目:
 Offset     Info    Type            Sym.Value  Sym. Name
000021d4  00000b07 R_386_JUMP_SLOT   00000ae4   isValidTemplate
000021d8  00000c07 R_386_JUMP_SLOT   0000063c   init_instructions
000021dc  00000e07 R_386_JUMP_SLOT   00000aaa   init_lib
000021e0  00001007 R_386_JUMP_SLOT   00000000   malloc
000021e4  00001307 R_386_JUMP_SLOT   00000000   __cxa_finalize
000021e8  00001907 R_386_JUMP_SLOT   00000000   __gmon_start__
000021ec  00001a07 R_386_JUMP_SLOT   00000000   strcpy

There are no unwind sections in this file.

Symbol table '.dynsym' contains 27 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 000004d8     0 SECTION LOCAL  DEFAULT    8 
     2: 00000570     0 SECTION LOCAL  DEFAULT   10 
     3: 00000f64     0 SECTION LOCAL  DEFAULT   11 
     4: 00000f80     0 SECTION LOCAL  DEFAULT   12 
     5: 000010d4     0 SECTION LOCAL  DEFAULT   13 
     6: 000020d8     0 SECTION LOCAL  DEFAULT   14 
     7: 000020e0     0 SECTION LOCAL  DEFAULT   15 
     8: 000020e8     0 SECTION LOCAL  DEFAULT   16 
     9: 000021f0     0 SECTION LOCAL  DEFAULT   20 
    10: 00002200     0 SECTION LOCAL  DEFAULT   21 
    11: 00000ae4   131 FUNC    GLOBAL DEFAULT   10 isValidTemplate
    12: 0000063c  1134 FUNC    GLOBAL DEFAULT   10 init_instructions
    13: 00002204     4 OBJECT  GLOBAL DEFAULT   21 __initialized
    14: 00000aaa    53 FUNC    GLOBAL DEFAULT   10 init_lib
    15: 000004d8     0 FUNC    GLOBAL DEFAULT    8 _init
    16: 00000000   392 FUNC    GLOBAL DEFAULT  UND malloc@GLIBC_2.0 (2)
    17: 000021f8     0 NOTYPE  GLOBAL DEFAULT  ABS __bss_start
    18: 00000f64     0 FUNC    GLOBAL DEFAULT   11 _fini
    19: 00000000   182 FUNC    WEAK   DEFAULT  UND __cxa_finalize@GLIBC_2.1.3 (3)
    20: 00000b67   969 FUNC    GLOBAL DEFAULT   10 diassemble
    21: 000021f8     0 NOTYPE  GLOBAL DEFAULT  ABS _edata
    22: 0000261c     0 NOTYPE  GLOBAL DEFAULT  ABS _end
    23: 00002220  1020 OBJECT  GLOBAL DEFAULT   21 __instructions
    24: 00000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses
    25: 00000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
    26: 00000000    34 FUNC    GLOBAL DEFAULT  UND strcpy@GLIBC_2.0 (2)

Histogram for bucket list length (total of 17 buckets):
 Length  Number     % of total  Coverage
      0  6          ( 35.3%)
      1  7          ( 41.2%)     43.8%
      2  3          ( 17.6%)     81.2%
      3  1          (  5.9%)    100.0%

版本符号节“.gnu.version”含有 27 个条目:
 地址: 0000000000000400  偏移量:0x000400  连接:2 (.dynsym)
  000:   0 (*本地*)       0 (*本地*)       0 (*本地*)       0 (*本地*)    
  004:   0 (*本地*)       0 (*本地*)       0 (*本地*)       0 (*本地*)    
  008:   0 (*本地*)       0 (*本地*)       0 (*本地*)       1 (*全局*)   
  00c:   1 (*全局*)      1 (*全局*)      1 (*全局*)      1 (*全局*)   
  010:   2 (GLIBC_2.0)     1 (*全局*)      1 (*全局*)      3 (GLIBC_2.1.3)
  014:   1 (*全局*)      1 (*全局*)      1 (*全局*)      1 (*全局*)   
  018:   0 (*本地*)       0 (*本地*)       2 (GLIBC_2.0)  

Version needs section '.gnu.version_r' contains 1 entries:
 地址:0x0000000000000438  Offset: 0x000438  Link to section: 3 (.dynstr)
  000000: Version: 1  文件:libc.so.6  计数:2
  0x0010:   Name: GLIBC_2.1.3  标志:无  版本:3
  0x0020:   Name: GLIBC_2.0  标志:无  版本:2