Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ scnhdr(4) — sysv — mips UMIPS RISC/os 4.52

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fseek(3S)

a.out(4)

reloc(4)

SCNHDR(4-SysV)

ld(1)



SCNHDR(4-SysV)      RISC/os Reference Manual       SCNHDR(4-SysV)



NAME
     scnhdr - section header for a MIPS object file

SYNOPSIS
     #include < scnhdr.h>

DESCRIPTION
     Every MIPS object file has a table of section headers to
     specify the layout of the data within the file.  Each sec-
     tion within an object file has its own header.  The C struc-
     ture appears below:

     struct scnhdr
     {
             char            s_name[8];  /* 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;  /* file ptr to gp table */
             unsigned short  s_nreloc;   /* number of relocation entries */
             unsigned short  s_nlnno;    /* number of gp table entries */
             long            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.  Conse-
     quently, 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 used for line numbers on MIPS machines.
     See the header file sym.h for the entries to get to the line
     number table.  The entries that were for line numbers in the
     section header are used for gp tables on MIPS machines.

     The number of relocation entries for a section is found in
     the s_nreloc field of the section header.  This field being
     a `C' language short and can overflow with large objects.
     If this field overflows the section header s_flags field has
     the 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 R_ABS so it is ignored when the reloca-
     tion takes place.  This is a kluge.




                         Printed 1/15/91                   Page 1





SCNHDR(4-SysV)      RISC/os Reference Manual       SCNHDR(4-SysV)



     The gp table gives the section size corresponding to each
     applicable value of the compiler option -G num (always
     including 0), sorted by smallest size first. It is pointed
     to by the s_lnnoptr field in the section header and its
     number of entries (including the header) is in the s_nlnno
     field in the section header.  This table only needs to exist
     for the .sdata and .sbss sections.  If there is no ``small''
     section then the gp table for it is attached to the
     coresponding ``large'' section so the information still gets
     to the link editor, ld(1).  The C union for the gp table
     appears below.

     union gp_table
     {
             struct {
                     long    current_g_value;/* actual value */
                     long    unused;
             } header;
             struct {
                     long    g_value;        /* hypothetical value */
                     long    bytes;  /* section size corresponding to hypothetical value */
             } entry;
     };

     Each gp table has one header structure that contains the
     actual value of the -G num option used to produce the object
     file.  An entry must exist for every applicable value of the
     -G num option.  The applicable values are all the sizes of
     the data items in that section.

     For .lib sections the number of shared libraries is in the
     s_nlib field (an alias to s_paddr).  The .lib section is
     made up of s_nlib descriptions of shared libraries.  Each
     description of a shared library is a libscn structure fol-
     lowed by the path name to the shared library.  The C struc-
     ture appears below and is defined in scnhdr.h.

     struct libscn
     {
             long    size;           /* size of this entry (including target name) */
             long    offset;         /* offset from start of entry to target name */
             long    tsize;          /* text size in bytes, padded to DW boundary */
             long    dsize;          /* initialized data size */
             long    bsize;          /* uninitialized data */
             long    text_start;     /* base of text used for this library */
             long    data_start;     /* base of data used for this library */
             long    bss_start;      /* base of bss used for this library */
             /* pathname of target shared library */
     };

SEE ALSO
     fseek(3S), a.out(4), reloc(4).



 Page 2                  Printed 1/15/91





SCNHDR(4-SysV)      RISC/os Reference Manual       SCNHDR(4-SysV)



     ld(1) in the User's Reference Manual.






















































                         Printed 1/15/91                   Page 3



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026