首页 > 其他 > 详细

动态链接库的ELF头分析

时间:2014-11-24 11:40:12      阅读:145      评论:0      收藏:0      [点我收藏+]

ELF(Executable and Linking Format)用于存储Linux程序。

ELF文件分三种类型: 1、目标文件(通常是.o); 2、可执行文件(我们的运行文件)   3、动态库(.so)

ELF头的各个字段:

typedef struct {
  unsigned char  e_ident[EI_NIDENT];  /* File identification. */
  Elf32_Half  e_type;    /* File type. */
  Elf32_Half  e_machine;  /* Machine architecture. */
  Elf32_Word  e_version;  /* ELF format version. */
  Elf32_Addr  e_entry;  /* Entry point. */
  Elf32_Off  e_phoff;  /* Program header file offset. */
  Elf32_Off  e_shoff;  /* Section header file offset. */
  Elf32_Word  e_flags;  /* Architecture-specific flags. */
  Elf32_Half  e_ehsize;  /* Size of ELF header in bytes. */
  Elf32_Half  e_phentsize;  /* Size of program header entry. */
  Elf32_Half  e_phnum;  /* Number of program header entries. */
  Elf32_Half  e_shentsize;  /* Size of section header entry. */
  Elf32_Half  e_shnum;  /* Number of section header entries. */
  Elf32_Half  e_shstrndx;  /* Section name strings section. */
} Elf32_Ehdr;

e_ident、e_type、e_machine、e_version、e_flags和e_ehsize字段比较固定;

e_entry 入口地址与文件类型有关(动态库就是0);

e_phoff、e_phentsize和e_phnum与装载视图有关;

e_shoff、e_shentsize、e_shnum和e_shstrndx与链接视图有关。

目前e_ehsize(ELF HEAD SIZE,32位系统上固定为52字节,也就是0x34;64位系统上是64字节) = 52字节;

e_shentsize = 40字节(固定的,也就是0x28);

e_phentsize = 32字节。

 

 

 

 

 

 

参考:

[1]http://blog.csdn.net/hhhbbb/article/details/6855004

[2]http://bbs.pediy.com/showthread.php?t=191649

动态链接库的ELF头分析

原文:http://www.cnblogs.com/larrylawrence/p/4118063.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!