Every object file has a group of section headers to specify the layout of the data within the file. Each section within an object file has its own header. The C structure is as follows:
char s_name; /* section name */
long s_paddr; /* physical address, aliased s_nlib */
long s_vaddr; /* virtual address */
long s_size; /* section size */
long s_scnptr; /* file ptr to raw data for section */
long s_relptr; /* file ptr to relocation */
long s_lnnoptr; /* special purpose */
unsigned short s_nreloc; /* number of reloc entries */
unsigned short s_nlnno; /* unused */
int s_flags; /* flags */ };
File pointers are byte offsets into the file; they can be used as the offset in a call to FSEEK (see ldfcn(4)). If a section is initialized, the file contains the actual bytes. An uninitialized section is somewhat different. It has a size, symbols defined in it, and symbols that refer to it. But it can have no relocation entries or data. Consequently, an uninitialized section has no raw data in the object file, and the values for s_scnptr, s_relptr, and s_nreloc are zero.
The entries that refer to line numbers (s_lnnoptr, and s_nlnno) are not related to line number information. See the header file sym.h for the entries to get to the line number table. The entries that were for line numbers are reserved and should be set to zero.
The number of relocation entries for a section is found in the s_nreloc field of the section header. Being a `C' language short, this field can overflow with large objects. If this field overflows, the section header s_flags field has the SM S_NRELOC_OVFL bit set. In this case, the true number of relocation entries is found in the r_vaddr field of the first relocation entry for that section. That relocation entry has a type of SM R_ABS, so it is ignored when the relocation takes place.
ld(1), fseek(3), a.out(4), reloc(4). delim off