cvs.delorie.com/djgpp/doc/coff/scnhdr.html   search  
COFF: Section Header

typedef struct {
  char           s_name[8];  /* section name                     */
  unsigned long  s_paddr;    /* physical address, aliased s_nlib */
  unsigned long  s_vaddr;    /* virtual address                  */
  unsigned long  s_size;     /* section size                     */
  unsigned long  s_scnptr;   /* file ptr to raw data for section */
  unsigned long  s_relptr;   /* file ptr to relocation           */
  unsigned long  s_lnnoptr;  /* file ptr to line numbers         */
  unsigned short s_nreloc;   /* number of relocation entries     */
  unsigned short s_nlnno;    /* number of line number entries    */
  unsigned long  s_flags;    /* flags                            */
} SCNHDR;

This structure always exists immediately following any optional header in the COFF file (or following the file header, if f_opthdr is zero). When reading this header, you should read SCNHSZ bytes, and not rely on sizeof(SCNHDR) to give the correct size. The number of section headers present is given in the f_nscns field of the file header.

s_name - section name
The name of the section. The section name will never be more than eight characters, but be careful to handle the case where it's exactly eight characters - there will be no trailing null in the file! For shorter names, there field is padded with null bytes.

s_paddr - physical address of section data
This is the address at which the section data should be loaded into memory. For linked executables, this is the absolute address within the program space. For unlinked objects, this address is relative to the object's address space (i.e. the first section is always at offset zero).

s_vaddr - virtual address of section data
Always the same value as s_paddr in DJGPP.

s_size - section data size
The number of bytes of data stored in the file for this section. You should always read this many bytes from the file, beginning s_scnptr bytes from the beginning of the object.

s_scnptr - section data pointer
This contains the file offset of the section data.

s_relptr - relocation data pointer
The file offset of the relocation entries for this section.

s_lnnoptr - line number table pointer
The file offset of the line number entries for this section.

s_nreloc - number of relocation entries
The number of relocation entries for this section. Beware files with more than 65535 entries; this field truncates the value with no other way to get the "real" value.

s_nlnno - number of line number entries
The number of line number entries for this section. Beware files with more than 65535 entries; this field truncates the value with no other way to get the "real" value.

s_flags - flag bits
These flags provide additional information for each section. Flags other than those set below may be set, but are of no use aside from what these three provide.

Bit
Symbol
Meaning
0x0020 STYP_TEXT If set, indicates that this section contains only executable code.
0x0040 STYP_DATA If set, indicates that this section contains only initialized data.
0x0080 STYP_BSS If set, indicates that this section defines uninitialized data, and has no data stored in the coff file for it.


  webmaster     delorie software   privacy  
  Copyright © 1996     Updated Oct 1996