Subversion Repositories tendra.SVN

Rev

Rev 5 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 6
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
Line 33... Line 63...
33
#endif /* lint */
63
#endif /* lint */
34
/*
64
/*
35
  symbol.c
65
  symbol.c
36
 
66
 
37
  This file contains code to generate the alpha symbol table
67
  This file contains code to generate the alpha symbol table
38
  (the .t file).  This code is based on the MIPS translator file 
68
  (the .t file).  This code is based on the MIPS translator file
39
  new_symbol.c
69
  new_symbol.c
40
*/
70
*/
41
 
71
 
42
/*
72
/*
43
$Log: symbol.c,v $
73
$Log: symbol.c,v $
Line 67... Line 97...
67
 *
97
 *
68
*/
98
*/
69
 
99
 
70
 
100
 
71
#include "config.h"
101
#include "config.h"
72
#include "symtab.h" 	/* type definitions for translator 
102
#include "symtab.h" 	/* type definitions for translator
73
			   produced debugging information 
103
			   produced debugging information
74
			   to be incorporated into a .T file */
104
			   to be incorporated into a .T file */
75
#include "bstack.h"
105
#include "bstack.h"
76
#include "makesymtab.h"
106
#include "makesymtab.h"
77
#include "xalloc.h"
107
#include "xalloc.h"
78
#include "common_types.h"
108
#include "common_types.h"
Line 88... Line 118...
88
#else
118
#else
89
#include CROSS_INCLUDE/symconst.h>
119
#include CROSS_INCLUDE/symconst.h>
90
#endif
120
#endif
91
 
121
 
92
 
122
 
