mirror of
https://github.com/SEPPDROID/Digital-Research-Source-Code.git
synced 2025-10-24 17:04:19 +00:00
Upload
Digital Research
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
mkver -e "lo68 - "
|
||||
c68 -L -r -n main.c symt.c version.c -l6 -o lo68.4k
|
||||
setstack lo68.4k 8000 8000
|
||||
221
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v103/lo68/lo68.h
Normal file
221
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v103/lo68/lo68.h
Normal file
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
Copyright 1983
|
||||
Alcyon Corporation
|
||||
8716 Production Ave.
|
||||
San Diego, Ca. 92121
|
||||
*/
|
||||
|
||||
#ifdef DRI
|
||||
# include <stdio.h>
|
||||
# include <klib.h>
|
||||
#endif
|
||||
|
||||
#ifdef MC68000
|
||||
# include <cout.h>
|
||||
# include <ar68.h>
|
||||
# include <stat.h>
|
||||
struct BYTESTR {
|
||||
char hibyte;
|
||||
char lobyte;
|
||||
};
|
||||
struct WORDSTR {
|
||||
int hiword;
|
||||
int loword;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef VAX11
|
||||
# include <c68/cout.h>
|
||||
# include <c68/ar68.h>
|
||||
# include <c68/stat.h>
|
||||
/* as a result of adding the sysinfo call, and removing defined MMU */
|
||||
# define sysinfo(i,j) mmuflag = 1
|
||||
# define fflush v6fflush
|
||||
#endif
|
||||
|
||||
#ifdef PDP11
|
||||
# include <c68/cout.h>
|
||||
# include <c68/ar68.h>
|
||||
# include <c68/stat.h>
|
||||
/* as a result of adding the sysinfo call, and removing defined MMU */
|
||||
# define sysinfo(i,j) mmuflag = 1
|
||||
# define fflush v6fflush
|
||||
#endif
|
||||
|
||||
#ifdef VAX11
|
||||
struct WORDSTR {
|
||||
short loword;
|
||||
short hiword;
|
||||
};
|
||||
struct BYTESTR {
|
||||
char lobyte;
|
||||
char hibyte;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef PDP11
|
||||
struct BYTESTR {
|
||||
char lobyte;
|
||||
char hibyte;
|
||||
};
|
||||
struct WORDSTR {
|
||||
int hiword;
|
||||
int loword;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* format of a symbol entry in the main table*/
|
||||
|
||||
#define SEEKREL 1 /*relative seek flag*/
|
||||
#define SYNAMLEN 8
|
||||
|
||||
struct symtab {
|
||||
char name[SYNAMLEN]; /*symbol name*/
|
||||
#ifndef VAX11
|
||||
int flags; /*bit flags*/
|
||||
#else
|
||||
short flags;
|
||||
#endif
|
||||
long vl1; /*symbol value*/
|
||||
char *tlnk; /*table link*/
|
||||
};
|
||||
|
||||
char *lmte; /*last entry in main table*/
|
||||
char *bmte; /*beginning of main table*/
|
||||
char *emte; /*end of main table*/
|
||||
|
||||
/*symbol table entry size -- must be sizeof for sbrk*/
|
||||
#define SYTESIZE (sizeof *symptr)
|
||||
struct symtab *symptr;
|
||||
/*symbol table entry length on object file without tlnk*/
|
||||
#ifndef VAX11
|
||||
# define OSTSIZE (SYTESIZE - sizeof symptr->tlnk)
|
||||
#else
|
||||
# define OSTSIZE 14
|
||||
#endif
|
||||
|
||||
/* flags for symbols*/
|
||||
#define SYDF 0100000 /*defined*/
|
||||
#define SYEQ 0040000 /*equated*/
|
||||
#define SYGL 0020000 /*global - entry or external*/
|
||||
#define SYER 0010000 /*equated register*/
|
||||
#define SYXR 0004000 /*external reference*/
|
||||
#define SYDA 0002000 /*DATA based relocatable*/
|
||||
#define SYTX 0001000 /*TEXT based relocatable*/
|
||||
#define SYBS 0000400 /*BSS based relocatable*/
|
||||
#define SYFN 0000200 /* ?.o file name */
|
||||
|
||||
|
||||
struct irts {
|
||||
char *irle; /*ptr to last entry in chain*/
|
||||
char *irfe; /*ptr to first entry in chain*/
|
||||
};
|
||||
|
||||
/* parameters that define the main table*/
|
||||
#define SZMT 300 /*initial size of the main table*/
|
||||
/*must be large enough to initialize*/
|
||||
#define ICRSZMT 100 /*add to main table when run out*/
|
||||
int cszmt; /*current size of main table*/
|
||||
|
||||
/*initial reference table for externals*/
|
||||
#define SZIRT 64
|
||||
char *eirt[SZIRT];
|
||||
char *saveirt[SZIRT];
|
||||
|
||||
/*initial reference table for globals*/
|
||||
char *girt[SZIRT];
|
||||
char *savgirt[SZIRT];
|
||||
|
||||
char **pirt;
|
||||
char *savlmte;
|
||||
|
||||
#define AREGLO 8
|
||||
#define AREGHI 15
|
||||
|
||||
/* relocation bit definitions:*/
|
||||
#define RBMASK 07 /*tells type of relocation*/
|
||||
#define INSABS 7 /*first word of instr -- absolute*/
|
||||
#define DABS 0 /*data word absolute*/
|
||||
#define TRELOC 2 /* TEXT relocatable*/
|
||||
#define DRELOC 1 /* DATA relocatable*/
|
||||
#define BRELOC 3 /* BSS relocatable*/
|
||||
#define EXTVAR 4 /* ref to external variable*/
|
||||
#define LUPPER 5 /* upper word of long*/
|
||||
#define EXTREL 6 /* relative mode on external variable*/
|
||||
|
||||
#define BSIZE 512
|
||||
|
||||
struct iob{
|
||||
int fd;
|
||||
int cc;
|
||||
char *cp;
|
||||
char cbuf[BSIZE];
|
||||
}ibuf, tbuf, obuf, rbuf, rtbuf, rdbuf;
|
||||
|
||||
int sflag; /*remove symbol table*/
|
||||
|
||||
long textbase;
|
||||
long database;
|
||||
long bssbase;
|
||||
long textsize;
|
||||
long datasize;
|
||||
long bsssize;
|
||||
long stacksize;
|
||||
|
||||
long textstart;
|
||||
long datastart;
|
||||
long bssstart;
|
||||
|
||||
char *ifilname; /*points to name of current input file*/
|
||||
|
||||
#define NFILE 256 /*max # files we can process*/
|
||||
char *fsymp[NFILE]; /*points to first symbol for each .o file*/
|
||||
char **firstsym; /*points to entry in fsymp*/
|
||||
|
||||
int extmatch; /*matched an external in a library entry*/
|
||||
int noload; /*dont load this lib file flag*/
|
||||
|
||||
#define NLIB 16 /*max # libraries to process*/
|
||||
int lbfictr[NLIB]; /*counts files loaded from one library*/
|
||||
int *libfctr; /*points to lbfictr*/
|
||||
long lbfioff[NFILE]; /*each file offset in library*/
|
||||
long *libptr; /*points to lbfioff*/
|
||||
struct libhdr libhd; /* 15 apr 83, used to be int[13] */
|
||||
struct hdr couthd; /* [vlh] 4.1 declared */
|
||||
|
||||
int undflg;
|
||||
char dafnc;
|
||||
int pass2;
|
||||
long stlen;
|
||||
int Xflag, Dflag, Bflag, Zflag;
|
||||
|
||||
struct symtab *etextptr;
|
||||
struct symtab *edataptr;
|
||||
struct symtab *endptr;
|
||||
char *lastdup;
|
||||
|
||||
char rtfnc;
|
||||
char rdfnc;
|
||||
int saverbits;
|
||||
int shortlflg;
|
||||
|
||||
#define TWOKSHT -1 /* 2k shared text */
|
||||
#define FOURKSHT 1 /* 4k shared text */
|
||||
|
||||
#define DEFSHTEXT FOURKSHT
|
||||
|
||||
#define SH2BOUND 2048 /*shared text memory boundary*/
|
||||
#define SHBOUND 4096
|
||||
int shtext; /*shared text if set*/
|
||||
int isplit; /*i&d split if set*/
|
||||
|
||||
|
||||
/*** Predeclared Functions ***/
|
||||
char *lemt();
|
||||
char *nextsy();
|
||||
int endit();
|
||||
long lgetnum();
|
||||
char *sbrk();
|
||||
long extval();
|
||||
char *mktemp();
|
||||
long lseek();
|
||||
1029
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v103/lo68/main.c
Normal file
1029
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v103/lo68/main.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
CC = cc
|
||||
C68 = c68
|
||||
SOURCES = main.c symt.c version.c
|
||||
OBJS = main.o symt.o version.o
|
||||
CFLAGS = -n -O -DVAX11 -w
|
||||
C68FLAGS = -n -L -r -DMC68000
|
||||
LIB = -lV6
|
||||
LIB68 = -l6
|
||||
|
||||
vax:
|
||||
@mkver -e "lo68 -"
|
||||
${CC} ${CFLAGS} ${SOURCES} -o lo68.vax ${LIB}
|
||||
|
||||
lo68:
|
||||
@mkver -e "lo68 -"
|
||||
${C68} ${C68FLAGS} ${SOURCES} -o lo68.4k ${LIB68}
|
||||
@setstack lo68.4k 8000 8000; size lo68.4k
|
||||
|
||||
all: vax lo68
|
||||
@@ -0,0 +1,9 @@
|
||||
CC = c68
|
||||
OBJS = main.o symt.o
|
||||
CFLAGS = -L -r -DMC68000
|
||||
LIB68 = -l6
|
||||
|
||||
lo68: $(OBJS)
|
||||
@mkver -e "lo68 -"
|
||||
${CC} ${CFLAGS} -n ${OBJS} version.c -o lo68.4k ${LIB68}
|
||||
@setstack lo68.4k 8000 8000; size lo68.2k
|
||||
513
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v103/lo68/symt.c
Normal file
513
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v103/lo68/symt.c
Normal file
@@ -0,0 +1,513 @@
|
||||
/*
|
||||
Copyright 1982
|
||||
Alcyon Corporation
|
||||
8716 Production Ave.
|
||||
San Diego, Ca. 92121
|
||||
*/
|
||||
|
||||
#include "lo68.h"
|
||||
|
||||
char tfilname[];
|
||||
char etexstr[];
|
||||
char edatstr[];
|
||||
char eendstr[];
|
||||
int debug;
|
||||
int exstat;
|
||||
|
||||
/* get one symbol entry from the input file and put it into*/
|
||||
/* the symbol table entry pointed to by lmte*/
|
||||
getsym() /* rewritten for vax */
|
||||
{
|
||||
register int i;
|
||||
long lvalue;
|
||||
char *p;
|
||||
short wvalue;
|
||||
|
||||
p = lmte;
|
||||
for(i=SYNAMLEN; --i != -1; ) /* 2 may 83 */
|
||||
*p++ = getc(&ibuf); /* get name */
|
||||
if (lgetw(&wvalue, &ibuf) == -1)
|
||||
printf(": error reading symbol table entry\n");
|
||||
if (lgetl(&lvalue ,&ibuf) == -1)
|
||||
printf(": error reading symbol table entry\n"); /* symbol value */
|
||||
((struct symtab *)lmte)->flags = wvalue;
|
||||
((struct symtab *)lmte)->vl1 = lvalue;
|
||||
#ifdef DEBUG
|
||||
printf("\tname= %s, flags= %o, val= %d\n", ((struct symtab *)lmte)->name,
|
||||
((struct symtab *)lmte)->flags, ((struct symtab *)lmte)->vl1);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* relocate the symbol value pointed to by lmte according to*/
|
||||
/* symbol type and corresponding relocation base*/
|
||||
relocsym()
|
||||
{
|
||||
long l;
|
||||
|
||||
if(((struct symtab *)lmte)->flags&SYXR) /*external*/
|
||||
return;
|
||||
if(((struct symtab *)lmte)->flags&SYTX)
|
||||
l = textbase;
|
||||
else if(((struct symtab *)lmte)->flags&SYDA)
|
||||
l = database;
|
||||
else if(((struct symtab *)lmte)->flags&SYBS)
|
||||
l = bssbase;
|
||||
else if(((struct symtab *)lmte)->flags&SYEQ) /*equated*/
|
||||
return; /* abs*/
|
||||
else {
|
||||
printf(": name = %s -- Invalid symbol",((struct symtab *)lmte)->name);
|
||||
printf(" flags: %o\n",(int)((struct symtab *)lmte)->flags);
|
||||
endit(-1);
|
||||
}
|
||||
((struct symtab *)lmte)->vl1 += l;
|
||||
}
|
||||
|
||||
#define ADDSYM "addsym: file=%s symbol=%s flags=%o\n"
|
||||
/*
|
||||
* add a symbol to the symbol table
|
||||
* if symbol is an external, put it on eirt even if it does
|
||||
* already exist
|
||||
* if symbol is a global, put it on girt and error if it exists
|
||||
* in any case, add it to the end of the symbol table
|
||||
* if libflg is set, we are searching a library. In this case, when
|
||||
* a global is encountered, search the external symbols and set
|
||||
* extmatch if a match is found.
|
||||
*/
|
||||
addsym(libflg)
|
||||
{
|
||||
register char *p;
|
||||
|
||||
if(debug)
|
||||
printf(ADDSYM,ifilname,lmte,(int)((struct symtab *)lmte)->flags);
|
||||
|
||||
if(((struct symtab *)lmte)->flags&SYXR) { /*external*/
|
||||
p = lemt(eirt);
|
||||
mmte();
|
||||
}
|
||||
else if(((struct symtab *)lmte)->flags&SYGL) { /*global*/
|
||||
if(libflg) { /*global in a library*/
|
||||
p = lemt(eirt); /*look up in externals*/
|
||||
if(p != lmte) { /*found a match*/
|
||||
extmatch++;
|
||||
}
|
||||
}
|
||||
p = lemt(girt);
|
||||
if(p == lmte)
|
||||
mmte();
|
||||
else if(((struct symtab *)p)->flags!=((struct symtab *)lmte)->flags ||
|
||||
((struct symtab *)p)->vl1 != ((struct symtab *)lmte)->vl1) {
|
||||
dupdef:
|
||||
if(libflg) {
|
||||
noload++;
|
||||
lastdup = p;
|
||||
}
|
||||
else
|
||||
prdup(p); /*dup defn msg*/
|
||||
}
|
||||
else {
|
||||
addmte(); /* put entry in for external #`s */
|
||||
}
|
||||
}
|
||||
else { /*normal symbol*/
|
||||
if(((struct symtab *)lmte)->name[0] == 'L') /*compiler label*/
|
||||
return;
|
||||
if(Xflag==0) /*dont save local symbols*/
|
||||
return;
|
||||
addmte();
|
||||
}
|
||||
}
|
||||
|
||||
prdup(p)
|
||||
char *p;
|
||||
{
|
||||
printf(": %s duplicate definition in %s\n",p,ifilname);
|
||||
exstat++;
|
||||
}
|
||||
|
||||
/* initialize the symbol table and the heads of the hash lists*/
|
||||
intsytab()
|
||||
{
|
||||
register char **p1, **p2;
|
||||
register i;
|
||||
long longtmp;
|
||||
|
||||
bmte = sbrk(SYTESIZE*SZMT+2);
|
||||
longtmp = (long)bmte; /* 11 apr 83, for vax */
|
||||
if(longtmp&1L) /* 11 apr 83, for vax */
|
||||
bmte++;
|
||||
emte = bmte + SYTESIZE*SZMT; /*end of main table*/
|
||||
lmte=bmte; /*beginning main table*/
|
||||
cszmt = SZMT; /*current size of main table*/
|
||||
p1 = eirt;
|
||||
p2 = girt;
|
||||
for(i=32; --i != -1; ) { /* 2 may 83 */
|
||||
*p1++ = (char *)p1;
|
||||
*p1++ = (char *)0;
|
||||
*p2++ = (char *)p2;
|
||||
*p2++ = (char *)0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* method for looking up entries in the main table
|
||||
*
|
||||
* Note: The entry to be looked up must be placed at the end
|
||||
* of the main table. The global cell 'lmte'(last main
|
||||
* entry) points to the next available entry in the main
|
||||
* table. The address of an initial reference table must
|
||||
* also be provided.
|
||||
|
||||
* 1) Compute the hash code for the symbol and add it to the base address
|
||||
* of the initial reference table given as input. Thus, two words are
|
||||
* accessed which define the chain on which the symbol must be if it is
|
||||
* in the table at all.
|
||||
|
||||
* 2) Alter the table link of the last symbol in the chain so that it
|
||||
* points to the symbol being looked up. Note that the symbol to be
|
||||
* looked up is always placed at the end of the main table before
|
||||
* calling the lookup routine. This essentially adds one more element
|
||||
* to the end of the chain, namely the symbol to be looked up.
|
||||
|
||||
* 3) Now start at the first symbol in the chain and follow the chain
|
||||
* looking for a symbol equal to the smbol being looked up. It is
|
||||
* quaranteed that such a symbol will be found because it is always
|
||||
* the last symbol on the chain.
|
||||
|
||||
* 4) When the symbol is found, check to see if it is the last symbol
|
||||
* on the chain. If not, the symbol being looked for is in the table
|
||||
* and has been found. If it is the last symbol, the symbol being
|
||||
* looked up is not in the table.
|
||||
|
||||
* 5) In the case the looked up symbol is not found, it is usually added
|
||||
* to the end of the table. This is done simply by changing the
|
||||
* initial reference table entry which points to the previous
|
||||
* last symbol on the chain so that is now points to the symbol at the
|
||||
* end of the main table. In case the symbol just looked up is not to
|
||||
* be added to the main table then no action is needed . This means
|
||||
* that the table link of the last symbol on a chain may point any-
|
||||
* where.
|
||||
|
||||
* look up entry in the main table
|
||||
* call with:
|
||||
* address of initial reference table
|
||||
* entry to be looked up at the end of the main table
|
||||
* returns:
|
||||
* a pointer to the entry. if this pointer is equal to
|
||||
* lmte then the symbol was not previously in the table.
|
||||
*/
|
||||
char *
|
||||
lemt(airt)
|
||||
char **airt;
|
||||
{
|
||||
register struct symtab *mtpt; /* 14 apr 83, from char * */
|
||||
|
||||
pirt = airt + hash(); /*pointer to entry in irt*/
|
||||
/*pointer to first entry in chain*/
|
||||
mtpt = (struct symtab *)((struct irts *)((struct irts *)pirt)->irfe);
|
||||
if(mtpt==0) /*empty chain*/
|
||||
mtpt = (struct symtab *)lmte; /*start at end of main table*/
|
||||
else /*last entry in chain is new symbol*/
|
||||
((struct symtab *)((struct irts *)pirt)->irle)->tlnk = lmte;
|
||||
return(nextsy(mtpt)); /*return next match on chain*/
|
||||
}
|
||||
|
||||
/*
|
||||
* locate the next symbol on a given hash chain with the same name as lmte
|
||||
* return a pointer to it. When this pointer is equal to lmte, the
|
||||
* chain has been completely searched.
|
||||
*/
|
||||
char *
|
||||
nextsy(amtpt)
|
||||
char *amtpt;
|
||||
{
|
||||
|
||||
register char *mtpt;
|
||||
register char *p1, *p2;
|
||||
register int i;
|
||||
|
||||
mtpt = amtpt;
|
||||
|
||||
/*loop to locate entry in main table*/
|
||||
lemtl:
|
||||
p1 = &((struct symtab *)mtpt)->name[0];
|
||||
p2 = &((struct symtab *)lmte)->name[0];
|
||||
for(i=SYNAMLEN; --i != -1; ) { /* 2 may 83 */
|
||||
if(*p1++ != *p2++) { /* changed to char ptr compares */
|
||||
mtpt = ((struct symtab *)mtpt)->tlnk; /*go to next entry in chain*/
|
||||
goto lemtl;
|
||||
}
|
||||
}
|
||||
return(mtpt);
|
||||
}
|
||||
|
||||
/*
|
||||
*make an entry in the main table
|
||||
* assumes:
|
||||
* entry to be made is pointed at by lmte
|
||||
* pirt points to the correct initial reference table entry
|
||||
*/
|
||||
mmte()
|
||||
{
|
||||
|
||||
((struct irts *)pirt)->irle = lmte; /*pointer to last entry in chain*/
|
||||
if(((struct irts *)pirt)->irfe == 0) /*first entry in chain*/
|
||||
((struct irts *)pirt)->irfe = lmte;
|
||||
addmte();
|
||||
}
|
||||
|
||||
/* add the symbol pointed to by lmte to symbol table*/
|
||||
addmte()
|
||||
{
|
||||
|
||||
lmte += SYTESIZE; /*bump last main table entry pointer*/
|
||||
if(lmte>=emte) { /*main table overflow*/
|
||||
if(sbrk(SYTESIZE*ICRSZMT) == (char *)-1){ /*get more memory*/
|
||||
printf(": symbol table overflow\n");
|
||||
exit(-1);
|
||||
}
|
||||
else { /*move end of main table*/
|
||||
emte += SYTESIZE*ICRSZMT;
|
||||
cszmt += ICRSZMT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* compute a hash code for the last entry in the main table*/
|
||||
/* returns the hash code*/
|
||||
hash()
|
||||
{
|
||||
register ht1, i; /*temps*/
|
||||
register char *p;
|
||||
|
||||
ht1 = 0;
|
||||
p = &((struct symtab *)lmte)->name[0];
|
||||
for(i=SYNAMLEN; --i != -1; ) /* 2 may 83 */
|
||||
ht1 += *p++;
|
||||
return(ht1&(SZIRT-2)); /*make hash code even and between 0 and 62*/
|
||||
}
|
||||
|
||||
/*
|
||||
* pack a string into an entry in the main table
|
||||
* call with:
|
||||
* pointer to the string
|
||||
* pointer to desired entry in the main table
|
||||
*/
|
||||
pack(apkstr,apkptr)
|
||||
char *apkstr;
|
||||
char *apkptr;
|
||||
{
|
||||
register i;
|
||||
register char *pkstr, *pkptr;
|
||||
|
||||
pkstr = apkstr;
|
||||
pkptr = apkptr;
|
||||
for(i=SYNAMLEN; --i != -1; ) /* 2 may 83 */
|
||||
*pkptr++ = *pkstr++; /* changed to char ptr move */
|
||||
}
|
||||
|
||||
/*save the current state of the symbol table -- it may be restored later*/
|
||||
savsymtab()
|
||||
{
|
||||
register char **p1, **p2;
|
||||
register i;
|
||||
|
||||
savlmte = lmte;
|
||||
p2 = eirt;
|
||||
p1 = saveirt;
|
||||
for(i = SZIRT; --i != -1; ) /* 2 may 83 */
|
||||
*p1++ = *p2++;
|
||||
p2 = girt;
|
||||
p1 = savgirt;
|
||||
for(i = SZIRT; --i != -1; ) /* 2 may 83 */
|
||||
*p1++ = *p2++;
|
||||
}
|
||||
|
||||
/*restore the symbol table as it was when we last saved it*/
|
||||
restsymtab()
|
||||
{
|
||||
register char **p1, **p2;
|
||||
register i;
|
||||
|
||||
lmte = savlmte;
|
||||
p1 = eirt;
|
||||
p2 = saveirt;
|
||||
for(i = SZIRT; --i != -1; ) /* 2 may 83 */
|
||||
*p1++ = *p2++;
|
||||
p1 = girt;
|
||||
p2 = savgirt;
|
||||
for(i = SZIRT; --i != -1; ) /* 2 may 83 */
|
||||
*p1++ = *p2++;
|
||||
}
|
||||
|
||||
/*
|
||||
* resolve the external variable addresses and set the
|
||||
* base address of the data and bss segments.
|
||||
* also allocate storage for the common variables.
|
||||
*/
|
||||
resolve()
|
||||
{
|
||||
register char *p;
|
||||
|
||||
textsize = textbase - textstart;
|
||||
datasize = database;
|
||||
bsssize = bssbase;
|
||||
if(Dflag)
|
||||
database = datastart;
|
||||
else if(shtext) { /*shared text - move start of data*/
|
||||
if(shtext == -1) { /* 2k boundary */
|
||||
database = (textbase+SH2BOUND)&~(SH2BOUND-1);
|
||||
datastart = database;
|
||||
}
|
||||
else { /* 4k boundary */
|
||||
database = (textbase+SHBOUND)&~(SHBOUND-1);
|
||||
datastart = database;
|
||||
}
|
||||
}
|
||||
else if(isplit) { /* i & d split*/
|
||||
database = 0;
|
||||
datastart = 0;
|
||||
}
|
||||
else {
|
||||
database = (textbase+1)&~1;
|
||||
datastart = database;
|
||||
}
|
||||
if(Bflag)
|
||||
bssbase = bssstart;
|
||||
else {
|
||||
bssbase = (database+datasize+1)&~1;
|
||||
bssstart = bssbase;
|
||||
}
|
||||
textbase = textstart;
|
||||
fixsyms(); /*relocate symbols with addresses*/
|
||||
fixexts(); /*fix external addresses & commons*/
|
||||
if(etextptr) {
|
||||
pack(etexstr,lmte);
|
||||
p = lemt(eirt);
|
||||
do {
|
||||
((struct symtab *)p)->vl1 = textsize;
|
||||
((struct symtab *)p)->flags &= ~SYXR; /*no longer external*/
|
||||
((struct symtab *)p)->flags |= SYDF|SYGL;
|
||||
} while((p = nextsy(((struct symtab *)p)->tlnk)) != lmte);
|
||||
}
|
||||
if(edataptr) {
|
||||
pack(edatstr,lmte);
|
||||
p=lemt(eirt);
|
||||
do {
|
||||
((struct symtab *)p)->vl1 = textsize+datasize;
|
||||
((struct symtab *)p)->flags &= ~SYXR; /*no longer external*/
|
||||
((struct symtab *)p)->flags |= SYDF|SYGL;
|
||||
} while((p = nextsy(((struct symtab *)p)->tlnk)) != lmte);
|
||||
}
|
||||
if(endptr) {
|
||||
pack(eendstr,lmte);
|
||||
p = lemt(eirt);
|
||||
do {
|
||||
((struct symtab *)p)->vl1 = textsize+datasize+bsssize;
|
||||
((struct symtab *)p)->flags &= ~SYXR; /*no longer external*/
|
||||
((struct symtab *)p)->flags |= SYDF|SYGL;
|
||||
} while((p = nextsy(((struct symtab *)p)->tlnk)) != lmte);
|
||||
}
|
||||
}
|
||||
|
||||
/* fix symbol addresses that have been assigned by adding in*/
|
||||
/* database and bssbase*/
|
||||
fixsyms() /*look at each symbol*/
|
||||
{
|
||||
register struct symtab *p;
|
||||
|
||||
for(p = (struct symtab *)bmte; p<(struct symtab *)lmte; p++) {
|
||||
if(p->flags&SYXR)
|
||||
continue;
|
||||
if(p->flags&SYDA) /*data symbol*/
|
||||
p->vl1 += database;
|
||||
else if(p->flags&SYBS) /* bss symbol*/
|
||||
p->vl1 += bssbase;
|
||||
}
|
||||
}
|
||||
|
||||
/* get addresses for all external symbols and common symbols*/
|
||||
fixexts()
|
||||
{
|
||||
register char *p;
|
||||
register char **sx1, **sx2;
|
||||
|
||||
for(sx1=eirt; sx1<&eirt[63]; sx1 += 2) { /*go thru externals*/
|
||||
if(*(sx2 = sx1+1)==0) /*this chain empty*/
|
||||
continue;
|
||||
|
||||
/* go thru symbols on chain*/
|
||||
sx2 = (char **)*sx2; /*first entry on this chain*/
|
||||
while(1) {
|
||||
if(((struct symtab *)sx2)->vl1)
|
||||
asgncomn(sx2); /*assign a common address*/
|
||||
else
|
||||
asgnext(sx2); /*match to a global*/
|
||||
p = (char *)sx2;
|
||||
if(p == *sx1) /*end of chain*/
|
||||
break;
|
||||
sx2 = (char **)((struct symtab *)sx2)->tlnk; /*next entry in chain*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* print a symbol name for an error message*/
|
||||
prtsym(ap)
|
||||
char *ap;
|
||||
{
|
||||
register i;
|
||||
register char *p;
|
||||
|
||||
p = ap;
|
||||
for(i = SYNAMLEN; --i != -1; ) { /* 2 may 83 */
|
||||
if(*p)
|
||||
putchar(*p++);
|
||||
else
|
||||
break;
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
/* output symbol table to file*/
|
||||
osymt()
|
||||
{
|
||||
register struct symtab *p;
|
||||
register int cnt;
|
||||
|
||||
stlen = 0;
|
||||
cnt = 0;
|
||||
if(sflag) /*no symbol table desired*/
|
||||
return;
|
||||
|
||||
/* now output the symbols deleting externals*/
|
||||
|
||||
for(p = (struct symtab *)bmte; p < (struct symtab *)lmte; p++) {
|
||||
if(p->flags&SYXR) /*external symbol*/
|
||||
continue;
|
||||
if((p->flags&SYGL)==0 && (p->name[0]=='L' || Xflag==0))
|
||||
continue;
|
||||
osyme(p);
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
/* output symbols in a form to be read by a debugger*/
|
||||
/* call with pointer to symbol table entry*/
|
||||
osyme(aosypt)
|
||||
struct symtab *aosypt;
|
||||
{
|
||||
register struct symtab *osypt;
|
||||
register char *p1;
|
||||
register int i;
|
||||
|
||||
osypt = aosypt; /*pointer to symbol table entry*/
|
||||
stlen += OSTSIZE; /*one more symbol out*/
|
||||
|
||||
/*output symbol to loader file*/
|
||||
p1 = &(osypt->name[0]);
|
||||
for(i = SYNAMLEN; --i != -1; ) /*output symbol name*/
|
||||
putc(*p1++,&obuf);
|
||||
|
||||
lputw(&osypt->flags,&obuf); /*output symbol flags*/
|
||||
lputl(&osypt->vl1,&obuf); /*output symbol value*/
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
char *compiled = "@(#) lo68 - Mon Sep 12 07:38 1983";
|
||||
Reference in New Issue
Block a user