网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

用php读取elf结构的方法

这篇文章给大家分享的是有关用php读取elf结构的方法的内容。小编觉得挺实用的,因此分享给大家做个参考。一起跟随小编过来看看吧。

创新互联是一家专注于网站建设、成都网站建设与策划设计,点军网站建设哪家好?创新互联做网站,专注于网站建设十余年,网设计领域的专业建站公司;建站业务涵盖:点军等地区。点军做网站价格咨询:18982081108

前提知识
  1. UNIX系统的可执行文件都采用ELF格式,类型分为目标文件、可执行文件和共享库

  2. ELF格式探析之三:sections

  3. 本例基于64位的小端序linux机器

以读取目标文件hello.o为例
#include 
void say_hello(char *who) {
    printf("hello, %s!\n", who);
}
char *my_name = "wb";
int man() {
    say_hello(my_name);
    return 0;
}
// 执行gcc -c hello.c生成hello.o
目标文件elf结构主要有:
  1. ELF header,位于文件的0~64字节,存储文件的描述信息,Section header table的起始位置

  2. N个Section

  3. Section header table,每个条目64字节,对应一个Section的信息

  4. Program header table,可执行文件需要,本例的hello.o没有

进一步分析elf结构
  1. 首先用readelf命令读取elf信息:readelf -h hello.o。总结如下:

  2. ELF header占用64字节

  3. N个Section占用6488-64-1472=4952字节

  4. Section header table占用23*64=1472字节

readelf -h hello.o
ELF Header:
Class:                             ELF64
Data:                              2's complement, little endian
OS/ABI:                            UNIX - System V
Type:                              REL (Relocatable file)
Machine:                           Advanced Micro Devices X86-64
Start of program headers:          0 (bytes into file)
Start of section headers:          5016 (bytes into file) //Section header table的起始位置
Size of this header:               64 (bytes) //ELF header的占用大小
Size of program headers:           0 (bytes)  //hello.o没有program header table
Number of program headers:         0          //hello.o没有program header table
Size of section headers:           64 (bytes) //Section header table每个条目占用大小
Number of section headers:         23         //Section header table条目个数
Section header string table index: 22         //.shstrtab Section位于Section header table第22个条目
用php读取.shstrtab Section内容
  1. .shstrtab Section其实是存储的所有Section的名字

感谢各位的阅读!关于用php读取elf结构的方法就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到吧!


网页名称:用php读取elf结构的方法
文章起源:http://bjjierui.cn/article/gdohhi.html

其他资讯