93
/* Procedures to accumulate symbol table records for MIPS translator 
123
/* Procedures to accumulate symbol table records for MIPS translator
94
 
124
 
95
   new_lsym
125
   new_lsym
96
   new_lsym_d
126
   new_lsym_d
97
   new_esym
127
   new_esym
98
   new_esym_d
128
   new_esym_d
Line 115... Line 145...
115
LSYMS* local_symbols;
145
LSYMS* local_symbols;
116
STRINGS* local_strings;
146
STRINGS* local_strings;
117
AUXTAB* aux_symbols;
147
AUXTAB* aux_symbols;
118
BSTACK* blockstack;
148
BSTACK* blockstack;
119
 
149
 
120
int add_aux PROTO_S ((AUXU,int));
150
int add_aux(AUXU,int);
121
	
151
 
122
int* file_inds;
152
int* file_inds;
123
int* aux_inds;
153
int* aux_inds;
124
int* str_inds;
154
int* str_inds;
125
int* sym_inds;
155
int* sym_inds;
126
 
156
 
Line 130... Line 160...
130
int stringsize = 0;
160
int stringsize = 0;
131
int nostrings=0;
161
int nostrings=0;
132
int noaux = 0;
162
int noaux = 0;
133
int densind = 0;
163
int densind = 0;
134
int esymindex = 0;
164
int esymindex = 0;
135
int extind=0;	
165
int extind=0;
136
 
166
 
137
 
167
 
138
void init_table_space
168
void init_table_space
139
    PROTO_N ( ( noofiles,noprocs ) )
-
 
140
    PROTO_T ( int noofiles X int noprocs )
169
(int noofiles, int noprocs)
141
{
170
{
142
  int ind=0;
171
  int ind=0;
143
  AUXU nilaux;
172
  AUXU nilaux;
144
  nilaux.isym=0;
173
  nilaux.isym=0;
145
  blockstack= (BSTACK*)xcalloc(noofiles,sizeof(BSTACK));
174
  blockstack= (BSTACK*)xcalloc(noofiles,sizeof(BSTACK));
146
  if(noofiles==0) alphafail(NO_DIAGNOSTICS_IN_TDF);
175
  if (noofiles==0)alphafail(NO_DIAGNOSTICS_IN_TDF);
147
  densenos=(DENSETAB*)xcalloc(1,sizeof(DENSETAB));
176
  densenos= (DENSETAB*)xcalloc(1,sizeof(DENSETAB));
148
  densenos->num = 0;
177
  densenos->num = 0;
149
  densenos->densenolist = (pDNR)xcalloc(DENSETABSIZE,sizeof(DNR));
178
  densenos->densenolist = (pDNR)xcalloc(DENSETABSIZE,sizeof(DNR));
150
  densenos->moredensenos= (DENSETAB*)0;
179
  densenos->moredensenos= (DENSETAB*)0;
151
  dense_numbers=densenos;
180
  dense_numbers=densenos;
152
  
181
 
153
  extstrings=(STRINGS*)xcalloc(1,sizeof(STRINGS));
182
  extstrings= (STRINGS*)xcalloc(1,sizeof(STRINGS));
154
  extstrings->str=(char*)xcalloc(STRINGTABSIZE,sizeof(char));
183
  extstrings->str= (char*)xcalloc(STRINGTABSIZE,sizeof(char));
155
  extstrings->usage=0;
184
  extstrings->usage=0;
156
  extstrings->overspill=(STRINGS*)0;
185
  extstrings->overspill= (STRINGS*)0;
157
  external_strings=extstrings;
186
  external_strings=extstrings;
158
     
187
 
159
  esymlist=(ESYMS*)xcalloc(1,sizeof(ESYMS));
188
  esymlist= (ESYMS*)xcalloc(1,sizeof(ESYMS));
160
  esymlist->symlist=(pEXTR)xcalloc(SYMTABSIZE,sizeof(EXTR));
189
  esymlist->symlist= (pEXTR)xcalloc(SYMTABSIZE,sizeof(EXTR));
161
  esymlist->noofsyms=0;
190
  esymlist->noofsyms=0;
162
  esymlist->nextsyms=(ESYMS*)0;
191
  esymlist->nextsyms= (ESYMS*)0;
163
  external_symbols=esymlist;
192
  external_symbols=esymlist;
164
   
193
 
165
  numfiles=noofiles;
194
  numfiles=noofiles;
166
  numprocs=noprocs;
195
  numprocs=noprocs;
167
  file_inds =(int*)xcalloc(noofiles,sizeof(int));
196
  file_inds = (int*)xcalloc(noofiles,sizeof(int));
168
  aux_inds =(int*)xcalloc(noofiles,sizeof(int));
197
  aux_inds = (int*)xcalloc(noofiles,sizeof(int));
169
  str_inds =(int*)xcalloc(noofiles,sizeof(int)); 
198
  str_inds = (int*)xcalloc(noofiles,sizeof(int));
170
  sym_inds =(int*)xcalloc(noofiles,sizeof(int));
199
  sym_inds = (int*)xcalloc(noofiles,sizeof(int));
171
  proc_isym_inds =(PROCSYM*)xcalloc(noprocs,sizeof(PROCSYM));
200
  proc_isym_inds = (PROCSYM*)xcalloc(noprocs,sizeof(PROCSYM));
172
   
201
 
173
  fdrlist = (pSYMFDR)xcalloc(noofiles,sizeof(SYMFDR));
202
  fdrlist = (pSYMFDR)xcalloc(noofiles,sizeof(SYMFDR));
174
  file_desc_table = fdrlist;
203
  file_desc_table = fdrlist;
175
   
204
 
176
  local_symbols = (LSYMS*)xcalloc(noofiles,sizeof(LSYMS));
205
  local_symbols = (LSYMS*)xcalloc(noofiles,sizeof(LSYMS));
177
  local_symbols->symlist = (pSYMR)xcalloc(noofiles*SYMTABSIZE,sizeof(SYMR));
206
  local_symbols->symlist = (pSYMR)xcalloc(noofiles*SYMTABSIZE,sizeof(SYMR));
178
  
207
 
179
  local_strings = (STRINGS*)xcalloc(noofiles,sizeof(STRINGS));
208
  local_strings = (STRINGS*)xcalloc(noofiles,sizeof(STRINGS));
180
  local_strings->str = (char*)xcalloc(noofiles*STRINGTABSIZE,sizeof(char));
209
  local_strings->str = (char*)xcalloc(noofiles*STRINGTABSIZE,sizeof(char));
181
  
210
 
182
  aux_symbols=(AUXTAB*)xcalloc(noofiles,sizeof(AUXTAB));
211
  aux_symbols= (AUXTAB*)xcalloc(noofiles,sizeof(AUXTAB));
183
  aux_symbols->auxinfo=(pAUXU)xcalloc(noofiles*AUXTABSIZE,sizeof(AUXU));
212
  aux_symbols->auxinfo= (pAUXU)xcalloc(noofiles*AUXTABSIZE,sizeof(AUXU));
184
   
213
 
185
  for (ind=0; ind<noofiles;ind++,fdrlist++){
214
  for (ind=0; ind<noofiles;ind++,fdrlist++) {
186
    fdrlist->symbols=local_symbols+ind;
215
    fdrlist->symbols=local_symbols+ind;
187
    fdrlist->filestr=local_strings+ind;
216
    fdrlist->filestr=local_strings+ind;
188
    fdrlist->auxtabs=aux_symbols+ind;
217
    fdrlist->auxtabs=aux_symbols+ind;
189
    fdrlist->proc_count=0;
218
    fdrlist->proc_count=0;
190
    (local_symbols+ind)->symlist=local_symbols->symlist+ind*SYMTABSIZE;
219
   (local_symbols+ind) ->symlist=local_symbols->symlist+ind*SYMTABSIZE;
191
    (local_strings+ind)->str=local_strings->str+ind*STRINGTABSIZE;
220
   (local_strings+ind) ->str=local_strings->str+ind*STRINGTABSIZE;
192
    (aux_symbols+ind)->auxinfo=aux_symbols->auxinfo+ind*AUXTABSIZE;
221
   (aux_symbols+ind) ->auxinfo=aux_symbols->auxinfo+ind*AUXTABSIZE;
193
    add_aux(nilaux,ind);	/* for each file add nilaux so no 0 */
