ELF文件格式浅析

liam@ubuntu:~/practice$ file hello
hello: ELF 32-bit MSB  executable, MIPS, MIPS32 rel2 version 1, dynamically linked (uses shared libs), for GNU/Linux 2.6.12, not stripped

ELF在linux下是一种可执行文件格式。

file命令得到的结果解析: hello, ELF 文件格式, 32位, 大端, mips32 ...

一、系统优势怎么解析ELF文件的格式的呢?

上图所示ELF文件的开始位置都有标致位的。

二、ELF文件格式组成:

使用readelf -a hello命令打印出的结果,基本包括了所有的信息了。

大概包括:

1、ELF header: ELF头文件的基本信息;

2、Section Header: 是一张表,用于描述segment section。

3、Program Headers: 就是真正拷贝到内存并运行的代码。

4 Symbol table:..

5 Primary GOT:...

6 PLT GOT:...

除了ELF header的头是固定格式以外,其他的部分不是必须有。格式位置也不一定是确定的。

三、常用ELF相关命令:


1 readelf -s hello 查看symbols;

2 readelf -d hello 查看依赖于那些库;

3 file hello

以上就是我常用的三个命令了。

 

posted @ 2015-04-30 23:24  JustRelax  阅读(580)  评论(0)    收藏  举报