1、概述
readelf 命令,一般用于查看 ELF 格式的文件信息,常见的文件如在Linux上的可执行文件,动态库(*.so)或者静态库(*.a) 等包含ELF格式的文件。
可以在 windows 命令行或 Git bash 上查看。
2、readelf 常用命令
语法:readelf (选项)(参数:文件),除了-v和-H之外,其它的选项必须有一个被指定参数。
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
-w[lLiaprmfFsoRt] 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]
Display the contents of DWARF2 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
1)选项 -h(elf header),显示elf文件开始的文件头信息;
2)选项 -l(program headers),segments 显示程序头(段头)信息;
3)选项 -S(section headers),sections 显示节头信息;
4)选项 -g(section groups),显示节组信息;
5)选项 -t,section-details 显示节的详细信息(-S的);
6)选项 -s,symbols 显示符号表段中的项;
7)选项 -e,headers 显示全部头信息,等价于: -h -l -S;
8)选项 -n,notes 显示note段(内核注释)的信息;
9)选项 -r,relocs 显示可重定位段的信息;
10)选项 -u,unwind 显示unwind段信息。当前只支持IA64 ELF的unwind段信息;
11)选项 -d,dynamic 显示动态段的信息;
12)选项 -V,version-info 显示版本段的信息;
13)选项 -A,arch-specific 显示CPU构架信息;
14)选项 -I,histogram 显示符号的时候,显示bucket list长度的柱状图;
15)选项 -x,hex-dump=<number or name> 以16进制方式显示指定段内内容,number指定段表中段的索引,或字符串指定文件中的段名;
16)选项 -D,use-dynamic 使用动态段中的符号表显示符号,而不是使用符号段 ;
17)选项 -a,all 显示全部信息,等价于 -h -l -S -s -r -d -V -A -I;
18)选项 -v,version 显示readelf的版本信息;
19)选项 -H,help 显示readelf所支持的命令行选项。
refer:
https://blog.csdn.net/yfldyxl/article/details/81566279