222
    add_aux(nilaux,ind);	/* for each file add nilaux so no 0 */
194
  }
223
  }
195
   
224
 
196
}
225
}
197
  
226
 
198
 
227
 
199
void add_proc
228
void add_proc
200
    PROTO_N ( ( sympos,filenum ) )
-
 
201
    PROTO_T ( int sympos X int filenum )
229
(int sympos, int filenum)
202
{
230
{
203
  static int symcount=0;
231
  static int symcount=0;
204
  pSYMFDR fdrlist=file_desc_table+filenum;
232
  pSYMFDR fdrlist=file_desc_table+filenum;
205
  fdrlist->proc_count+=1;
233
  fdrlist->proc_count+=1;
206
  (proc_isym_inds+symcount)->procsymindex=sympos;
234
 (proc_isym_inds+symcount) ->procsymindex=sympos;
207
  (proc_isym_inds+symcount)->fnum=filenum;
235
 (proc_isym_inds+symcount) ->fnum=filenum;
208
  symcount++;
236
  symcount++;
209
}
237
}
210
	
238
 
211
 
239
 
212
 
240
 
213
 
241
 
214
/*********************  STRING procedures  ********************/
242
/*********************  STRING procedures  ********************/
215
 
243
 
216
int add_string
244
int add_string
217
    PROTO_N ( ( str,list ) )
-
 
218
    PROTO_T ( char *str X STRINGS *list )
245
(char *str, STRINGS *list)
219
{
246
{
220
  int stringind=list->usage;
247
  int stringind=list->usage;
221
  int length = strlen(str)+1;
248
  int length = strlen(str) +1;
222
  while (list->overspill!=0){
249
  while (list->overspill!=0) {
223
    list=list->overspill;
250
    list=list->overspill;
224
    stringind+=list->usage;
251
    stringind+=list->usage;
225
  }
252
  }
226
  if ((list->usage+length)>STRINGTABSIZE){
253
  if ((list->usage+length) >STRINGTABSIZE) {
227
    list->overspill = (STRINGS*)xcalloc(1,sizeof(STRINGS));
254
    list->overspill = (STRINGS*)xcalloc(1,sizeof(STRINGS));
228
    list=list->overspill;
255
    list=list->overspill;
229
    list->str=(char*)xcalloc(STRINGTABSIZE,sizeof(char));
256
    list->str= (char*)xcalloc(STRINGTABSIZE,sizeof(char));
230
    list->usage=length;
257
    list->usage=length;
231
    strcpy(list->str,str);
258
    strcpy(list->str,str);
232
  }
259
  }
233
  else{  
260
  else{
234
    strcpy(list->str+list->usage,str);
261
    strcpy(list->str+list->usage,str);
235
    list->usage+=length;
262
    list->usage+=length;
236
  }
263
  }
237
  return stringind;
264
  return stringind;
238
}
265
}
239
 
266
 
240
 
267
 
241
int add_to_loc_strings
268
int add_to_loc_strings
242
    PROTO_N ( ( locstr,index ) )
-
 
243
    PROTO_T ( char *locstr X int index )
269
(char *locstr, int index)
244
{
270
{
245
  stringsize+=strlen(locstr)+1;
271
  stringsize+=strlen(locstr) +1;
246
  nostrings++;
272
  nostrings++;
247
  return(add_string(locstr, local_strings+index));
273
  return(add_string(locstr, local_strings+index));
248
}
274
}
249
 
275
 
250
 
276
 
251
 
277
 
252
int add_to_ext_strings
278
int add_to_ext_strings
253
    PROTO_N ( ( extstr ) )
-
 
254
    PROTO_T ( char *extstr )
279
(char *extstr)
255
{
280
{
256
  int posind=extind;
281
  int posind=extind;
257
  add_string(extstr, extstrings);
282
  add_string(extstr, extstrings);
258
  extind+=strlen(extstr)+1;
283
  extind+=strlen(extstr) +1;
259
  return(posind);
284
  return(posind);
260
}
285
}
261
 
286
 
262
 
287
 
263
/******************  DENSE NUMBERS  ********************/
288
/******************  DENSE NUMBERS  ********************/
264
 
289
 
265
 
290
 
266
int add_dense_no
291
int add_dense_no
267
    PROTO_N ( ( rfd,index ) )
-
 
268
    PROTO_T ( int rfd X int index )
