home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / wizards / 3847 < prev    next >
Encoding:
Text File  |  1992-09-08  |  1.7 KB  |  45 lines

  1. Newsgroups: comp.unix.wizards
  2. Path: sparky!uunet!cis.ohio-state.edu!news.sei.cmu.edu!fs7.ece.cmu.edu!crabapple.srv.cs.cmu.edu!dstewart
  3. From: dstewart+@cs.cmu.edu (David B Stewart)
  4. Subject: Question on COFF Format (Summary)
  5. Message-ID: <BuA46n.LFr.1@cs.cmu.edu>
  6. Sender: news@cs.cmu.edu (Usenet News System)
  7. Nntp-Posting-Host: ius4.ius.cs.cmu.edu
  8. Cc: dstewart
  9. Organization: The Robotics Institute, Carnegie Mellon University
  10. Date: Tue, 8 Sep 1992 21:39:53 GMT
  11. Lines: 32
  12.  
  13. In article <Bu2AJL.43K.1@cs.cmu.edu> I wrote:
  14. > I am writing a program which must read in an i860 COFF file.
  15. > Is there any way of knowing the size of the string table before
  16. > the table is read in?
  17.  
  18. Several responses said to get the file size (using fstat()) and
  19. subtract (symbol_table_offset + symbol_table_size) from it, and
  20. that is the size of the string table.  That is what I was doing,
  21. and I was looking for a better solution.  It turns out, the size
  22. of the string table IS stored in the file.  The first 4 bytes
  23. of the string table is the size of the table, in bytes.
  24.  
  25. Therefore I can do the following to dynamically allocate my string table
  26. using the following code segment (var declarations omitted):
  27.  
  28.     lseek(fd,fhdr->f_symptr+fhdr->f_nsyms*sizeof(struct syment),SEEK_SET);
  29.     read(fd,&size,4);
  30.     strtable = malloc(size)
  31.     *(int *)strtable = size;
  32.     read(fd,strtable+4,size);
  33.  
  34. Thanks for your responses.
  35.  
  36. ~dave
  37.  
  38. -------------------------------------------------------------------------------
  39. David B. Stewart  - email: <dstewart@cmu.edu>            The Robotics Institute
  40. snail mail:       - ECE Dept., Carnegie Mellon University, Pittsburgh, PA 15213
  41. Current Projects: - Chimera 3.0 Real-Time Operating System
  42.           - Reconfigurable Sensor-Based Control Systems
  43.