码迷,mamicode.com
首页 > 其他好文 > 详细

查看程序符号表的几个命令

时间:2015-07-20 23:34:51      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:

objdump -t xxx.o

weeds@weeds-ThinkPad-T440p:~/Documents/encrypchip$ objdump -t main.o

main.o:     file format elf32-little

SYMBOL TABLE:
00000000 l    df *ABS*  00000000 main.c
00000000 l    d  .text  00000000 .text
00000000 l    d  .data  00000000 .data
00000000 l    d  .bss   00000000 .bss
00000000 l    d  .mdebug.abi32  00000000 .mdebug.abi32
00000000 l    d  .rodata    00000000 .rodata
00000000 l    d  .reginfo   00000000 .reginfo
00000000 l    d  .pdr   00000000 .pdr
00000000 l    d  .comment   00000000 .comment
00000000 l    d  .gnu.attributes    00000000 .gnu.attributes
00000000 g     F .text  000000dc demo1
00000000         *UND*  00000000 GetIdChipSerialNo
00000000         *UND*  00000000 printf
00000000         *UND*  00000000 putchar
000000dc g     F .text  0000027c demo2
00000000         *UND*  00000000 _alpu_rand
00000000         *UND*  00000000 gettimeofday
00000000         *UND*  00000000 alpuc_process
00000000         *UND*  00000000 puts
00000358 g     F .text  0000003c main

readelf -h xxx.o

weeds@weeds-ThinkPad-T440p:~/Documents/encrypchip$ readelf  -h main.o 
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:                              REL (Relocatable file)
  Machine:                           MIPS R3000
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          1624 (bytes into file)
  Flags:                             0x1005, noreorder, cpic, o32, mips1
  Size of this header:               52 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           40 (bytes)
  Number of section headers:         15
  Section header string table index: 12

readelf -s main.o

weeds@weeds-ThinkPad-T440p:~/Documents/encrypchip$ readelf  -s main.o 

Symbol table ‘.symtab‘ contains 21 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
    0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
 1: 00000000     0 FILE    LOCAL  DEFAULT  ABS main.c
 2: 00000000     0 SECTION LOCAL  DEFAULT    1 
 3: 00000000     0 SECTION LOCAL  DEFAULT    3 
 4: 00000000     0 SECTION LOCAL  DEFAULT    4 
 5: 00000000     0 SECTION LOCAL  DEFAULT    8 
 6: 00000000     0 SECTION LOCAL  DEFAULT    9 
 7: 00000000     0 SECTION LOCAL  DEFAULT    5 
 8: 00000000     0 SECTION LOCAL  DEFAULT    6 
 9: 00000000     0 SECTION LOCAL  DEFAULT   10 
10: 00000000     0 SECTION LOCAL  DEFAULT   11 
11: 00000000   220 FUNC    GLOBAL DEFAULT    1 demo1
12: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND GetIdChipSerialNo
13: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND printf
14: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND putchar
15: 000000dc   636 FUNC    GLOBAL DEFAULT    1 demo2
16: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _alpu_rand
17: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND gettimeofday
18: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND alpuc_process
19: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND puts
20: 00000358    60 FUNC    GLOBAL DEFAULT    1 main

nm xxx.o 对比g++编译程序生成的符号表与gcc生成的不同点。

weeds@weeds-ThinkPad-T440p:~/Documents/encrypchip$ nm main.o #g++ compile
     U _Z10_alpu_randv
     U _Z13alpuc_processPhS_
     U _Z17GetIdChipSerialNoPh
00000000 T _Z5demo1v
000000dc T _Z5demo2v
     U gettimeofday
00000358 T main
     U printf
     U putchar
     U puts

weeds@weeds-ThinkPad-T440p:~/Documents/encrypchip$ mipsel-openwrt-linux-gcc -c main.c 
mipsel-openwrt-linux-gcc: warning: environment variable ‘STAGING_DIR‘ not defined
weeds@weeds-ThinkPad-T440p:~/Documents/encrypchip$ nm main.o #gcc compile
     U GetIdChipSerialNo
     U _alpu_rand
     U alpuc_process
00000000 T demo1
000000dc T demo2
         U gettimeofday
00000358 T main
     U printf
     U putchar
     U puts

版权声明:本文为博主原创文章,未经博主允许不得转载。

查看程序符号表的几个命令

标签:

原文地址:http://blog.csdn.net/qianguozheng/article/details/46652899

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!