292
(int rfd, int index)
269
{
293
{
270
  DNR* curr_dense;
294
  DNR* curr_dense;
271
  DENSETAB* denseptr= densenos;
295
  DENSETAB* denseptr= densenos;
272
  while (denseptr->moredensenos){
296
  while (denseptr->moredensenos) {
273
    denseptr=denseptr->moredensenos;
297
    denseptr=denseptr->moredensenos;
274
  }
298
  }
275
  if(denseptr->num==DENSETABSIZE){
299
  if (denseptr->num==DENSETABSIZE) {
276
    denseptr->moredensenos = (DENSETAB*)xcalloc(1,sizeof(DENSETAB));
300
    denseptr->moredensenos = (DENSETAB*)xcalloc(1,sizeof(DENSETAB));
277
    denseptr=denseptr->moredensenos;
301
    denseptr=denseptr->moredensenos;
278
    denseptr->num = 0;
302
    denseptr->num = 0;
279
    denseptr->densenolist = (pDNR)xcalloc(DENSETABSIZE,sizeof(DNR));
303
    denseptr->densenolist = (pDNR)xcalloc(DENSETABSIZE,sizeof(DNR));
280
    denseptr->moredensenos = (DENSETAB*)0;
304
    denseptr->moredensenos = (DENSETAB*)0;
281
  }
305
  }
282
  curr_dense=(denseptr->densenolist)+denseptr->num;
306
  curr_dense= (denseptr->densenolist) +denseptr->num;
283
  curr_dense->rfd = rfd;
307
  curr_dense->rfd = rfd;
284
  curr_dense->index = index;
308
  curr_dense->index = index;
285
  denseptr->num+=1;
309
  denseptr->num+=1;
286
  densind++;
310
  densind++;
287
  return (densind-1);
311
  return(densind-1);
288
}
312
}
289
 
313
 
290
DNR * get_dense_ptr
314
DNR * get_dense_ptr
291
    PROTO_N ( ( densind ) )
-
 
292
    PROTO_T ( int densind )
315
(int densind)
293
{
316
{
294
  DENSETAB* denseptr = densenos;
317
  DENSETAB* denseptr = densenos;
295
  int densecount=denseptr->num;
318
  int densecount=denseptr->num;
296
  while (densecount<=densind){
319
  while (densecount<=densind) {
297
    denseptr=denseptr->moredensenos;
320
    denseptr=denseptr->moredensenos;
298
    densecount+=denseptr->num;
321
    densecount+=denseptr->num;
299
  }
322
  }
300
  return(denseptr->densenolist+(denseptr->num-(densecount-densind)));
323
  return(denseptr->densenolist+ (denseptr->num- (densecount-densind)));
301
}
324
}
302
 
325
 
303
 
326
 
304
/********************  SYMBOL PROCEDURES  ********************/
327
/********************  SYMBOL PROCEDURES  ********************/
305
 
328
 
306
int get_sym_index
329
int get_sym_index
307
    PROTO_N ( ( ind ) )
-
 
308
    PROTO_T ( int ind )
330
(int ind)
309
{
331
{
310
  LSYMS* lsymlist=local_symbols+ind;
332
  LSYMS* lsymlist=local_symbols+ind;
311
  int lsymindex = lsymlist->noofsyms;
333
  int lsymindex = lsymlist->noofsyms;
312
  while (lsymlist->nextsyms!=0){
334
  while (lsymlist->nextsyms!=0) {
313
    lsymlist=lsymlist->nextsyms;
335
    lsymlist=lsymlist->nextsyms;
314
    lsymindex+=lsymlist->noofsyms;
336
    lsymindex+=lsymlist->noofsyms;
315
  }	
337
  }
316
  return (lsymindex);
338
  return(lsymindex);
317
}	
339
}
318
 
340
 
319
SYMR * get_sym_ptr
341
SYMR * get_sym_ptr
320
    PROTO_N ( ( ind,symind ) )
-
 
321
    PROTO_T ( int ind X int symind )
342
(int ind, int symind)
322
{
343
{
323
  LSYMS* lsymlist=local_symbols+ind;
344
  LSYMS* lsymlist=local_symbols+ind;
324
  int symcount=lsymlist->noofsyms;
345
  int symcount=lsymlist->noofsyms;
325
  while (symcount<=symind){
346
  while (symcount<=symind) {
326
    lsymlist=lsymlist->nextsyms;
347
    lsymlist=lsymlist->nextsyms;
327
    symcount+=lsymlist->noofsyms;
348
    symcount+=lsymlist->noofsyms;
328
  }
349
  }
329
  return(lsymlist->symlist+(lsymlist->noofsyms-(symcount-symind)));
350
  return(lsymlist->symlist+ (lsymlist->noofsyms- (symcount-symind)));
330
}
351
}
331
 
352
 
332
 
353
 
333
 
354
 
334
int add_lsym
355
int add_lsym
335
    PROTO_N ( ( ind,newsym ) )
-
 
336
    PROTO_T ( int ind X SYMR *newsym )
356
(int ind, SYMR *newsym)
337
{
357
{
338
  LSYMS* lsymlist=local_symbols+ind;
358
  LSYMS* lsymlist=local_symbols+ind;
339
  int lsymindex = lsymlist->noofsyms;
359
  int lsymindex = lsymlist->noofsyms;
340
  nosyms++;
360
  nosyms++;
341
  while (lsymlist->nextsyms!=0){
361
  while (lsymlist->nextsyms!=0) {
342
    lsymlist=lsymlist->nextsyms;
362
    lsymlist=lsymlist->nextsyms;
343
    lsymindex+=lsymlist->noofsyms;
363
    lsymindex+=lsymlist->noofsyms;
344
  }
364
  }
345
  if (lsymlist->noofsyms==SYMTABSIZE){
365
  if (lsymlist->noofsyms==SYMTABSIZE) {
346
    lsymlist->nextsyms=(LSYMS*)xcalloc(1,sizeof(LSYMS));
366
    lsymlist->nextsyms= (LSYMS*)xcalloc(1,sizeof(LSYMS));
347
    lsymlist=lsymlist->nextsyms;
367
    lsymlist=lsymlist->nextsyms;
348
    lsymlist->symlist=(pSYMR)xcalloc(SYMTABSIZE,sizeof(SYMR));
368
    lsymlist->symlist= (pSYMR)xcalloc(SYMTABSIZE,sizeof(SYMR));
349
    lsymlist->noofsyms=0;
369
    lsymlist->noofsyms=0;
350
    lsymlist->nextsyms=(LSYMS*)0;
370
    lsymlist->nextsyms= (LSYMS*)0;
351
  }
371
  }
352
  *(lsymlist->symlist+lsymlist->noofsyms)=(*newsym);
372
  *(lsymlist->symlist+lsymlist->noofsyms) = (*newsym);
353
  lsymlist->noofsyms += 1;
373
  lsymlist->noofsyms += 1;
354
  return (lsymindex);
374
  return(lsymindex);
355
}
375
}
356
 
376
 
357
 
377
 
358
int add_esym
378
int add_esym
359
    PROTO_N ( ( ind,newsym ) )
-
 
360
    PROTO_T ( int ind X SYMR *newsym )
379
(int ind, SYMR *newsym)
361
{
380
{
362
  if (esymlist->noofsyms==SYMTABSIZE){
381
  if (esymlist->noofsyms==SYMTABSIZE) {
363
    esymlist->nextsyms=(ESYMS*)xcalloc(1,sizeof(ESYMS));
382
    esymlist->nextsyms= (ESYMS*)xcalloc(1,sizeof(ESYMS));
364
    esymlist=esymlist->nextsyms;
383
    esymlist=esymlist->nextsyms;
365
    esymlist->symlist=(pEXTR)xcalloc(SYMTABSIZE,sizeof(EXTR));
384
    esymlist->symlist= (pEXTR)xcalloc(SYMTABSIZE,sizeof(EXTR));
366
    esymlist->noofsyms=0;
385
    esymlist->noofsyms=0;
367
    esymlist->nextsyms=(ESYMS*)0;
386
    esymlist->nextsyms= (ESYMS*)0;
368
  }
387
  }
369
  (esymlist->symlist+esymlist->noofsyms)->ifd = ind;
388
 (esymlist->symlist+esymlist->noofsyms) ->ifd = ind;
370
  (esymlist->symlist+esymlist->noofsyms)->asym=(*newsym);
389
 (esymlist->symlist+esymlist->noofsyms) ->asym= (*newsym);
371
  esymlist->noofsyms += 1;
390
  esymlist->noofsyms += 1;
372
  esymindex++;
391
  esymindex++;
373
  return(esymindex-1);
392
  return(esymindex-1);
374
}	
393
}
375
 
394
 
376
AUXU* get_aux_ptr PROTO_S ((int, int));
395
AUXU* get_aux_ptr(int, int);
377
 
396
 
378
int new_lsym
397
int new_lsym
379
    PROTO_N ( ( chars,value,symtype,symclass,s,filenum ) )
-
 
380
    PROTO_T ( char *chars X int value X int symtype X int symclass X diag_type s X int filenum )
