【开发工具】【readelf】查看ELF格式文件工具(readelf)的使用

目录

readelf概述

readelf命令使用说明


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的版本信息 */

参考:

可以通过readelf工具对目标文件进行解析,学习目标文件的结构。

readelf命令使用说明


获取更多相关的嵌入式开发工具,可收藏系列博文,持续更新中:
【开发工具】嵌入式常用开发工具汇总帖

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Evan_ZGYF丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值