linux 的readelf命令查看so文件

2019-10-19  本文已影响0人  牵手生活

查看readelf 的帮助说明(选项)

一般可以使用readelf工具来获得so的详细信息。
windows可以使用So Helper工具(个人感觉不太好用)

$ readelf -h
#下面时命令输出的help说明
caizhigui@czg-ThinkPad-ubuntu:~/czgSoft/czgTemp/wechat 7.0.5/lib/armeabi-v7a$ readelf -h
readelf: Warning: Nothing to do.
Usage: readelf <option(s)> elf-file(s)
 Display information about the contents of ELF format files
 Options are:
  -a --all               Equivalent to: -h -l -S -s -r -d -V -A -I
  -h --file-header       Display the ELF file header
  -l --program-headers   Display the program headers
     --segments          An alias for --program-headers
  -S --section-headers   Display the sections' header
     --sections          An alias for --section-headers
  -g --section-groups    Display the section groups
  -t --section-details   Display the section details
  -e --headers           Equivalent to: -h -l -S
  -s --syms              Display the symbol table
     --symbols           An alias for --syms
  --dyn-syms             Display the dynamic symbol table
  -n --notes             Display the core notes (if present)
  -r --relocs            Display the relocations (if present)
  -u --unwind            Display the unwind info (if present)
  -d --dynamic           Display the dynamic section (if present)
  -V --version-info      Display the version sections (if present)
  -A --arch-specific     Display architecture specific information (if any)
  -c --archive-index     Display the symbol/file index in an archive
  -D --use-dynamic       Use the dynamic section info when displaying symbols
  -x --hex-dump=<number|name>
                         Dump the contents of section <number|name> as bytes
  -p --string-dump=<number|name>
                         Dump the contents of section <number|name> as strings
  -R --relocated-dump=<number|name>
                         Dump the contents of section <number|name> as relocated bytes
  -z --decompress        Decompress section before dumping it
  -w[lLiaprmfFsoRtUuTgAckK] or
  --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,
               =frames-interp,=str,=loc,=Ranges,=pubtypes,
               =gdb_index,=trace_info,=trace_abbrev,=trace_aranges,
               =addr,=cu_index,=links,=follow-links]
                         Display the contents of DWARF debug sections
  --dwarf-depth=N        Do not display DIEs at depth N or greater
  --dwarf-start=N        Display DIEs starting with N, at the same depth
                         or deeper
  -I --histogram         Display histogram of bucket list lengths
  -W --wide              Allow output width to exceed 80 characters
  @<file>                Read options from <file>
  -H --help              Display this information
  -v --version           Display the version number of readelf

常用的选项说明

 -a 显示so文件所以信息
 -h ELF文件头
 -l program-headers ,静态加载分析时需要的信息
 -S section-headers ,静态加载分析时需要的信息
 -e 头信息,elf header,section header,program header
 -s 显示符号表
 -d 显示动态节  

readelf -h 查看so的头信息

ELF格式文件符号表全解析及readelf命令使用方法

$ readelf -h libwechatxlog.so
readelf -h

readelf -S查看so ---静态加载分析时需要的信息(ida工具就是利用该功能来加载)

$ readelf -S libwechatxlog.so 
readelf -S

readelf -l 查看so ---动态加载分析时需要的信息(ida工具调试就是利用该功能来加载)

如果so文件被混淆,那么Section Headers可能是错的,被修改过的,但它的Program Headers肯定是对的。

$ readelf -l libwechatxlog.so 
readelf -l

readelf -d 查看so ---动态节--可以看到程序依赖库的文件、表的备注信息之类

$ readelf -d libwechatxlog.so 
readelf -d

readelf -s 符号表机制

符号表保存了程序实现或使用的所有全局变量和函数,如果程序引用一个自身代码未定义的符号,则称之为未定义符号,这类引用必须在静态链接期间用其他目标模块或库解决,或在加载时通过动态链接解决。

$ readelf -s libwechatxlog.so
readelf -s

参考文献
ELF格式文件符号表全解析及readelf命令使用方法
objdump命令解析

上一篇下一篇

猜你喜欢

热点阅读