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