69,382
社区成员
发帖
与我相关
我的任务
分享
//analysis the shstrtab offset in the file
ioffset = shdr[phead->e_shstrndx].sh_offset;
isize = shdr[phead->e_shstrndx].sh_size;
pshstr = (char*)malloc(sizeof(char)*isize);
//read the shstrtable from file
if( 0 != fseek(p,ioffset,SEEK_SET) )
{
printf("move the offset for shstrtab failed!\n");
}
iRet = fread(pshstr,isize,1,p);
if( 1 != iRet )
{
printf("read the shstrtab from file failed!\n");
}
printf("The Section of Elf file: %d\n",phead->e_shnum );
printf("Index Name size offset \n");
for( i = 1; i< phead->e_shnum ; ++i )
{
printf("%d ", i);
printf("%s ",pshstr+shdr[i].sh_name );//使用下标pshstr[shdr[i].sh_name]就会出现段错误
printf("%d ",shdr[i].sh_size);
printf("%d ",shdr[i].sh_offset);
printf("\n");
}