linux far命令,linux中readelf 命令列出模块中所有段

PC操作系统:ubuntu 11.10

使用的开发板:am335x_evm

开发板使用的操作系统:linux 3.2

readelf用来显示ELF格式目标文件的信息.可通过参数选项来控制显示哪些特定信息。

(注意: readelf不支持显示archive文档, 也不支持64位的ELF文件)。

readelf [-a|--all] [-h|--file-header] [-l|--program-headers|--segments]

[-S|--section-headers|--sections] [-g|--section-groups]

[-t|--section-details] [-e|--headers] [-s|--syms|--symbols]

[--dyn-syms] [-n|--notes] [-r|--relocs] [-u|--unwind]

[-d|--dynamic] [-V|--version-info] [-A|--arch-specific]

[-D|--use-dynamic] [-x |--hex-dump=] [-p |--string-dump=] [-R |--relocated-dump=] [-c|--archive-index]

[-w[lLiaprmfFsoRt]| --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index]]

[--dwarf-depth=n] [--dwarf-start=n] [-I|--histogram] [-v|--version]

[-W|--wide] [-H|--help] elffile...

readelf displays information about one or more ELF format object files. The options control what particular information to display.

elffile... are the object files to be examined. 32-bit and 64-bit ELF files are supported, as are archives containing ELF files.

This program performs a similar function to objdump but it goes into more detail and it exists independently of the bfd library, so if there is a bug in bfd then readelf will not be affected.

The long and short forms of options, shown here as alternatives, are equivalent. At least one option besides `-v' or `-H' must be given.

-a

--all

Equivalent to specifying --file-header, --program-headers, --sections, --symbols, --relocs, --dynamic, --notes and --version-info.

-h

--file-header

Displays the information contained in the ELF header at the start of the file.

-l

--program-headers

--segments

Displays the information contained in the file's segment headers, if it has any.

-S

--sections

--section-headers

Displays the information contained in the file's section headers, if it has any.

-g

--section-groups

Displays the information contained in the file's section groups, if it has any.

-t

--section-details

Displays the detailed section information. Implies -S.

-s

--symbols

--syms

Displays the entries in symbol table section of the file, if it has one.

--dyn-syms

Displays the entries in dynamic symbol table section of the file, if it has one.

-e

--headers

Display all the headers in the file. Equivalent to -h -l -S.

-n

--notes

Displays the contents of the NOTE segments and/or sections, if any.

-r

--relocs

Displays the contents of the file's relocation section, if it has one.

-u

--unwind

Displays

the contents of the file's unwind section, if it has one. Only the

unwind sections for IA64 ELF files, as well as ARM unwind tables (.ARM.exidx / .ARM.extab) are currently supported.

-d

--dynamic

Displays the contents of the file's dynamic section, if it has one.

-V

--version-info

Displays the contents of the version sections in the file, it they exist.

-A

--arch-specific

Displays architecture-specific information in the file, if there is any.

-D

--use-dynamic

When displaying symbols, this option makes readelf use the symbol hash tables in the file's dynamic section, rather than the symbol table sections.

-x

--hex-dump=

Displays

the contents of the indicated section as a hexadecimal bytes. A number

identifies a particular section by index in the section table; any other

string identifies all sections with that name in the object file.

-R

--relocated-dump=

Displays

the contents of the indicated section as a hexadecimal bytes. A number

identifies a particular section by index in the section table; any other

string identifies all sections with that name in the object file. The

contents of the section will be

relocated before they are displayed.

-p

--string-dump=

Displays

the contents of the indicated section as printable strings. A number

identifies a particular section by index in the section table; any other

string identifies all sections with that name in the object file.

-c

--archive-index

Displays the file symbol index infomation contained in the header part of binary archives. Performs the same function as the t command to ar, but without using the BFD library. See .

-w[lLiaprmfFsoRt]

--debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index]

Displays the contents of the debug sections in the file, if any

are present. If one of the optional letters or words follows the switch

then only data found in those specific sections will be dumped.

Note that there is no single letter option to display the content of trace sections or .gdb_index.

Note: the =decodedline option will display the interpreted contents of a .debug_line section whereas the =rawline option dumps the contents in a raw format.

Note: the =frames-interp option will display the interpreted contents of a .debug_frame section whereas the =frames option dumps the contents in a raw format.

Note: the output from the =info option can also be affected by the options --dwarf-depth and --dwarf-start.

--dwarf-depth=n

Limit the dump of the .debug_info section to n children. This is only useful with --debug-dump=info. The default is to print all DIEs; the special value 0 for n will also have this effect.

With a non-zero value for n, DIEs at or deeper than n levels will not be printed. The range for n is zero-based.

--dwarf-start=n

Print only DIEs beginning with the DIE numbered n. This is only useful with --debug-dump=info.

If specified, this option will suppress printing of any header information and all DIEs before the DIE numbered n. Only siblings and children of the specified DIE will be printed.

This can be used in conjunction with --dwarf-depth.

-I

--histogram

Display a histogram of bucket list lengths when displaying the contents of the symbol tables.

-v

--version

Display the version number of readelf.

-W

--wide

Don't break output lines to fit into 80 columns. By default readelf breaks section header and segment listing lines for 64-bit ELF files, so that they fit into 80 columns. This option causes readelf to print each section

header resp. each segment one a single line, which is far more readable

on terminals wider than 80 columns.

-H

--help

Display the command line options understood by readelf.

aecbe48995e2c803a96d1b48a2bcdbe0.png

add95d4319191027bef1d7a2e6aaae25.png

linux模块使用 ELF 二进制格式,模块中包含了几个额外的段,普通的程序或库中不会出现。模块由以下 ELF 段组成:

@1@ __ksymtab,__ksymtab_gpl 和 __ksymtab_gpl_future 段包含一个符号表,包括了模块导出的所有符号。

__ksymtab 段中导出的符号可以由内核的所有部分所用(不考虑许可证);

__ksymtab_gpl 中的符号只能由 GPL 兼容的部分使用;

__ksymtab_gpl_future 中的符号未来只能由GPL兼容的部分使用。

@2@ __kcrctab,__kcrctab_gpl 和 __kcrctab_gpl_future 包含模块所有导出函数的校验和。

__versions 包含该模块使用的,来自于外部源代码的所有引用的校验和。

@3@ __param 存储了模块可接受的参数有个信息

@4@ __ex_table 用于为内核异常表定义新项,前提是模块代码需要使用该机制。

@5@ .modinfo 存储了在加载当前模块之前,内核必须先行加载的所有其他模块名称。也就是说,该特定模块依赖的所有模块名称。

此外,每个模块都可以保存一些特定的信息,可以使用用户空间工具 modinfo 查询,特别是开发者的名字,模块描述,

许可证信息,参数列表等。

@6@ .exit.text 包含了在该模块从内核移除时,所需使用的代码(和可能的数据)。

该信息并未保存在普通的代码段中,这样,如果内核配置中未启用移除模块的选项,就不必将该段载入内存中。

@7@ .init.text 段包含了 初始化函数(和数据)。

之所以使用一个独立的段,是因为初始化完成后,相关的代码和数据就不再需要,因而可以从内存中移除。

@8@ .gnu.linkonce.this_module 提供了 struct module 的一个实例。

其中保存了模块的名称(name)和指向二进制文件中的初始化函数和清理函数(init 和 exit)的指针。

根据该段,内核即可判断特定的二进制文件是否为模块。

如果没有该段,则拒绝装载文件。

在模块自身和所依赖的所有其他内核模块都已经编译完成之前,上述的一些段是无法生成的,例如列出模块所有依赖关系的段。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值