您的位置:首页 > 运维架构 > Linux

Linux readelf命令

2014-07-07 16:21 281 查看
readelf:显示ELF文件的相关信息,通过不同的参数可以指定显示的信息

ELF:Executable and Linkable Format,可执行连接格式。可以通过file命令来查看文件是否是ELF格式文件。

常用参数及说明:更多详细信息可以查考man readelf页面

-a:显示ELF文件里面的所有信息
-h:显示ELF文件里面的头文件信息
-l:显示ELF文件里面的程序头文件信息
-d:显示ELF文件里面的动态部分的信息

例子:

[root@rhel6164 ~]# readelf -h `which touch` #显示头文件信息
ELF Header:
Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class:                             ELF64
Data:                              2's complement, little endian
Version:                           1 (current)
OS/ABI:                            UNIX - System V
ABI Version:                       0
Type:                              EXEC (Executable file)
Machine:                           Advanced Micro Devices X86-64
Version:                           0x1
Entry point address:               0x401870
Start of program headers:          64 (bytes into file)
Start of section headers:          50672 (bytes into file)
Flags:                             0x0
Size of this header:               64 (bytes)
Size of program headers:           56 (bytes)
Number of program headers:         8
Size of section headers:           64 (bytes)
Number of section headers:         32
Section header string table index: 31


[root@rhel6164 ~]# readelf -l `which touch` #显示程序头文件信息

Elf file type is EXEC (Executable file)
Entry point 0x401870
There are 8 program headers, starting at offset 64

Program Headers:
Type           Offset             VirtAddr           PhysAddr
FileSiz            MemSiz              Flags  Align
PHDR           0x0000000000000040 0x0000000000400040 0x0000000000400040
0x00000000000001c0 0x00000000000001c0  R E    8
INTERP         0x0000000000000200 0x0000000000400200 0x0000000000400200
0x000000000000001c 0x000000000000001c  R      1
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
0x000000000000a484 0x000000000000a484  R E    200000
LOAD           0x000000000000a488 0x000000000060a488 0x000000000060a488
0x0000000000001728 0x0000000000001728  RW     200000
DYNAMIC        0x000000000000af48 0x000000000060af48 0x000000000060af48
0x00000000000001a0 0x00000000000001a0  RW     8
NOTE           0x000000000000021c 0x000000000040021c 0x000000000040021c
0x0000000000000044 0x0000000000000044  R      4
GNU_EH_FRAME   0x00000000000096c4 0x00000000004096c4 0x00000000004096c4
0x0000000000000284 0x0000000000000284  R      4
GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000  RW     8

Section to Segment mapping:
Segment Sections...
00
01     .interp
02     .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .gnu.liblist .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame
03     .ctors .dtors .jcr .data.rel.ro .dynamic .got .got.plt .data .bss .dynstr .gnu.conflict
04     .dynamic
05     .note.ABI-tag .note.gnu.build-id
06     .eh_frame_hdr
[root@rhel6164 ~]# readelf -d `which touch`#显示动态部分信息

Dynamic section at offset 0xaf48 contains 25 entries:
Tag        Type                         Name/Value
0x0000000000000001 (NEEDED)             Shared library: [librt.so.1]
0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
0x000000000000000c (INIT)               0x4014a0
0x000000000000000d (FINI)               0x407f18
0x000000006ffffef5 (GNU_HASH)           0x400260
0x0000000000000005 (STRTAB)             0x60b548
0x0000000000000006 (SYMTAB)             0x4002a0
0x000000000000000a (STRSZ)              823 (bytes)
0x000000000000000b (SYMENT)             24 (bytes)
0x0000000000000015 (DEBUG)              0x0
0x0000000000000003 (PLTGOT)             0x60b158
0x0000000000000002 (PLTRELSZ)           1392 (bytes)
0x0000000000000014 (PLTREL)             RELA
0x0000000000000017 (JMPREL)             0x400f30
0x0000000000000007 (RELA)               0x400df8
0x0000000000000008 (RELASZ)             312 (bytes)
0x0000000000000009 (RELAENT)            24 (bytes)
0x000000006ffffffe (VERNEED)            0x400d78
0x000000006fffffff (VERNEEDNUM)         2
0x000000006ffffff0 (VERSYM)             0x400ce0
0x000000006ffffef9 (GNU_LIBLIST)        0x4009a8
0x000000006ffffdf7 (GNU_LIBLISTSZ)      80 (bytes)
0x000000006ffffef8 (GNU_CONFLICT)       0x60b8b0
0x000000006ffffdf6 (GNU_CONFLICTSZ)     768 (bytes)
0x0000000000000000 (NULL)               0x0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: