2
Copyright (C) 1994 W. Schelter
4
This file is part of GNU Common Lisp, herein referred to as GCL
6
GCL is free software; you can redistribute it and/or modify it under
7
the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE as published by
8
the Free Software Foundation; either version 2, or (at your option)
11
GCL is distributed in the hope that it will be useful, but WITHOUT
12
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14
License for more details.
19
#define NSYMS(hdr) count_symbols(&hdr,fp)
24
/* the routines other than relocate are also used in rsym.c */
28
#define temp_malloc malloc
35
unsigned int new_value;
36
where = the_start + relocation_info.r_address;
37
switch(relocation_info.r_segment){
38
case RNOOP: goto DONT;
40
new_value = symbol_table[relocation_info.
45
case RTEXT: new_value= (int)start_address; break;
47
dprintf(relocation_info.r_address = %d,
48
relocation_info.r_address);
50
"\nRel_Info {r_segment = %x, r_symbolnum= %x, r_address = %d} -- Ignored",
51
relocation_info.r_segment,
52
relocation_info.r_symbolnum,
53
relocation_info.r_address);
57
switch(relocation_info.r_length){
58
case 0: *( char *)where = new_value + *( char *) where;
60
case 1: *( short *)where = new_value + *( short *) where;
62
case 2: *( long *)where = new_value + *( long *) where;
71
#ifdef PRIVATE_FASLINK
74
faslink(faslfile, ldargstring)
75
object faslfile, ldargstring;
77
struct exec tmpheader, faslheader;
79
FILE *fp; TABL *table;
80
char filename[MAXPATHLEN];
81
char ldargstr[MAXPATHLEN];
84
char command[MAXPATHLEN * 2];
88
object *old_vs_base = vs_base;
89
object *old_vs_top = vs_top;
91
coerce_to_filename(ldargstring, ldargstr);
92
coerce_to_filename(faslfile, filename);
94
/* Print out symbol table */
95
sprintf(stbfilename, "/tmp/stb%d", getpid());
96
fp = fopen(stbfilename, "w");
97
for(i = 0, p = (char *)&tmpheader; i < sizeof(struct exec); i++)
99
tmpheader.a_magic.system_id = HP9000S200_ID;
100
tmpheader.a_magic.file_type = RELOC_MAGIC;
101
tmpheader.a_stamp = 2;
103
fwrite(&tmpheader, sizeof(struct exec), 1, fp);
104
table = c_table.ptable;
105
for(i = 0; i < c_table.length; i++) {
106
struct nlist_ nbuf; int len;
107
char *string; unsigned int address;
108
string =(*table)[i].string;
109
address =(*table)[i].address;
110
len = strlen(string);
111
if (((strncmp(string,"_end", 4) == NULL) && (len == 4)) ||
112
((strncmp(string,"_etext",6) == NULL) && (len == 6)) ||
113
((strncmp(string,"_edata",6) == NULL) && (len == 6)))
115
nbuf.n_value = address;
116
nbuf.n_type = N_ABS | N_EXT;
120
fwrite(&nbuf,sizeof(nbuf),1,fp);
121
fwrite(string,len,1,fp);
122
tmpheader.a_lesyms += sizeof(struct nlist_) + len;
125
fwrite(&tmpheader, sizeof(struct exec), 1, fp);
128
sprintf(tmpfilename, "/tmp/fasl%d", getpid());
130
"ld -r -o %s -x %s %s %s -h _edata -h _etext",
136
if (system(command) != 0)
137
FEerror("The linkage editor failed.", 0);
141
faslfile = open_stream(faslfile, smm_input, Cnil, sKerror);
143
fp = faslfile->sm.sm_fp;
144
fread(&faslheader, sizeof(faslheader), 1, fp);
145
fseek(fp,RDATA_OFFSET(faslheader)+faslheader.a_drsize,0);
153
tmpfp = fopen(tmpfilename,"a+");
155
filecpy(tmpfp,fp,fpend-fpthis);
159
close_stream(faslfile);
161
tmpfile = make_simple_string(tmpfilename);
164
res = fasload(tmpfile);
167
vs_base = old_vs_base;
176
count_symbols(phdr,fp)
180
fseek(fp,(int)(LESYM_OFFSET(*phdr)), 0);
181
for(i = phdr->a_lesyms, nsyms = 0; i > 0; nsyms++) {
183
fread((char *)&tmp, SYMESZ, 1, fp); i -= SYMESZ;
184
fseek(fp,(int)tmp.n_length,1); i -= tmp.n_length;
190
#define READ_IN_STRING_TABLE(fp,size) \
191
read_in_string_table(fp,&fileheader,size,OUR_ALLOCA(size))
194
read_in_string_table(fp,pfileheader,string_size,buf)
196
struct exec *pfileheader;
204
dprintf( string table leng = %d, string_size);
205
fseek(fp,LESYM_OFFSET(*pfileheader), 0);
206
for (i = pfileheader->a_lesyms,j=0; i > 0; i=i- slen-SYMESZ)
209
slen = symbol_table[j++].n_length;
213
dprintf( slen %d,slen);