22 if (elfd<=0) { fprintf(stderr,
"open error %d\n",
errno); exit(2);}
23 elf_version(EV_CURRENT);
24 elf=elf_begin(elfd, ELF_C_READ, 0);
25 printf(
"elf=%d\n", elf);
26 if (elf==0) printf(
"%s\n", elf_errmsg(elf_errno()));
27 ehdr=elf32_getehdr(elf);
28 printf(
"elfhdr=%x\n", ehdr);
30 for (i=0; i<16; i++) {
31 printf(
"%2x ", ehdr->e_ident[i]);}
32 printf(
"\ne_type= %d\n", ehdr->e_type);
33 printf(
"e_machine= %d\n", ehdr->e_machine);
34 printf(
"e_version= %d\n", ehdr->e_version);
35 printf(
"e_entry= 0x%x\n", ehdr->e_entry);
36 printf(
"e_phoff= 0x%x\n", ehdr->e_phoff);
37 printf(
"e_shoff= 0x%x\n", ehdr->e_shoff);
38 printf(
"e_flags= 0x%x\n", ehdr->e_flags);
39 printf(
"e_ehsize= 0x%x\n", ehdr->e_ehsize);
40 printf(
"e_phentsize= %d\n", ehdr->e_phentsize);
41 printf(
"e_phnum= %d\n", ehdr->e_phnum);
42 printf(
"e_shentsize= %d\n", ehdr->e_shentsize);
43 printf(
"e_shnum= %d\n", ehdr->e_shnum);
44 printf(
"e_shstrndx= %d\n", ehdr->e_shstrndx);
46 scn= elf_getscn(elf, ehdr->e_shstrndx);
47 printf(
"string section = %x\n", scn);
49 data=elf_getdata(scn, data);
54 if (*cp == 0) printf(
"\n");