Annotation of coherent/b/bin/ld386/data.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * General Loader-Binder
                      3:  *
                      4:  * Knows about FILE struct to the extent it is revealed in putc
                      5:  * if BREADBOX is non-zero
                      6:  *
                      7:  */
                      8: #include <stdio.h>
                      9: #ifdef GEMDOS
                     10: #include <stat.h>
                     11: #define DIRSIZ 14
                     12: typedef unsigned long fsize_t;
                     13: #else
                     14: #include <sys/stat.h>
                     15: #include <sys/dir.h>
                     16: #endif
                     17: #include <mtype.h>
                     18: #include <coff.h>
                     19: #include <arcoff.h>
                     20: 
                     21: #ifdef DEBUG
                     22: #define TRACE(x) printf("Trace %lx %s(%d)\n", x, __FILE__, __LINE__);
                     23: #define TRACES(x) printf("Trace %s %s(%d)\n", x, __FILE__, __LINE__);
                     24: #else
                     25: #define TRACE(x)
                     26: #define TRACES(x)
                     27: #endif
                     28: 
                     29: typedef        unsigned long   uaddr_t;        /* universal address type */
                     30: 
                     31: #define NLSEG  3
                     32: 
                     33: #define S_TEXT 0
                     34: #define S_DATA 1
                     35: #define S_BSSD 2
                     36: 
                     37: /*
                     38:  * Macro to test for symbol equality.
                     39:  */
                     40: #define        eq(s1,s2)       ( strcmp( s1, s2) == 0 )
                     41: 
                     42: /*
                     43:  * Segment descriptor
                     44:  */
                     45: typedef        struct seg_s {
                     46:        uaddr_t vbase;          /* virtual address base */
                     47:        fsize_t daddr,          /* seek addr of segment */
                     48:                size;           /* size */
                     49:        long    relptr;         /* seek addr of rel records */
                     50:        long    nreloc;         /* number of relocation records */
                     51: } seg_t;
                     52: 
                     53: /*
                     54:  * Symbol descriptor
                     55:  */
                     56: typedef        struct  sym_t   {
                     57:        struct  sym_t   *next;  /* chained together */
                     58:        struct  mod_t   *mod;   /* pass 1; defining module */
                     59:        unsigned int    symno;  /* pass 2; symbol number */
                     60:        char    sclass;         /* storage class */
                     61:        char    scnum;          /* section number */
                     62:        long    value;          /* value of symbol */
                     63:        char    name[1];        /* symbol id */
                     64: } sym_t;
                     65: 
                     66: /*
                     67:  * Descriptor for each input module
                     68:  */
                     69: typedef        struct  mod_t   {
                     70:        struct  mod_t   *next;  /* chained together */
                     71:        char    *fname;         /* file containing module */
                     72:        char    mname[DIRSIZ];  /* module name if in archive */
                     73:        seg_t   seg[NLSEG];     /* descriptor for each segment */
                     74:        uaddr_t symptr;         /* location of symbol table */
                     75:        unsigned int    nsym;   /* #symbols for this module */
                     76:        sym_t   *sym[];         /* array of nsym symbol ptrs */
                     77: } mod_t;
                     78: 
                     79: /*
                     80:  * Command line flag option
                     81:  */
                     82: typedef        char    flag_t;
                     83: 
                     84: /*
                     85:  * Structures built in pass 1, used in pass 2
                     86:  */
                     87: #define        NHASH   64
                     88: 
                     89: /*
                     90:  * Seconds between ranlib update and archive modify times
                     91:  */
                     92: #define        SLOPTIME 150
                     93: 
                     94: /*
                     95:  * Values for worder
                     96:  */
                     97: #define        LOHI    0
                     98: #define        HILO    1
                     99: 
                    100: /*
                    101:  * For pass 2; these will change if format of relocation changed
                    102:  */
                    103: #define        getaddr getlohi
                    104: #define        putaddr(addr, fp, sgp)  putlohi((short)(addr), fp, sgp)
                    105: #define        getsymno getlohi
                    106: #define        putsymno putlohi
                    107: 
                    108: /*
                    109:  * C requires this...
                    110:  */
                    111: void   setbase(), endbind(), undef();
                    112: uaddr_t        newpage(), lentry();
                    113: fsize_t        segoffs(), baseall();
                    114: void   symredef(), rdsystem();
                    115: sym_t  *addsym(), *symref(), *newsym();
                    116: fsize_t        symoff();
                    117: void   loadmod();
                    118: unsigned short getword(), getlohi(), gethilo(), hash();
                    119: void   message(), fatal(), usage(), filemsg(), modmsg(), mpmsg(), spmsg();
                    120: void   mpfatal();
                    121: void   putlong();
                    122: unsigned long getlong();
                    123: 
                    124: /*
                    125:  * Start variables & constants
                    126:  */
                    127: 
                    128: extern sym_t * symtable[NHASH];        /* hashed symbol table */
                    129: extern mod_t * modhead, *modtail;      /* module list head and tail */
                    130: extern sym_t * etext_s,*edata_s,*end_s;/* special loader generated symbols */
                    131: extern char    etext_id[SYMNMLEN],     /* and their names */
                    132:                edata_id[SYMNMLEN],     
                    133:                end_id[SYMNMLEN];
                    134: 
                    135: extern FILEHDR fileh;                  /* output load file headers */
                    136: extern AOUTHDR aouth;
                    137: extern SCNHDR secth[NLSEG];
                    138: 
                    139: extern char    *mchname[];             /* names of known machines */
                    140: extern uaddr_t segsize[],              /* size of segment on target machine */
                    141:                drvbase[],              /* base of loadable driver */
                    142:                drvtop[];               /* address limit of loadable driver */
                    143: 
                    144: extern flag_t  noilcl,                 /* discard internal symbols `L...' */
                    145:                nolcl,                  /* discard local symbols */
                    146:                watch,                  /* watch everything happen */
                    147:                worder,                 /* byte order in word; depends on machine */
                    148:                comflag,                /* don't flag coff of diff size */
                    149:                reloc,                  /* write reloc symbols */
                    150:                dcomm;                  /* define commons even if reloc out */
                    151: 
                    152: extern  int    errCount;               /* Errors detected here */      
                    153: /*
                    154:  * Structures associated with storage economy
                    155:  */
                    156: extern mod_t   *mtemp;                 /* only one module in core at a time */
                    157: extern FILE    *mfp;                   /* temp file for module structures */
                    158: extern int     mdisk,                  /* flag <>0 means module struct to disk */
                    159:                nmod,                   /* module count */
                    160:                mxmsym;                 /* max # of symbols ref'd by 1 module */
                    161: 
                    162: extern mod_t   *modhead, *modtail;     /* module list head and tail */
                    163: extern seg_t   oseg[NLSEG];            /* output segment descriptors */
                    164: extern int     nundef;                 /* number of undefined symbols */
                    165: extern uaddr_t comnb;                  /* byte aligned commons */
                    166: extern uaddr_t comns;                  /* short aligned commons */
                    167: extern uaddr_t comnl;                  /* long aligned commons */
                    168: 
                    169: extern char    *outbuf;                /* buffer for in-memory load */
                    170: extern FILE    *outputf[NLSEG];        /* output ptrs (for each segment) */
                    171: extern FILE    *outputr[NLSEG];        /* reloc output ptrs (for each segment) */
                    172: 
                    173: extern char    *alloc();               /* malloc or die */
                    174: /*
                    175:  *     Kludge for maximum size of a loadable data segment
                    176:  *     for the 8086, used in both fixstack and ld
                    177:  */
                    178: 
                    179: #define        MAXSEG86        0x10000L        /* Maximum Segment Size         */
                    180: #define        DEFSTACK        0x1000          /* Initial Stack Size by Kernel */
                    181: #define        WARNSIZE        0x1000          /* Warning Tolerance Distance   */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.