398
(char *chars, int value, int symtype, int symclass, diag_type s, int filenum)
381
{
399
{
382
  SYMR newsym;
400
  SYMR newsym;
383
  AUXU nilaux;
401
  AUXU nilaux;
384
  int strind, symindex;
402
  int strind, symindex;
385
  nilaux.isym=0;
403
  nilaux.isym=0;
Line 387... Line 405...
387
  newsym.value = value;
405
  newsym.value = value;
388
  newsym.st = symtype;
406
  newsym.st = symtype;
389
  newsym.sc = symclass;
407
  newsym.sc = symclass;
390
/* do the following as a switch statment */
408
/* do the following as a switch statment */
391
 
409
 
392
  if (symtype == stEnd){
410
  if (symtype == stEnd) {
393
    SYMSTR symstrind;
411
    SYMSTR symstrind;
394
    int isymstart;
412
    int isymstart;
395
    symstrind = pop(blockstack+filenum);
413
    symstrind = pop(blockstack+filenum);
396
    isymstart = symstrind.sym;
414
    isymstart = symstrind.sym;
397
    if (symstrind.str>0)
415
    if (symstrind.str>0)
398
    {newsym.iss = symstrind.str;}	
416
    {newsym.iss = symstrind.str;}
399
    else {newsym.iss = 0 ;}	
417
    else {newsym.iss = 0 ;}
400
    if (isymstart<0){
418
    if (isymstart<0) {
401
      newsym.index=(-isymstart);
419
      newsym.index= (-isymstart);
402
      get_aux_ptr(filenum,
420
      get_aux_ptr(filenum,
403
		  get_sym_ptr(filenum, -isymstart)->index)->isym=symindex+1;
421
		  get_sym_ptr(filenum, -isymstart) ->index) ->isym=symindex+1;
404
    }
422
    }
405
    else{
423
    else{
406
      get_sym_ptr(filenum, isymstart)->index=symindex+1;
424
      get_sym_ptr(filenum, isymstart) ->index=symindex+1;
407
      newsym.index=isymstart;
425
      newsym.index=isymstart;
408
    }
426
    }
409
 
427
 
410
    /* (((local_symbols + filenum)->symlist)+newsym.index)->index = symindex+1; */
428
    /* (((local_symbols + filenum)->symlist)+newsym.index)->index = symindex+1; */
411
  }
429
  }
412
 
430
 
413
  else if (symtype == stFile){
431
  else if (symtype == stFile) {
414
    add_aux(nilaux,filenum);
432
    add_aux(nilaux,filenum);
415
    strind=add_to_loc_strings(chars,filenum);
433
    strind=add_to_loc_strings(chars,filenum);
416
    newsym.iss = strind;
434
    newsym.iss = strind;
417
    push(symindex, strind, blockstack+filenum);
435
    push(symindex, strind, blockstack+filenum);
418
    /* newsym.index filled in later by stEnd  */
436
    /* newsym.index filled in later by stEnd  */
419
  }
437
  }
420
  else if (symtype == stBlock){
438
  else if (symtype == stBlock) {
421
    if (chars){strind=add_to_loc_strings(chars,filenum);}
439
    if (chars) {strind=add_to_loc_strings(chars,filenum);}
422
    else {strind = 0;}
440
    else {strind = 0;}
423
    push(symindex, strind, blockstack+filenum);
441
    push(symindex, strind, blockstack+filenum);
424
    newsym.iss = strind;
442
    newsym.iss = strind;
425
    /* newsym.index filled in later by stEnd  */
443
    /* newsym.index filled in later by stEnd  */
426
  }
444
  }
Line 428... Line 446...
428
  else if (symtype == stLabel /*|| symtype == stMember and enum???*/ ){
446
  else if (symtype == stLabel /*|| symtype == stMember and enum???*/ ){
429
    newsym.index = 0;
447
    newsym.index = 0;
430
    newsym.iss = add_to_loc_strings(chars,filenum);
448
    newsym.iss = add_to_loc_strings(chars,filenum);
431
  }
449
  }
432
 
450
 
433
  else	if (symtype==stProc){
451
  else	if (symtype==stProc) {
434
    DNR* procdense=get_dense_ptr(value);
452
    DNR* procdense=get_dense_ptr(value);
435
    strind=add_to_loc_strings(chars,filenum);
453
    strind=add_to_loc_strings(chars,filenum);
436
    newsym.value=0;	/* not needed now */
454
    newsym.value=0;	/* not needed now */
437
/* add esym but with lsymindex as index not aux or isymMac */
455
/* add esym but with lsymindex as index not aux or isymMac */
438
    newsym.iss = add_to_ext_strings(chars);
456
    newsym.iss = add_to_ext_strings(chars);
Line 455... Line 473...
455
/* add esym but with lsymindex as index not aux or isymMac */
473
/* add esym but with lsymindex as index not aux or isymMac */
456
    procdense->rfd=filenum;
474
    procdense->rfd=filenum;
457
    procdense->index=symindex;
475
    procdense->index=symindex;
458
    newsym.index=add_aux(nilaux,filenum);
476
    newsym.index=add_aux(nilaux,filenum);
459
    push(-symindex, strind, blockstack+filenum);
477
    push(-symindex, strind, blockstack+filenum);
460
    add_proc(symindex, filenum);  
478
    add_proc(symindex, filenum);
461
    add_aux(nilaux,filenum);	/* add nil type !! */
479
    add_aux(nilaux,filenum);	/* add nil type !! */
462
  }
480
  }
463
  else if (!diagnose ){
481
  else if (!diagnose) {
464
    newsym.index = 1048575;
482
    newsym.index = 1048575;
465
    newsym.iss = add_to_loc_strings(chars,filenum);
483
    newsym.iss = add_to_loc_strings(chars,filenum);
466
  }
484
  }
467
  else{
485
  else{
468
    newsym.iss = add_to_loc_strings(chars,filenum);
486
    newsym.iss = add_to_loc_strings(chars,filenum);
469
    newsym.index = add_type_to_aux(s, filenum);
487
    newsym.index = add_type_to_aux(s, filenum);
470
  }
488
  }
471
  return(add_lsym (filenum, &newsym));
489
  return(add_lsym(filenum, &newsym));
472
}
490
}
473
 
