目录
readelf概述
readelf是Linux下的分析ELF文件的命令,这个命令在分析ELF文件格式时非常有用。常见的文件如在Linux上的可执行文件,动态库(*.so)或者静态库(*.a) 等包含ELF格式的文件。
Ps:什么是ELF文件?
系统里的目标文件是按照特定的目标文件格式来组织的,各个系统的目标文件格式都不相同。
从贝尔实验室诞生的第一个Unix系统使用的是a.out格式(直到今天,直到文件仍然称为a.out文件)。Windows使用可移植植入(PortableExecutable,PE)格式。MacOS- X使用Mach-O格式。现代x86-64Linux和Unix系统使用可调可链接格式(ELF)。
ELF格式的文件在Linux系统下有.axf,.bin,.elf,.o,.prx,.puff,.ko,.mod和.so等等
readelf命令使用说明
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
/* all 显示全部信息,等价于 -h -l -S -s -r -d -V -A -I。 */
-h --file-header Display the ELF file header
/* 显示elf文件开始的文件头信息。 */
-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
/* 显示节的详细信息(-S的) */
-e --headers Equivalent to: -h -l -S
/* 显示全部头信息,等价于: -h -l -S */
-s --syms Display the symbol table
--symbols An alias for --syms
--dyn-syms Display the dynamic symbol table
/* symbols 显示符号表段中的项(如果有数据的话) */
-n --notes Display the core notes (if present)
/* 显示note段(内核注释)的信息 */
-r --relocs Display the relocations (if present)
/* 显示可重定位段的信息 */
-u --unwind Display the unwind info (if present)
/* 显示unwind段信息。当前只支持IA64 ELF的unwind段信息 */
-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)
/* 显示CPU构架信息 */
-c --archive-index Display the symbol/file index in an archive
/* 显示符号的时候,显示bucket list长度的柱状图 */
-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
/* 以16进制方式显示指定段内内容。number指定段表中段的索引,或字符串指定文件中的段名 */
-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[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,
=addr,=cu_index]
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
/* 显示readelf所支持的命令行选项 */
-v --version Display the version number of readelf
/* 显示readelf的版本信息 */
参考:
获取更多相关的嵌入式开发工具,可收藏系列博文,持续更新中:
【开发工具】嵌入式常用开发工具汇总帖