1: 
   2: /*
   3:  *      Program Name:   nsym.c
   4:  *      Author:  S.M. Schultz
   5:  *
   6:  *      -----------   Modification History   ------------
   7:  *      Version Date            Reason For Modification
   8:  *      1.0     31Oct93         1. Initial release into the public domain.
   9:  *				   Calculating the offsets of the string
  10:  *				   and symbol tables in an executable is
  11:  *				   rather messy and verbose when dealing
  12:  *				   with overlaid objects.  The macros (in
  13:  *				   a.out.h) N_STROFF, N_SYMOFF, etc simply
  14:  *				   call these routines.
  15:  *      --------------------------------------------------
  16: */
  17: 
  18: #include <a.out.h>
  19: 
  20: off_t
  21: n_stroff(ep)
  22:     register struct xexec *ep;
  23:     {
  24:     off_t   l;
  25: 
  26:     l = n_symoff(ep);
  27:     l += ep->e.a_syms;
  28:     return(l);
  29:     }
  30: 
  31: off_t
  32: n_datoff(ep)
  33:     register struct xexec *ep;
  34:     {
  35:     off_t   l;
  36: 
  37:     l = n_treloc(ep);
  38:     l -= ep->e.a_data;
  39:     return(l);
  40:     }
  41: 
  42: /*
  43:  * Obviously if bit 0 of the flags word (a_flag) is not off then there's
  44:  * no relocation information present and this routine shouldn't have been
  45:  * called.
  46: */
  47: 
  48: off_t
  49: n_dreloc(ep)
  50:     register struct xexec *ep;
  51:     {
  52:     off_t   l;
  53:     register u_short *ov = ep->o.ov_siz;
  54:     register int    i;
  55: 
  56:     l = (off_t)sizeof (struct exec) + ep->e.a_text + ep->e.a_data;
  57:     if  (ep->e.a_magic == A_MAGIC5 || ep->e.a_magic == A_MAGIC6)
  58:         {
  59:         for (i = 0; i < NOVL; i++)
  60:             l += *ov++;
  61:         l += sizeof (struct ovlhdr);
  62:         }
  63:     l += ep->e.a_text;
  64:     return(l);
  65:     }
  66: 
  67: off_t
  68: n_treloc(ep)
  69:     register struct xexec *ep;
  70:     {
  71:     off_t   l;
  72: 
  73:     l = n_dreloc(ep);
  74:     l -= ep->e.a_text;
  75:     return(l);
  76:     }
  77: 
  78: off_t
  79: n_symoff(ep)
  80:     register struct xexec *ep;
  81:     {
  82:     register int    i;
  83:     register u_short *ov;
  84:     off_t   sum, l;
  85: 
  86:     l = (off_t) N_TXTOFF(ep->e);
  87:     sum = (off_t)ep->e.a_text + ep->e.a_data;
  88:     if  (ep->e.a_magic == A_MAGIC5 || ep->e.a_magic == A_MAGIC6)
  89:         {
  90:         for (ov = ep->o.ov_siz, i = 0; i < NOVL; i++)
  91:             sum += *ov++;
  92:         }
  93:     l += sum;
  94:     if  ((ep->e.a_flag & 1) == 0)   /* relocation present? */
  95:         l += sum;
  96:     return(l);
  97:     }

Defined functions

n_datoff defined in line 31; used 4 times
n_dreloc defined in line 48; used 5 times
n_stroff defined in line 20; used 4 times
n_symoff defined in line 78; used 5 times
n_treloc defined in line 67; used 5 times
Last modified: 1993-10-31
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3094
Valid CSS Valid XHTML 1.0 Strict