491
 
474
 
492
 
475
int new_lsym_d
493
int new_lsym_d
476
    PROTO_N ( ( chars,value,symtype,symclass,s,filenum ) )
-
 
477
    PROTO_T ( char *chars X int value X int symtype X int symclass X diag_type s X int filenum )
494
(char *chars, int value, int symtype, int symclass, diag_type s, int filenum)
478
{
495
{
479
  return(add_dense_no(filenum,new_lsym (chars, value, symtype, symclass,s, 
496
  return(add_dense_no(filenum,new_lsym(chars, value, symtype, symclass,s,
480
					filenum)));
497
					filenum)));
481
  
498
 
482
}
499
}
483
 
500
 
484
 
501
 
485
int new_esym
502
int new_esym
486
    PROTO_N ( ( chars,value,symtype,symclass,s,filenum ) )
-
 
487
    PROTO_T ( char *chars X int value X int symtype X int symclass X diag_type s X int filenum )
503
(char *chars, int value, int symtype, int symclass, diag_type s, int filenum)
488
{
504
{
489
  SYMR newsym;
505
  SYMR newsym;
490
  int strind=add_to_ext_strings(chars);
506
  int strind=add_to_ext_strings(chars);
491
  newsym.iss = strind;
507
  newsym.iss = strind;
492
  newsym.value = value;
508
  newsym.value = value;
493
  newsym.st = symtype;
509
  newsym.st = symtype;
494
  newsym.reserved = 0;
510
  newsym.reserved = 0;
495
  newsym.sc = symclass;
511
  newsym.sc = symclass;
496
  
512
 
497
  if (((symtype==stProc) && (symclass==scNil ||symclass==scUndefined)) 
513
  if (((symtype==stProc) && (symclass==scNil ||symclass==scUndefined))
498
      || (!diagnose)){
514
      || (!diagnose)) {
499
    /* no diagnostics  */
515
    /* no diagnostics  */
500
    newsym.index=1048575;
516
    newsym.index=1048575;
501
    newsym.value=0;
517
    newsym.value=0;
502
  }
518
  }
503
  else{
519
  else{
504
    newsym.index=add_type_to_aux(s,filenum);
520
    newsym.index=add_type_to_aux(s,filenum);
505
  }
521
  }
506
  return add_esym (filenum, &newsym);
522
  return add_esym(filenum, &newsym);
507
}
523
}
508
 
524
 
509
 
525
 
510
int new_esym_d
526
int new_esym_d
511
    PROTO_N ( ( chars,value,symtype,symclass,s,filenum ) )
-
 
512
    PROTO_T ( char *chars X int value X int symtype X int symclass X diag_type s X int filenum )
527
(char *chars, int value, int symtype, int symclass, diag_type s, int filenum)
513
{
528
{
514
  return(add_dense_no(0x7fffffff,new_esym(chars, value, symtype, symclass, s
529
  return(add_dense_no(0x7fffffff,new_esym(chars, value, symtype, symclass, s
515
					  , filenum)));
530
					  , filenum)));
516
}
531
}
517
 
532
 
518
 
533
 
519
/********************* Auxillary information  ********************/
534
/********************* Auxillary information  ********************/
520
 
535
 
521
AUXU * get_aux_ptr
536
AUXU * get_aux_ptr
522
    PROTO_N ( ( index,auxind ) )
-
 
523
    PROTO_T ( int index X int auxind )
537
(int index, int auxind)
524
{
538
{
525
  AUXTAB* auxdata;
539
  AUXTAB* auxdata;
526
  int auxcount;
540
  int auxcount;
527
  auxdata=aux_symbols+index;
541
  auxdata=aux_symbols+index;
528
  auxcount=auxdata->num;
542
  auxcount=auxdata->num;
529
  while (auxcount<auxind){
543
  while (auxcount<auxind) {
530
    auxdata=auxdata->moreaux;  
544
    auxdata=auxdata->moreaux;
531
    auxcount+=auxdata->num;
545
    auxcount+=auxdata->num;
532
  }
546
  }
533
  return(auxdata->auxinfo+(auxdata->num-(auxcount-auxind)));
547
  return(auxdata->auxinfo+ (auxdata->num- (auxcount-auxind)));
534
}
548
}
535
 
549
 
536
 
550
 
537
int add_aux
551
int add_aux
538
    PROTO_N ( ( auxent,index ) )
-
 
539
    PROTO_T ( AUXU auxent X int index )
