//检查打开的文件是不是ELF格式的文件
//检验ELF头
//获得节头表的地址
//遍历节头表,依次查看一个节的属性,从节头字符串表中找到其名称,如果名称和“特别”的section名匹配,则找到此节的地址
//提取“特别”的节中的信息
//检验ELF头
//获得节头表的地址
//遍历节头表,依次查看一个节的属性,从节头字符串表中找到其名称,如果名称和“特别”的section名匹配,则找到此节的地址
//提取“特别”的节中的信息
//显示上面提取的信息
#include<stdio.h>
#include<elf.h>
#include<stdlib.h>
#include<string.h>
int main(int argc,char *argv[])
{
FILE *fp;
Elf64_Ehdr *ehdr;
Elf64_Shdr *shdr;
char buffer[1024]={0};
int i=0,j=0;
long length;
fp=fopen(argv[1],"rb");
if(fp==NULL)
{
printf("can not open %s\n",argv[1]);
return -1;
}
ehdr = (Elf64_Ehdr *)malloc(sizeof(Elf64_Ehdr));
shdr = (Elf64_Shdr *)malloc(sizeof(Elf64_Shdr));
fread(ehdr,sizeof(Elf64_Ehdr),1,fp);
if(ehdr->e_ident[EI_MAG0] == ELFMAG0