hdr.c
Go to the documentation of this file.
00001 #include <fcntl.h>
00002 #include <filehdr.h>
00003 #include <aouthdr.h>
00004 #include <scnhdr.h>
00005 #include <sym.h>
00006 
00007 main(argc,argv)
00008 int argc;
00009 char *argv[];
00010 { int fd,i;
00011   struct filehdr hdr;
00012   struct aouthdr ahdr;
00013   struct scnhdr  shdr;
00014   HDRR symhdr;
00015   FDR fdr;
00016 
00017   fd=open(argv[1],O_RDONLY);
00018   if (fd<0) {printf("cannot open %s\n",argv[1]); exit(1);}
00019 
00020   read(fd, &hdr, sizeof(hdr));
00021   printf("filehdr\nmagic=0x%x nscns=%d timdat=0x%x symptr=0x%x\n",
00022         hdr.f_magic,hdr.f_nscns, hdr.f_timdat, hdr.f_symptr);
00023   printf("nsyms=%d opthdr=0x%x flags=0x%x\n\n",hdr.f_nsyms, hdr.f_opthdr,
00024         hdr.f_flags);
00025 
00026   read(fd, &ahdr, sizeof(ahdr));
00027   printf("aouthdr:\nmagic=0x%x vstamp=0x%x tsize=0x%x dsize=0x%x bsize=0x%x\n",
00028         ahdr.magic, ahdr.vstamp, ahdr.tsize, ahdr.dsize, ahdr.bsize);
00029   printf("entry=0x%x text_start=0x%x data_start=0x%x bss_start=0x%x\n",
00030         ahdr.entry, ahdr.text_start, ahdr.data_start, ahdr.bss_start);
00031 
00032   for (i=0; i<hdr.f_nscns; i++) {
00033     read(fd, &shdr, sizeof(shdr));
00034     printf("\nsection %d\nsname=%s paddr=0x%x vaddr=0x%x size=0x%x scnptr=0x%x\n",
00035         i,shdr.s_name, shdr.s_paddr, shdr.s_vaddr, shdr.s_size, shdr.s_scnptr);
00036     printf("relptr=0x%x lnnoptr=0x%x nreloc=0x%x nlnno=0x%x flags=0x%x\n",
00037         shdr.s_relptr, shdr.s_lnnoptr, shdr.s_nreloc, shdr.s_nlnno, shdr.s_flags);
00038     }
00039 
00040   lseek(fd, hdr.f_symptr,0);
00041   read(fd,&symhdr,sizeof(symhdr));
00042   printf("\nsymbolic header:\n");
00043   printf("magic=0x%x vstamp=0x%x ilinemax=%d cbLine=%d cbLineOffset=%d\n",
00044          symhdr.magic, symhdr.vstamp, symhdr.ilineMax, symhdr.cbLine,
00045          symhdr.cbLineOffset);
00046   printf("idnMax=0x%x cbDnOffset=0x%x ipdMax=%d cbPdOffset=%d\n",
00047          symhdr.idnMax, symhdr.cbDnOffset, symhdr.ipdMax, symhdr.cbPdOffset);
00048   printf("isymMax=0x%x cbSymOffset=0x%x ioptMax=%d cbOptOffset=%d\n",
00049          symhdr.isymMax, symhdr.cbSymOffset, symhdr.ioptMax, symhdr.cbOptOffset);
00050   printf("issExtMax=%d cbSsExtOffset=0x%x ifdMax=%d cbFdOffset=0x%x\n",
00051          symhdr.issExtMax, symhdr.cbSsExtOffset, symhdr.ifdMax, symhdr.cbFdOffset);
00052   printf("crfd=%d cbRfdOffset=0x%x iextMax=%d cbExtOffset=0x%x\n",
00053          symhdr.crfd, symhdr.cbRfdOffset, symhdr.iextMax, symhdr.cbExtOffset);
00054 
00055 
00056   printf("\nfile descriptor header\n");
00057   lseek(fd,symhdr.cbFdOffset,0);
00058   for (i=0; i<symhdr.ifdMax; i++) {
00059     read(fd, &fdr, sizeof(fdr));
00060     printf("%d adr=0x%x rss=0x%x ",i, fdr.adr, fdr.rss);
00061   printf("issBase=0x%x cbSs=0x%x isymBase=0x%x csym=0x%x\n",
00062                 fdr.issBase, fdr.cbSs, fdr.isymBase, fdr.csym); }
00063   }
00064 
00065 


euslisp
Author(s): Toshihiro Matsui
autogenerated on Thu Jun 6 2019 18:05:53