static struct exec header
;
static struct nlist nlist
;
static lispval
*linkaddr
;
register struct argent
*mlbot
= lbot
;
char *sbrk(), *tfile
, cbuf
[512], *mytemp(), *gstab();
printf("getting symbol table from %s\n",cbuf
); fflush(stdout
);
if((fildes
= open(cbuf
,0))<0)
* Read a.out header to find out where symbol table is.
if(read(fildes
,(char *)&header
,sizeof(header
)) <= 0) {
lseek(fildes
, header
.a_text
+header
.a_data
+header
.a_trsize
currtab
= Vreadtable
->clb
;
Vreadtable
->clb
= strtab
;
ibase
->clb
= inewint(10);
while((sizeof nlist
)==read(fildes
,&nlist
,sizeof nlist
)) {
if( nlist
.n_name
[0]!='.' || nlist
.n_name
[1]!='.')
linkaddr
= (lispval
*)*(int *)nlist
.n_value
;
bindaddr
= (int *)*(int *)(nlist
.n_value
+sizeof(int));
Vreadtable
->clb
= currtab
;
register int *i
, *end
, temp
;
extern lispval
*bind_lists
;
/* first link this linkage table to the garbage
collector's list. We will try to be tricky
so that if the garbage collector is invoked
by mkptr we will not cause markdp() to go off
*(linkaddr
-1) = (lispval
) bind_lists
;
*i
= -1; /* clobber to short circuit gc */
struct binder
{lispval (*b_entry
)();
int b_type
;} bindage
, *pos
;
pos
= (struct binder
*)bindaddr
;
for(bindage
= *pos
++; bindage
.b_atmlnk
!=-1; bindage
= *pos
++) {
if( bindage
.b_type
== 99) {
/* we must evaluate this form for effect */
findstr(bindage
.b_atmlnk
, array
);
/* garbage collection appears to
cause problems at this point */
/* if(ISNIL(copval(gcload,CNIL)) && loading->clb != tatom)
gc(CNIL); /* do a gc if gc will be off */
Vreadtable
->clb
= currtab
;
Vreadtable
->clb
= strtab
;
ibase
->clb
= inewint(10);
handy
->entry
= bindage
.b_entry
;
handy
->discipline
= (bindage
.b_type
== 0 ? lambda
:
bindage
.b_type
== 1 ? nlambda
:
findstr(bindage
.b_atmlnk
, array
);
mkptr(array
)->fnbnd
= handy
;
cp
= ptr
+ (char *)bindaddr
;
while(cnt
<STRLIM
&& (array
[cnt
++] = *cp
++));
/* find free file descriptor */
for(;p
->_flag
&(_IOREAD
|_IOWRT
);p
++)
error("Too many open files to do readlist",FALSE
);
p
->_flag
= _IOREAD
| _IOSTRG
;
p
->_base
= p
->_ptr
= str
;
p
->_cnt
= strlen(str
) + 1;