552
(AUXU auxent, int index)
540
{
553
{
541
  AUXTAB* auxdata;
554
  AUXTAB* auxdata;
542
  int auxind;
555
  int auxind;
543
  noaux++;
556
  noaux++;
544
  auxdata=aux_symbols+index;
557
  auxdata=aux_symbols+index;
545
  auxind=auxdata->num;
558
  auxind=auxdata->num;
546
  while (auxdata->moreaux!=0){
559
  while (auxdata->moreaux!=0) {
547
    auxdata=auxdata->moreaux;
560
    auxdata=auxdata->moreaux;
548
    auxind+=auxdata->num;
561
    auxind+=auxdata->num;
549
  }
562
  }
550
  if (auxdata->num==AUXTABSIZE){
563
  if (auxdata->num==AUXTABSIZE) {
551
    auxdata->moreaux=(AUXTAB*)xcalloc(1,sizeof(AUXTAB));
564
    auxdata->moreaux= (AUXTAB*)xcalloc(1,sizeof(AUXTAB));
552
    auxdata=auxdata->moreaux;
565
    auxdata=auxdata->moreaux;
553
    auxdata->auxinfo=(pAUXU)xcalloc(AUXTABSIZE,sizeof(AUXU));
566
    auxdata->auxinfo= (pAUXU)xcalloc(AUXTABSIZE,sizeof(AUXU));
554
    auxdata->moreaux=(AUXTAB*)0;
567
    auxdata->moreaux= (AUXTAB*)0;
555
    auxdata->num=0;
568
    auxdata->num=0;
556
  }
569
  }
557
  *((auxdata->auxinfo)+auxdata->num) = auxent;
570
  *((auxdata->auxinfo) +auxdata->num) = auxent;
558
  auxdata->num+=1;
571
  auxdata->num+=1;
559
  auxind++;
572
  auxind++;
560
  return (auxind-1);
573
  return(auxind-1);
561
}
574
}
562
 
575
 
563
 
576
 
564
int add_st_aux
577
int add_st_aux
565
    PROTO_N ( ( ind ) )
-
 
566
    PROTO_T ( int ind )
578
(int ind)
567
{
579
{
568
  AUXU straux;
580
  AUXU straux;
569
  AUXU maxaux;
581
  AUXU maxaux;
570
  int indaux;
582
  int indaux;
571
  maxaux.count=0xffffffff;
583
  maxaux.count=0xffffffff;
572
  straux.ti.bt=btStruct;
584
  straux.ti.bt=btStruct;
573
  indaux=add_aux(straux, ind);
585
  indaux=add_aux(straux, ind);
574
  add_aux(maxaux, ind);
586
  add_aux(maxaux, ind);
575
  add_aux(maxaux, ind);
587
  add_aux(maxaux, ind);
576
  return indaux;
588
  return indaux;
577
}
589
}
578
	
590
 
579
int add_un_aux
591
int add_un_aux
580
    PROTO_N ( ( ind ) )
-
 
581
    PROTO_T ( int ind )
592
(int ind)
582
{
593
{
583
  AUXU uniaux;
594
  AUXU uniaux;
584
  AUXU maxaux;
595
  AUXU maxaux;
585
  int indaux;
596
  int indaux;
586
  maxaux.count=0xffffffff;
597
  maxaux.count=0xffffffff;
587
  uniaux.ti.bt=btUnion;
598
  uniaux.ti.bt=btUnion;
588
  indaux=add_aux(uniaux, ind); 
599
  indaux=add_aux(uniaux, ind);
589
  add_aux(maxaux, ind);
600
  add_aux(maxaux, ind);
590
  add_aux(maxaux, ind);
601
  add_aux(maxaux, ind);
591
  return indaux;
602
  return indaux;
592
}
603
}
593
 
604
 
594
 
605
 
595
void output_symtab
606
void output_symtab
596
    PROTO_N ( ( symfilename ) )
-
 
597
    PROTO_T ( char *symfilename )
607
(char *symfilename)
598
{
608
{
599
  /* end all the files */
609
  /* end all the files */
600
  int i;
610
  int i;
601
 
611
 
602
  for (i=0;i<numfiles;i++){	/* might need the iss */
612
  for (i=0;i<numfiles;i++){	/* might need the iss */
603
    new_lsym("",0,stEnd,scText,(diag_type)0,i);
613
    new_lsym("",0,stEnd,scText,(diag_type)0,i);
604
  }
614
  }
605
 
615
 
606
  makesymtab(external_strings, external_symbols, dense_numbers, 
616
  makesymtab(external_strings, external_symbols, dense_numbers,
607
	     file_desc_table, numfiles, symfilename, esymindex, nosyms, 
617
	     file_desc_table, numfiles, symfilename, esymindex, nosyms,
608
	     extind, stringsize, noaux, densind, proc_isym_inds, numprocs);
618
	     extind, stringsize, noaux, densind, proc_isym_inds, numprocs);
609
 
619
 
610
  return;
620
  return;
611
  
621
 
612
}
622
}
613
 
623
 
614
 
624
 
615
 
625
 
616
 
626
 
617
 
627
 
618
 
628
 
619
 
629
 
620
  
630