hdr.c
Go to the documentation of this file.
1 #include <fcntl.h>
2 #include <filehdr.h>
3 #include <aouthdr.h>
4 #include <scnhdr.h>
5 #include <sym.h>
6 
7 main(argc,argv)
8 int argc;
9 char *argv[];
10 { int fd,i;
11  struct filehdr hdr;
12  struct aouthdr ahdr;
13  struct scnhdr shdr;
14  HDRR symhdr;
15  FDR fdr;
16 
17  fd=open(argv[1],O_RDONLY);
18  if (fd<0) {printf("cannot open %s\n",argv[1]); exit(1);}
19 
20  read(fd, &hdr, sizeof(hdr));
21  printf("filehdr\nmagic=0x%x nscns=%d timdat=0x%x symptr=0x%x\n",
22  hdr.f_magic,hdr.f_nscns, hdr.f_timdat, hdr.f_symptr);
23  printf("nsyms=%d opthdr=0x%x flags=0x%x\n\n",hdr.f_nsyms, hdr.f_opthdr,
24  hdr.f_flags);
25 
26  read(fd, &ahdr, sizeof(ahdr));
27  printf("aouthdr:\nmagic=0x%x vstamp=0x%x tsize=0x%x dsize=0x%x bsize=0x%x\n",
28  ahdr.magic, ahdr.vstamp, ahdr.tsize, ahdr.dsize, ahdr.bsize);
29  printf("entry=0x%x text_start=0x%x data_start=0x%x bss_start=0x%x\n",
30  ahdr.entry, ahdr.text_start, ahdr.data_start, ahdr.bss_start);
31 
32  for (i=0; i<hdr.f_nscns; i++) {
33  read(fd, &shdr, sizeof(shdr));
34  printf("\nsection %d\nsname=%s paddr=0x%x vaddr=0x%x size=0x%x scnptr=0x%x\n",
35  i,shdr.s_name, shdr.s_paddr, shdr.s_vaddr, shdr.s_size, shdr.s_scnptr);
36  printf("relptr=0x%x lnnoptr=0x%x nreloc=0x%x nlnno=0x%x flags=0x%x\n",
37  shdr.s_relptr, shdr.s_lnnoptr, shdr.s_nreloc, shdr.s_nlnno, shdr.s_flags);
38  }
39 
40  lseek(fd, hdr.f_symptr,0);
41  read(fd,&symhdr,sizeof(symhdr));
42  printf("\nsymbolic header:\n");
43  printf("magic=0x%x vstamp=0x%x ilinemax=%d cbLine=%d cbLineOffset=%d\n",
44  symhdr.magic, symhdr.vstamp, symhdr.ilineMax, symhdr.cbLine,
45  symhdr.cbLineOffset);
46  printf("idnMax=0x%x cbDnOffset=0x%x ipdMax=%d cbPdOffset=%d\n",
47  symhdr.idnMax, symhdr.cbDnOffset, symhdr.ipdMax, symhdr.cbPdOffset);
48  printf("isymMax=0x%x cbSymOffset=0x%x ioptMax=%d cbOptOffset=%d\n",
49  symhdr.isymMax, symhdr.cbSymOffset, symhdr.ioptMax, symhdr.cbOptOffset);
50  printf("issExtMax=%d cbSsExtOffset=0x%x ifdMax=%d cbFdOffset=0x%x\n",
51  symhdr.issExtMax, symhdr.cbSsExtOffset, symhdr.ifdMax, symhdr.cbFdOffset);
52  printf("crfd=%d cbRfdOffset=0x%x iextMax=%d cbExtOffset=0x%x\n",
53  symhdr.crfd, symhdr.cbRfdOffset, symhdr.iextMax, symhdr.cbExtOffset);
54 
55 
56  printf("\nfile descriptor header\n");
57  lseek(fd,symhdr.cbFdOffset,0);
58  for (i=0; i<symhdr.ifdMax; i++) {
59  read(fd, &fdr, sizeof(fdr));
60  printf("%d adr=0x%x rss=0x%x ",i, fdr.adr, fdr.rss);
61  printf("issBase=0x%x cbSs=0x%x isymBase=0x%x csym=0x%x\n",
62  fdr.issBase, fdr.cbSs, fdr.isymBase, fdr.csym); }
63  }
64 
65 
main(int argc, argv)
Definition: hdr.c:7
static int argc
Definition: transargv.c:56


euslisp
Author(s): Toshihiro Matsui
autogenerated on Thu Jun 6 2019 20:00:44