|
|
1.1 root 1:
2: # line 2 "ld.yac"
3: static char ID[] = "@(#) ld.yac: 1.8 12/1/83";
4: #include "system.h"
5: #include <stdio.h>
6: #include "bool.h"
7: #include "attributes.h"
8: #include "list.h"
9: #include "structs.h"
10:
11: #if TRVEC
12: #include "tv.h"
13: #include "ldtv.h"
14: #endif
15:
16: #include "extrns.h"
17: #include "sgs.h"
18: #include "sgsmacros.h"
19: #include "ldmacros.h"
20:
21:
22:
23: extern char inline[];
24:
25:
26: /*
27: *
28: * There is a very important variable, called
29: *
30: * in_y_exp
31: *
32: * that is used to help recognize filenames.
33: *
34: * The problems is this: a UNIX filename can contain
35: * virtually any character, and the nodes in the pathname
36: * are separated by slashes. Unfortunately, slashes also
37: * occur in expressions, comments, and the /= assignment
38: * operator. Moreover, the LEX rules ignore white space,
39: * which is important to knowing where one filename stops
40: * and the next begins.
41: *
42: * The resolution is this. Lex doesn't know enough alone to
43: * recognize a filename; so we give it some help. Whenever we
44: * are in an expression, we set in_y_exp to TRUE, and then lex knows
45: * that any slash is a slash, and should not be kept as part of
46: * a filename. a/b is a divided by b, not the file a/b.
47: *
48: * Consequently, whenever a slash must be kept as a slash,
49: * in_y_exp will be TRUE. Otherwise, it will be FALSE, and the
50: * lexical analyzer will treat a/b as a filename.
51: */
52:
53: int in_y_exp;
54:
55: static secnum; /* number of sections */
56: static char *fnamptr;
57: static int nsecspcs, fillflag; /* parsing status flags */
58: static ACTITEM *aiptr, *afaiptr, *grptr; /* pointers to action items */
59: extern char *curfilnm; /* name of current ifile */
60:
61: #if TRVEC
62: static TVASSIGN *tvslotn, /* ptr to last in list of tv slots */
63: *slotptr; /* temp for traversing list */
64: #endif
65:
66: static int tempi; /* temporary int */
67: /*eject*/
68:
69: # line 167 "ld.yac"
70: typedef union {
71: int ivalue; /* yylval values */
72: char *sptr;
73: long *lptr;
74:
75: ACTITEM *aitem; /* nonterminal values */
76: ENODE *enode;
77: } YYSTYPE;
78: # define NAME 2
79: # define LONGINT 3
80: # define INT 4
81: # define ALIGN 5
82: # define DOT 6
83: # define LEN 7
84: # define MEMORY 8
85: # define ORG 9
86: # define REGIONS 10
87: # define SECTIONS 11
88: # define PHY 12
89: # define AND 13
90: # define ANDAND 14
91: # define BNOT 15
92: # define COLON 16
93: # define COMMA 17
94: # define DIV 18
95: # define EQ 19
96: # define EQEQ 20
97: # define GE 21
98: # define GT 23
99: # define LBRACE 24
100: # define LE 26
101: # define LPAREN 27
102: # define LSHIFT 28
103: # define LT 29
104: # define MINUS 30
105: # define MULT 31
106: # define NE 32
107: # define NOT 33
108: # define OR 34
109: # define OROR 35
110: # define PC 36
111: # define PLUS 37
112: # define RBRACE 38
113: # define RPAREN 39
114: # define RSHIFT 40
115: # define SEMICOL 41
116: # define DIVEQ 42
117: # define MINUSEQ 43
118: # define MULTEQ 44
119: # define PLUSEQ 45
120: # define FILENAME 46
121: # define TV 47
122: # define SPARE 48
123: # define DSECT 49
124: # define NOLOAD 50
125: # define COPY 51
126: # define INFO 52
127: # define BLOCK 53
128: # define UMINUS 54
129: # define GROUP 55
130: # define RANGE 56
131: # define ASSIGN 57
132: #define yyclearin yychar = -1
133: #define yyerrok yyerrflag = 0
134: extern int yychar;
135: extern short yyerrflag;
136: #ifndef YYMAXDEPTH
137: #define YYMAXDEPTH 150
138: #endif
139: YYSTYPE yylval, yyval;
140: # define YYERRCODE 256
141:
142: # line 737 "ld.yac"
143:
144: /*eject*/
145: /*VARARGS*/
146: yyerror(format, a1, a2, a3, a4)
147: char *format;
148: {
149:
150: /*
151: * Issue a parsing error message
152: */
153:
154: char *p;
155:
156: p = sname(curfilnm); /* strip off directories from path name */
157:
158: /*
159: * For any purely YACC-generated error, also print out the current
160: * line, up to the point of the error
161: */
162:
163: if( strcmp(format, "syntax error") == 0 )
164: lderror(1, lineno, p, "%s : scanned line = (%s)", format, inline, a1, a2 );
165: else
166: lderror(1, lineno, p, format, a1, a2, a3, a4);
167: }
168: short yyexca[] ={
169: -1, 1,
170: 0, -1,
171: -2, 0,
172: -1, 17,
173: 19, 123,
174: 42, 123,
175: 43, 123,
176: 44, 123,
177: 45, 123,
178: -2, 125,
179: -1, 147,
180: 20, 0,
181: 21, 0,
182: 23, 0,
183: 26, 0,
184: 29, 0,
185: 32, 0,
186: -2, 103,
187: -1, 148,
188: 20, 0,
189: 21, 0,
190: 23, 0,
191: 26, 0,
192: 29, 0,
193: 32, 0,
194: -2, 104,
195: -1, 149,
196: 20, 0,
197: 21, 0,
198: 23, 0,
199: 26, 0,
200: 29, 0,
201: 32, 0,
202: -2, 105,
203: -1, 150,
204: 20, 0,
205: 21, 0,
206: 23, 0,
207: 26, 0,
208: 29, 0,
209: 32, 0,
210: -2, 106,
211: -1, 151,
212: 20, 0,
213: 21, 0,
214: 23, 0,
215: 26, 0,
216: 29, 0,
217: 32, 0,
218: -2, 107,
219: -1, 152,
220: 20, 0,
221: 21, 0,
222: 23, 0,
223: 26, 0,
224: 29, 0,
225: 32, 0,
226: -2, 108,
227: };
228: # define YYNPROD 128
229: # define YYLAST 404
230: short yyact[]={
231:
232: 97, 105, 17, 40, 108, 93, 20, 104, 101, 52,
233: 99, 36, 52, 102, 207, 96, 100, 91, 92, 103,
234: 40, 98, 106, 94, 90, 17, 36, 95, 107, 20,
235: 51, 13, 188, 12, 15, 81, 71, 51, 167, 68,
236: 194, 45, 127, 47, 175, 57, 18, 65, 16, 54,
237: 135, 44, 77, 19, 75, 55, 77, 214, 215, 216,
238: 217, 229, 53, 86, 228, 176, 227, 226, 33, 18,
239: 14, 225, 222, 97, 105, 219, 82, 180, 93, 160,
240: 104, 101, 39, 99, 28, 119, 102, 35, 96, 100,
241: 91, 92, 103, 74, 98, 106, 94, 90, 209, 179,
242: 95, 78, 79, 82, 198, 78, 79, 27, 29, 30,
243: 31, 82, 18, 115, 110, 111, 112, 88, 197, 177,
244: 172, 69, 66, 124, 123, 185, 134, 129, 114, 16,
245: 113, 121, 174, 125, 211, 72, 82, 82, 84, 137,
246: 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
247: 148, 149, 150, 151, 152, 153, 154, 169, 80, 72,
248: 156, 93, 170, 155, 83, 42, 25, 213, 22, 173,
249: 97, 105, 21, 195, 92, 93, 82, 104, 101, 94,
250: 99, 132, 178, 102, 9, 96, 100, 91, 92, 103,
251: 239, 98, 106, 94, 90, 233, 157, 95, 230, 189,
252: 187, 32, 186, 182, 162, 158, 122, 120, 184, 200,
253: 117, 67, 159, 190, 129, 193, 16, 201, 93, 116,
254: 231, 220, 64, 237, 136, 204, 20, 210, 96, 206,
255: 91, 92, 212, 93, 240, 235, 94, 90, 221, 232,
256: 95, 218, 223, 109, 205, 91, 92, 203, 202, 199,
257: 181, 94, 90, 165, 164, 163, 131, 41, 87, 24,
258: 224, 130, 168, 49, 8, 37, 49, 208, 234, 192,
259: 183, 238, 118, 85, 41, 89, 97, 105, 191, 11,
260: 37, 93, 171, 104, 101, 128, 99, 126, 48, 102,
261: 50, 96, 100, 91, 92, 103, 133, 98, 46, 94,
262: 90, 97, 43, 95, 166, 76, 93, 161, 104, 101,
263: 73, 99, 23, 38, 102, 34, 96, 100, 91, 92,
264: 103, 10, 98, 7, 94, 90, 97, 6, 95, 5,
265: 4, 93, 3, 104, 101, 2, 99, 1, 236, 102,
266: 196, 96, 100, 91, 92, 103, 70, 26, 0, 94,
267: 90, 0, 93, 95, 104, 101, 0, 99, 0, 0,
268: 102, 0, 96, 100, 91, 92, 103, 0, 0, 0,
269: 94, 90, 64, 56, 95, 61, 20, 0, 0, 0,
270: 0, 0, 62, 0, 0, 60, 0, 0, 0, 0,
271: 0, 0, 0, 0, 0, 0, 0, 63, 0, 0,
272: 58, 0, 0, 59 };
273: short yypact[]={
274:
275: -1000,-1000, 23,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
276: -1000,-1000, 148, 144, 256, 142, 65,-1000,-1000, 66,
277: -1000, 24, 18, 141,-1000, 7, 370,-1000,-1000,-1000,
278: -1000,-1000,-1000,-1000, 9,-1000, 195,-1000, 1,-1000,
279: 108,-1000, 45, 120,-1000,-1000,-1000,-1000, 140,-1000,
280: 114, 271, 255, 255, -13,-1000,-1000,-1000, 370, 370,
281: 370, 103, 101, 370,-1000,-1000,-1000, 210,-1000,-1000,
282: 194,-1000, 270, 47, 188,-1000, 49, 187, 97, 96,
283: -1000, 7,-1000, 0, 10,-1000, 219,-1000, 219,-1000,
284: 370, 370, 370, 370, 370, 370, 370, 370, 370, 370,
285: 370, 370, 370, 370, 370, 370, 370,-1000,-1000,-1000,
286: -1000,-1000,-1000, 370, 220, 157, 186, 203, 40, 185,
287: 252,-1000, 251, 250, 260,-1000, 119,-1000, 93,-1000,
288: -1000,-1000,-1000, 94,-1000, 12, 92, 12, 143, 143,
289: -1000,-1000,-1000, 215, 215, 334, 313, 200, 200, 200,
290: 200, 200, 200, 288, 263, 60, 38,-1000, 247, 184,
291: -1000,-1000, 268,-1000,-1000, 191, 86,-1000, 181, 180,
292: 0,-1000, 267, 10, 150, 91, 77, 246, 193,-1000,
293: -1000, 159, 245,-1000, 244,-1000, 260, 241, 150, 11,
294: -1000, 59,-1000,-1000,-1000, 132, 151, 8, 238, 36,
295: -1000, 214, 159, 33,-1000,-1000,-1000,-1000,-1000, 180,
296: 258,-1000,-1000,-1000, 32, 28, 27, 25, 22,-1000,
297: 179, 213,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
298: 236, 176, 159, 232, 217, 159,-1000, 171,-1000, 231,
299: -1000 };
300: short yypgo[]={
301:
302: 0, 261, 347, 36, 45, 49, 181, 32, 43, 40,
303: 346, 44, 63, 50, 340, 55, 338, 337, 335, 332,
304: 330, 329, 327, 323, 321, 315, 87, 35, 313, 82,
305: 312, 310, 307, 54, 305, 304, 38, 302, 51, 41,
306: 298, 296, 290, 288, 287, 42, 285, 282, 278, 275 };
307: short yyr1[]={
308:
309: 0, 17, 18, 18, 19, 19, 19, 19, 19, 19,
310: 19, 19, 20, 25, 25, 26, 26, 27, 27, 16,
311: 16, 21, 28, 28, 29, 29, 10, 10, 3, 22,
312: 31, 31, 33, 33, 34, 34, 34, 32, 32, 35,
313: 35, 35, 36, 30, 30, 23, 37, 37, 38, 38,
314: 38, 41, 41, 40, 42, 8, 39, 39, 43, 11,
315: 11, 12, 12, 13, 13, 14, 14, 14, 14, 14,
316: 44, 44, 44, 45, 45, 45, 45, 46, 47, 47,
317: 48, 48, 9, 9, 9, 7, 7, 7, 1, 2,
318: 2, 2, 2, 2, 5, 5, 5, 5, 5, 5,
319: 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
320: 5, 5, 49, 49, 49, 15, 15, 15, 15, 15,
321: 15, 15, 15, 4, 4, 6, 6, 24 };
322: short yyr2[]={
323:
324: 0, 1, 2, 0, 1, 1, 1, 1, 1, 1,
325: 1, 1, 4, 1, 2, 11, 1, 1, 0, 3,
326: 0, 4, 1, 2, 11, 1, 1, 0, 3, 6,
327: 3, 1, 2, 0, 3, 6, 4, 2, 0, 1,
328: 3, 0, 3, 1, 0, 4, 1, 3, 1, 1,
329: 1, 1, 3, 5, 5, 2, 6, 1, 6, 4,
330: 0, 1, 0, 4, 0, 3, 3, 3, 3, 0,
331: 1, 3, 0, 2, 1, 1, 1, 1, 4, 0,
332: 1, 3, 2, 2, 0, 2, 0, 2, 4, 1,
333: 1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
334: 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
335: 3, 1, 1, 1, 1, 1, 1, 2, 2, 2,
336: 4, 4, 3, 1, 1, 1, 1, 2 };
337: short yychk[]={
338:
339: -1000, -17, -18, -19, -20, -21, -22, -23, -1, -6,
340: -24, 256, 10, 8, 47, 11, -4, 2, 46, 30,
341: 6, 24, 24, -30, 3, 24, -2, 42, 19, 43,
342: 44, 45, -6, 2, -25, -26, 2, 256, -28, -29,
343: 2, 256, 24, -37, -38, -39, -40, -8, -43, 256,
344: -42, 30, 2, 55, -5, -15, 3, -4, 30, 33,
345: 15, 5, 12, 27, 2, 38, -26, 16, 38, -29,
346: -10, -3, 27, -31, 48, -33, -34, 7, 56, 57,
347: 38, -27, 17, 24, 24, 2, -12, 3, -12, -49,
348: 37, 30, 31, 18, 36, 40, 28, 13, 34, 23,
349: 29, 21, 26, 32, 20, 14, 35, 41, 17, 256,
350: -15, -15, -15, 27, 27, -5, 9, 16, 2, 38,
351: 19, -33, 19, 27, 27, -38, -44, -45, -46, -8,
352: -1, 256, -6, -41, -39, -13, 5, -13, -5, -5,
353: -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
354: -5, -5, -5, -5, -5, -5, -4, 39, 19, 9,
355: 39, -32, 19, 3, 3, 3, -35, -36, 2, 38,
356: -27, -47, 27, -27, 38, -11, 53, 27, -11, 39,
357: 39, 3, 19, 2, 17, 39, -27, 19, -7, 19,
358: -45, -48, 2, -39, -9, 23, -14, 27, 27, 3,
359: 16, -27, 3, 3, -36, 3, -9, 3, 256, 39,
360: -27, 2, -3, 16, 49, 50, 51, 52, 3, 39,
361: 7, -27, 39, -7, 2, 39, 39, 39, 39, 39,
362: 19, 7, 3, 19, -27, 3, -16, 6, -27, 19,
363: 3 };
364: short yydef[]={
365:
366: 3, -2, 1, 2, 4, 5, 6, 7, 8, 9,
367: 10, 11, 0, 0, 44, 0, 0, -2, 126, 0,
368: 124, 0, 0, 0, 43, 0, 0, 89, 90, 91,
369: 92, 93, 127, 125, 0, 13, 0, 16, 0, 22,
370: 27, 25, 33, 18, 46, 48, 49, 50, 0, 57,
371: 0, 0, 62, 62, 0, 111, 115, 116, 0, 0,
372: 0, 0, 0, 0, 123, 12, 14, 0, 21, 23,
373: 0, 26, 0, 0, 0, 31, 33, 0, 0, 0,
374: 45, 0, 17, 72, 0, 55, 64, 61, 64, 88,
375: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
376: 0, 0, 0, 0, 0, 0, 0, 112, 113, 114,
377: 117, 118, 119, 0, 0, 0, 0, 0, 0, 38,
378: 0, 32, 0, 0, 41, 47, 18, 70, 79, 74,
379: 75, 76, 77, 18, 51, 60, 0, 60, 94, 95,
380: 96, 97, 98, 99, 100, 101, 102, -2, -2, -2,
381: -2, -2, -2, 109, 110, 0, 0, 122, 0, 0,
382: 28, 29, 0, 30, 34, 0, 18, 39, 0, 86,
383: 0, 73, 0, 0, 84, 69, 0, 0, 0, 120,
384: 121, 18, 0, 37, 0, 36, 0, 0, 84, 0,
385: 71, 18, 80, 52, 53, 0, 0, 0, 0, 0,
386: 54, 0, 18, 0, 40, 42, 56, 85, 87, 86,
387: 0, 82, 83, 58, 0, 0, 0, 0, 0, 63,
388: 0, 0, 35, 78, 81, 65, 66, 67, 68, 59,
389: 0, 0, 18, 0, 20, 18, 15, 0, 24, 0,
390: 19 };
391: #ifndef lint
392: static char yaccpar_sccsid[] = "@(#)yaccpar 1.6 88/02/08 SMI"; /* from UCB 4.1 83/02/11 */
393: #endif
394:
395: #
396: # define YYFLAG -1000
397: # define YYERROR goto yyerrlab
398: # define YYACCEPT return(0)
399: # define YYABORT return(1)
400:
401: /* parser for yacc output */
402:
403: #ifdef YYDEBUG
404: int yydebug = 0; /* 1 for debugging */
405: #endif
406: YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
407: int yychar = -1; /* current input token number */
408: int yynerrs = 0; /* number of errors */
409: short yyerrflag = 0; /* error recovery flag */
410:
411: yyparse() {
412:
413: short yys[YYMAXDEPTH];
414: short yyj, yym;
415: register YYSTYPE *yypvt;
416: register short yystate, *yyps, yyn;
417: register YYSTYPE *yypv;
418: register short *yyxi;
419:
420: yystate = 0;
421: yychar = -1;
422: yynerrs = 0;
423: yyerrflag = 0;
424: yyps= &yys[-1];
425: yypv= &yyv[-1];
426:
427: yystack: /* put a state and value onto the stack */
428:
429: #ifdef YYDEBUG
430: if( yydebug ) printf( "state %d, char 0%o\n", yystate, yychar );
431: #endif
432: if( ++yyps>= &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
433: *yyps = yystate;
434: ++yypv;
435: *yypv = yyval;
436:
437: yynewstate:
438:
439: yyn = yypact[yystate];
440:
441: if( yyn<= YYFLAG ) goto yydefault; /* simple state */
442:
443: if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
444: if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
445:
446: if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
447: yychar = -1;
448: yyval = yylval;
449: yystate = yyn;
450: if( yyerrflag > 0 ) --yyerrflag;
451: goto yystack;
452: }
453:
454: yydefault:
455: /* default state action */
456:
457: if( (yyn=yydef[yystate]) == -2 ) {
458: if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
459: /* look through exception table */
460:
461: for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
462:
463: while( *(yyxi+=2) >= 0 ){
464: if( *yyxi == yychar ) break;
465: }
466: if( (yyn = yyxi[1]) < 0 ) return(0); /* accept */
467: }
468:
469: if( yyn == 0 ){ /* error */
470: /* error ... attempt to resume parsing */
471:
472: switch( yyerrflag ){
473:
474: case 0: /* brand new error */
475:
476: yyerror( "syntax error" );
477: yyerrlab:
478: ++yynerrs;
479:
480: case 1:
481: case 2: /* incompletely recovered error ... try again */
482:
483: yyerrflag = 3;
484:
485: /* find a state where "error" is a legal shift action */
486:
487: while ( yyps >= yys ) {
488: yyn = yypact[*yyps] + YYERRCODE;
489: if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
490: yystate = yyact[yyn]; /* simulate a shift of "error" */
491: goto yystack;
492: }
493: yyn = yypact[*yyps];
494:
495: /* the current yyps has no shift onn "error", pop stack */
496:
497: #ifdef YYDEBUG
498: if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
499: #endif
500: --yyps;
501: --yypv;
502: }
503:
504: /* there is no state on the stack with an error shift ... abort */
505:
506: yyabort:
507: return(1);
508:
509:
510: case 3: /* no shift yet; clobber input char */
511:
512: #ifdef YYDEBUG
513: if( yydebug ) printf( "error recovery discards char %d\n", yychar );
514: #endif
515:
516: if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
517: yychar = -1;
518: goto yynewstate; /* try again in the same state */
519:
520: }
521:
522: }
523:
524: /* reduction by production yyn */
525:
526: #ifdef YYDEBUG
527: if( yydebug ) printf("reduce %d\n",yyn);
528: #endif
529: yyps -= yyr2[yyn];
530: yypvt = yypv;
531: yypv -= yyr2[yyn];
532: yyval = yypv[1];
533: yym=yyn;
534: /* consult goto table to find next state */
535: yyn = yyr1[yyn];
536: yyj = yypgo[yyn] + *yyps + 1;
537: if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
538: switch(yym){
539:
540: case 1:
541: # line 178 "ld.yac"
542: ; break;
543: case 3:
544: # line 182 "ld.yac"
545: ; break;
546: case 8:
547: # line 188 "ld.yac"
548: {
549: bldexp(yypvt[-0].enode, &explist);
550: } break;
551: case 9:
552: # line 191 "ld.yac"
553: {
554: filespec(yypvt[-0].sptr);
555: } break;
556: case 11:
557: # line 195 "ld.yac"
558: {
559: for( tempi = lineno; tempi == lineno; )
560: yychar = yylex();
561: yyerrok;
562: yyclearin;
563: } break;
564: case 12:
565: # line 203 "ld.yac"
566: {
567: #if USEREGIONS == 0
568: yyerror("REGIONS command not allowed in a %s load", SGS);
569: #endif
570: } break;
571: case 14:
572: # line 211 "ld.yac"
573: ; break;
574: case 15:
575: # line 213 "ld.yac"
576: {
577: long *orgp, *lenp, *vaddrp, vzero;
578: REGION *rgnp;
579: orgp = yypvt[-6].lptr;
580: lenp = yypvt[-2].lptr;
581: if (*lenp <= 0)
582: yyerror("region %s has invalid length",yypvt[-10].sptr);
583: if ( (vaddrp = yypvt[-0].lptr) == NULL )
584: vzero = *orgp;
585: else
586: vzero = *orgp - *vaddrp;
587: if ( (vzero & 0xfL) != 0 ) {
588: yyerror("virtual 0 (paddr %.1lx) of region %s is not a multiple of 16",
589: vzero, yypvt[-10].sptr);
590: vzero &= ~0xfL;
591: }
592: rgnp = (REGION *) myalloc(sizeof(REGION));
593: rgnp->rgorig = *orgp;
594: rgnp->rglength = *lenp;
595: rgnp->rgvaddr = (vaddrp == NULL) ? 0L : *vaddrp;
596: if( (rgnp->rgvaddr + rgnp->rglength) > 0x10000L ) {
597: yyerror("addresses of region %s (vaddr=%.1lx len=%.1lx) exceed 64K",
598: yypvt[-10].sptr, rgnp->rgvaddr, *lenp);
599: rgnp->rglength = 0x10000L - rgnp->rgvaddr;
600: }
601: strncpy( rgnp->rgname, yypvt[-10].sptr, 8 );
602: listadd(l_REG, ®list, rgnp);
603: } break;
604: case 16:
605: # line 241 "ld.yac"
606: {
607: yyerror("REGIONS specification ignored");
608: } break;
609: case 18:
610: # line 248 "ld.yac"
611: ; break;
612: case 19:
613: # line 250 "ld.yac"
614: {
615: if ( *(long *) yypvt[-0].lptr > 0xffffL ) {
616: yyerror("virtual address %.1lx exceeds 0xffff: truncated to %.1lx",
617: *(long *) yypvt[-0].lptr, *(long *) yypvt[-0].lptr & 0xffffL);
618: *(long *) yypvt[-0].lptr &= 0xffffL;
619: }
620: yyval.lptr = yypvt[-0].lptr;
621: } break;
622: case 20:
623: # line 259 "ld.yac"
624: {
625: yyval.lptr = NULL;
626: } break;
627: case 21:
628: # line 264 "ld.yac"
629:
630: ; break;
631: case 23:
632: # line 268 "ld.yac"
633: ; break;
634: case 24:
635: # line 270 "ld.yac"
636: {
637: long *orgp, *lenp;
638: MEMTYPE *memp;
639: orgp = yypvt[-5].lptr;
640: lenp = yypvt[-1].lptr;
641: memp = (MEMTYPE *) myalloc(sizeof(MEMTYPE));
642: memp->mtorig = *orgp;
643: memp->mtlength = *lenp;
644: memp->mtattr = yypvt[-9].ivalue;
645: strncpy( memp->mtname, yypvt[-10].sptr, 8 );
646: listadd(l_MEM, &memlist, memp);
647: } break;
648: case 25:
649: # line 282 "ld.yac"
650: {
651: yyerror("MEMORY specification ignored");
652: } break;
653: case 26:
654: # line 287 "ld.yac"
655: {
656: yyval.ivalue = yypvt[-0].ivalue;
657: } break;
658: case 27:
659: # line 290 "ld.yac"
660: { /* empty */
661: yyval.ivalue = att_R | att_W | att_X | att_I;
662: } break;
663: case 28:
664: # line 295 "ld.yac"
665: {
666: int attflgs;
667: char *p;
668: attflgs = 0;
669: for( p = yypvt[-1].sptr; *p; p++ )
670: switch (*p) {
671: case 'R': attflgs |= att_R; break;
672: case 'W': attflgs |= att_W; break;
673: case 'X': attflgs |= att_X; break;
674: case 'I': attflgs |= att_I; break;
675: default: yyerror("bad attribute value in MEMORY directive: %c", *p);
676: }
677: yyval.ivalue = attflgs;
678: } break;
679: case 29:
680: # line 311 "ld.yac"
681: {
682: #if TRVEC
683: int length;
684:
685: tvspec.tvinflnm = curfilnm;
686: tvspec.tvinlnno = lineno;
687:
688: length = 0;
689: for( slotptr = tvslot1; slotptr != NULL; slotptr = slotptr->nxtslot ) {
690: TVASSIGN *slotptr2;
691: length = max(length, slotptr->slot);
692: for (slotptr2 = tvslot1; slotptr2 != slotptr; slotptr2 = slotptr2->nxtslot )
693: if (slotptr2->slot == slotptr->slot) {
694: lderror(1,0,NULL,
695: "function %s assigned to tv slot %d which is already in use", slotptr->funname, slotptr->slot);
696: break;
697: }
698: }
699: if( tvspec.tvlength > 0 ) {
700: if( length > tvspec.tvlength ) {
701: yyerror("ASSIGN slot %d exceeds total TV size of %d",
702: length, tvspec.tvlength);
703: tvspec.tvlength = length;
704: }
705: if( tvspec.tvrange[1] > tvspec.tvlength ) {
706: yyerror("RANGE value %d exceeds total TV size of %d",
707: tvspec.tvrange[1], tvspec.tvlength);
708: tvspec.tvlength = tvspec.tvrange[1];
709: }
710: }
711: else
712: tvspec.tvlength = max(length, tvspec.tvrange[1]);
713: #else
714: yyerror("usage of unimplemented syntax");
715: #endif
716: } break;
717: case 30:
718: # line 349 "ld.yac"
719: {
720: #if TRVEC
721: tvspec.tvosptr = (OUTSECT *) ((unsigned) *(long *) yypvt[-0].lptr);
722: #else
723: yyerror("usage of unimplemented syntax");
724: #endif
725: } break;
726: case 34:
727: # line 363 "ld.yac"
728: {
729: #if TRVEC
730: if( tvspec.tvlength > 0 )
731: yyerror("illegal multiple LENGTH fields in the TV directive");
732: tvspec.tvlength = (int) (*(long *) yypvt[-0].lptr);
733: #else
734: yyerror("usage of unimplemented syntax");
735: #endif
736: } break;
737: case 35:
738: # line 372 "ld.yac"
739: {
740: #if TRVEC
741: if( tvspec.tvrange[1] > 0 )
742: yyerror("illegal multiple RANGE fields in the TV directive");
743: if( tvspec.tvrange[0] < 0 || tvspec.tvrange[0] > tvspec.tvrange[1] )
744: yyerror("illegal RANGE syntax: r[0]<0 or r[0]>r[1]");
745: else {
746: tvspec.tvrange[0] = (int) (*(long *) yypvt[-3].lptr);
747: tvspec.tvrange[1] = (int) (*(long *) yypvt[-1].lptr);
748: }
749: #else
750: yyerror("usage of unimplemented syntax");
751: #endif
752: } break;
753: case 37:
754: # line 389 "ld.yac"
755: {
756: #if TRVEC
757: #if FLEXNAMES
758: tvspec.tvfnfill = savefn(yypvt[-0].sptr);
759: #else
760: strncpy(tvspec.tvfnfill, yypvt[-0].sptr, 8 );
761: #endif
762: #else
763: yyerror("usage of unimplemented syntax");
764: #endif
765: } break;
766: case 42:
767: # line 407 "ld.yac"
768: {
769: #if TRVEC
770: if( (int) (*(long *) yypvt[-0].lptr) == 0 )
771: yyerror("illegal ASSIGN slot number (0)");
772: if( tvslot1 == NULL )
773: tvslot1 = tvslotn = (TVASSIGN *) myalloc(sizeof(TVASSIGN));
774: else
775: tvslotn = tvslotn->nxtslot = (TVASSIGN *) myalloc(sizeof(TVASSIGN));
776: #if FLEXNAMES
777: tvslotn->funname = savefn(yypvt[-2].sptr);
778: #else
779: strncpy(tvslotn->funname, yypvt[-2].sptr, 8);
780: #endif
781: tvslotn->slot = (int) (*(long *) yypvt[-0].lptr);
782: tvslotn->nxtslot = NULL;
783: #else
784: yyerror("usage of unimplemented syntax");
785: #endif
786: } break;
787: case 43:
788: # line 428 "ld.yac"
789: {
790: long org;
791: org = *(long *) yypvt[-0].lptr;
792: #if TRVEC
793: chktvorg(org, &(tvspec.tvbndadr));
794: #endif
795: } break;
796: case 45:
797: # line 438 "ld.yac"
798:
799: ; break;
800: case 53:
801: # line 454 "ld.yac"
802: {
803: listadd(l_AI,&bldoutsc,grptr);
804: grptr = NULL;
805: } break;
806: case 54:
807: # line 460 "ld.yac"
808: {
809: if ( yypvt[-3].lptr != NULL && yypvt[-2].lptr != NULL )
810: yyerror("bonding excludes alignment");
811: grptr = dfnscngrp(AIDFNGRP, (long *)yypvt[-3].lptr, (long *)yypvt[-2].lptr, (long *)yypvt[-1].lptr);
812: strncpy( grptr->dfnscn.ainame, "*group*", 8 );
813: } break;
814: case 55:
815: # line 468 "ld.yac"
816: {
817: char *fp;
818: fp = yypvt[-0].sptr;
819: if (fp[0] == 'l') /* library flag */
820: library(fp);
821: else
822: yyerror("bad flag value in SECTIONS directive: -%s", yypvt[-0].sptr);
823: } break;
824: case 56:
825: # line 478 "ld.yac"
826: {
827: if (aiptr == NULL)
828: goto scnerr;
829: aiptr->dfnscn.aifill = yypvt[-1].ivalue;
830: aiptr->dfnscn.aifillfg = fillflag;
831: listadd(l_AI,grptr ? &grptr->dfnscn.sectspec : &bldoutsc,aiptr);
832: if (grptr && yypvt[-0].ivalue)
833: yyerror("can not specify an owner for section within a group");
834: aiptr = NULL;
835: } break;
836: case 57:
837: # line 488 "ld.yac"
838: {
839: if (aiptr)
840: yyerror("section %s not built", aiptr->dfnscn.ainame);
841: scnerr:
842: aiptr = NULL;
843: } break;
844: case 58:
845: # line 496 "ld.yac"
846: {
847: secnum++;
848: if ( OKSCNNAME(yypvt[-5].sptr) == 0 )
849: yyerror("%s is a reserved section name", yypvt[-5].sptr);
850: if ( yypvt[-4].lptr != NULL && yypvt[-3].lptr != NULL )
851: yyerror("bonding excludes alignment");
852: aiptr = dfnscngrp(AIDFNSCN, (long *)yypvt[-4].lptr, (long *)yypvt[-3].lptr, (long *)yypvt[-2].lptr);
853: if (grptr && aiptr->dfnscn.aibndadr != -1L)
854: yyerror("can not bond a section within a group");
855: if (grptr && aiptr->dfnscn.aialign != 0L)
856: yyerror("can not align a section within a group");
857: aiptr->dfnscn.aisctype = yypvt[-1].ivalue;
858: strncpy( aiptr->dfnscn.ainame, yypvt[-5].sptr, 8 );
859: } break;
860: case 59:
861: # line 512 "ld.yac"
862: {
863: yyval.lptr = yypvt[-1].lptr;
864: } break;
865: case 60:
866: # line 515 "ld.yac"
867: { /* empty */
868: yyval.lptr = NULL;
869: } break;
870: case 61:
871: # line 520 "ld.yac"
872: {
873: yyval.lptr = yypvt[-0].lptr;
874: } break;
875: case 62:
876: # line 523 "ld.yac"
877: { /* empty */
878: yyval.lptr = NULL;
879: } break;
880: case 63:
881: # line 528 "ld.yac"
882: {
883: yyval.lptr = yypvt[-1].lptr;
884: } break;
885: case 64:
886: # line 531 "ld.yac"
887: { /* empty */
888: yyval.lptr = NULL;
889: } break;
890: case 65:
891: # line 536 "ld.yac"
892: {
893: yyval.ivalue = STYP_DSECT;
894: } break;
895: case 66:
896: # line 539 "ld.yac"
897: {
898: yyval.ivalue = STYP_NOLOAD;
899: } break;
900: case 67:
901: # line 542 "ld.yac"
902: {
903: yyval.ivalue = STYP_COPY | STYP_DSECT;
904: } break;
905: case 68:
906: # line 545 "ld.yac"
907: {
908: yyval.ivalue = STYP_INFO | STYP_DSECT;
909: } break;
910: case 69:
911: # line 548 "ld.yac"
912: { /* empty */
913: yyval.ivalue = STYP_REG;
914: } break;
915: case 74:
916: # line 559 "ld.yac"
917: {
918: bldadfil( ((ACTITEM *) ldfilist.tail)->ldlbry.aifilnam, aiptr );
919: } break;
920: case 75:
921: # line 562 "ld.yac"
922: {
923: bldexp(yypvt[-0].enode,&aiptr->dfnscn.sectspec);
924: } break;
925: case 76:
926: # line 565 "ld.yac"
927: {
928: in_y_exp = 0;
929: yyerror("statement ignored");
930: for( tempi = lineno; ((int)yychar > 0) && (tempi == lineno) ; )
931: yychar = yylex();
932: if ((int) yychar <= 0)
933: lderror(2,0,NULL, "unexpected EOF");
934: yyerrok;
935: yyclearin;
936: } break;
937: case 77:
938: # line 577 "ld.yac"
939: {
940: fnamptr = savefn(yypvt[-0].sptr);
941: nsecspcs = 0;
942: bldldfil(fnamptr,0);
943: afaiptr = bldadfil(fnamptr,aiptr);
944: } break;
945: case 78:
946: # line 584 "ld.yac"
947: {
948: afaiptr->adfile.ainadscs = nsecspcs;
949: afaiptr->adfile.aifilflg = fillflag;
950: afaiptr->adfile.aifill2 = yypvt[-0].ivalue;
951: } break;
952: case 80:
953: # line 592 "ld.yac"
954: {
955: nsecspcs++;
956: bldadscn(yypvt[-0].sptr,fnamptr,aiptr);
957: } break;
958: case 81:
959: # line 596 "ld.yac"
960: {
961: nsecspcs++;
962: bldadscn(yypvt[-0].sptr,fnamptr,aiptr);
963: } break;
964: case 82:
965: # line 602 "ld.yac"
966: {
967: if (grptr)
968: strncpy( grptr->dfnscn.aiowname, yypvt[-0].sptr, 8 );
969: else
970: strncpy( aiptr->dfnscn.aiowname, yypvt[-0].sptr, 8 );
971: yyval.ivalue = 1;
972: } break;
973: case 83:
974: # line 609 "ld.yac"
975: {
976: if (grptr)
977: grptr->dfnscn.aiattown = yypvt[-0].ivalue;
978: else
979: aiptr->dfnscn.aiattown = yypvt[-0].ivalue;
980: yyval.ivalue = 1;
981: } break;
982: case 84:
983: # line 616 "ld.yac"
984: { /* empty */
985: yyval.ivalue = 0;
986: } break;
987: case 85:
988: # line 621 "ld.yac"
989: {
990: fillflag = 1;
991: yyval.ivalue = (int) (*(long *)yypvt[-0].lptr);
992: } break;
993: case 86:
994: # line 625 "ld.yac"
995: { /* empty */
996: fillflag = 0;
997: yyval.ivalue = 0;
998: } break;
999: case 87:
1000: # line 629 "ld.yac"
1001: {
1002: yyerror("bad fill value");
1003: fillflag = 0;
1004: yyerrok;
1005: yyclearin;
1006: yyval.ivalue = 0;
1007: } break;
1008: case 88:
1009: # line 638 "ld.yac"
1010: {
1011: in_y_exp = 0;
1012: if ( yypvt[-2].ivalue == EQ )
1013: yyval.enode = buildtree(EQ, yypvt[-3].enode, yypvt[-1].enode);
1014: else {
1015: ENODE *p,*ndp;
1016: ndp = buildtree(yypvt[-2].ivalue,yypvt[-3].enode,yypvt[-1].enode);
1017: p = (ENODE *) myalloc(sizeof(ENODE));
1018: *p = *yypvt[-3].enode;
1019: yyval.enode = buildtree(EQ,p,ndp);
1020: }
1021: } break;
1022: case 89:
1023: # line 652 "ld.yac"
1024: { yyval.ivalue = DIV; in_y_exp = TRUE; } break;
1025: case 90:
1026: # line 653 "ld.yac"
1027: { yyval.ivalue = EQ; in_y_exp = TRUE; } break;
1028: case 91:
1029: # line 654 "ld.yac"
1030: { yyval.ivalue = MINUS; in_y_exp = TRUE; } break;
1031: case 92:
1032: # line 655 "ld.yac"
1033: { yyval.ivalue = MULT; in_y_exp = TRUE; } break;
1034: case 93:
1035: # line 656 "ld.yac"
1036: { yyval.ivalue = PLUS; in_y_exp = TRUE; } break;
1037: case 94:
1038: # line 659 "ld.yac"
1039: {
1040: bop:
1041: yyval.enode = buildtree(yypvt[-1].ivalue,yypvt[-2].enode,yypvt[-0].enode);
1042: } break;
1043: case 95:
1044: # line 663 "ld.yac"
1045: { goto bop; } break;
1046: case 96:
1047: # line 664 "ld.yac"
1048: { goto bop; } break;
1049: case 97:
1050: # line 665 "ld.yac"
1051: { goto bop; } break;
1052: case 98:
1053: # line 666 "ld.yac"
1054: { goto bop; } break;
1055: case 99:
1056: # line 667 "ld.yac"
1057: { goto bop; } break;
1058: case 100:
1059: # line 668 "ld.yac"
1060: { goto bop; } break;
1061: case 101:
1062: # line 669 "ld.yac"
1063: { goto bop; } break;
1064: case 102:
1065: # line 670 "ld.yac"
1066: { goto bop; } break;
1067: case 103:
1068: # line 671 "ld.yac"
1069: { goto bop; } break;
1070: case 104:
1071: # line 672 "ld.yac"
1072: { goto bop; } break;
1073: case 105:
1074: # line 673 "ld.yac"
1075: { goto bop; } break;
1076: case 106:
1077: # line 674 "ld.yac"
1078: { goto bop; } break;
1079: case 107:
1080: # line 675 "ld.yac"
1081: { goto bop; } break;
1082: case 108:
1083: # line 676 "ld.yac"
1084: { goto bop; } break;
1085: case 109:
1086: # line 677 "ld.yac"
1087: { goto bop; } break;
1088: case 110:
1089: # line 678 "ld.yac"
1090: { goto bop; } break;
1091: case 111:
1092: # line 679 "ld.yac"
1093: {
1094: yyval.enode = yypvt[-0].enode;
1095: } break;
1096: case 114:
1097: # line 686 "ld.yac"
1098: {
1099: yyerror ("semicolon required after expression");
1100: } break;
1101: case 115:
1102: # line 691 "ld.yac"
1103: {
1104: yyval.enode = cnstnode(*(long *) yypvt[-0].lptr);
1105: } break;
1106: case 116:
1107: # line 694 "ld.yac"
1108: {
1109: yyval.enode = yypvt[-0].enode;
1110: } break;
1111: case 117:
1112: # line 697 "ld.yac"
1113: {
1114: yyval.enode = buildtree(UMINUS,yypvt[-0].enode,NULL);
1115: } break;
1116: case 118:
1117: # line 700 "ld.yac"
1118: {
1119: yyval.enode = buildtree(yypvt[-1].ivalue,yypvt[-0].enode,NULL);
1120: } break;
1121: case 119:
1122: # line 703 "ld.yac"
1123: {
1124: yyval.enode = buildtree(BNOT,yypvt[-1].ivalue,NULL);
1125: } break;
1126: case 120:
1127: # line 706 "ld.yac"
1128: {
1129: yyval.enode = buildtree(yypvt[-3].ivalue,yypvt[-1].enode,NULL);
1130: } break;
1131: case 121:
1132: # line 709 "ld.yac"
1133: {
1134: yyval.enode = buildtree(yypvt[-3].ivalue,yypvt[-1].enode,NULL);
1135: } break;
1136: case 122:
1137: # line 712 "ld.yac"
1138: {
1139: yyval.enode = yypvt[-1].enode;
1140: } break;
1141: case 123:
1142: # line 717 "ld.yac"
1143: {
1144: yyval.enode = symnode(yypvt[-0].sptr);
1145: } break;
1146: case 124:
1147: # line 720 "ld.yac"
1148: {
1149: yyval.enode = symnode(NULL);
1150: } break;
1151: case 125:
1152: # line 725 "ld.yac"
1153: {
1154: yyval.sptr = yypvt[-0].sptr;
1155: } break;
1156: case 126:
1157: # line 728 "ld.yac"
1158: {
1159: yyval.sptr = yypvt[-0].sptr;
1160: } break;
1161: case 127:
1162: # line 733 "ld.yac"
1163: {
1164: pflags(yypvt[-0].sptr, TRUE);
1165: } break;
1166: }
1167: goto yystack; /* stack new state and value */
1168:
1169: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.