Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2599 lines
81 KiB

  1. /*
  2. * Created by CSD YACC (IBM PC) from "newdef.y" */
  3. # define T_FALIAS 257
  4. # define T_KCLASS 258
  5. # define T_KNAME 259
  6. # define T_KLIBRARY 260
  7. # define T_KBASE 261
  8. # define T_KDEVICE 262
  9. # define T_KPHYSICAL 263
  10. # define T_KVIRTUAL 264
  11. # define T_ID 265
  12. # define T_NUMBER 266
  13. # define T_KDESCRIPTION 267
  14. # define T_KHEAPSIZE 268
  15. # define T_KSTACKSIZE 269
  16. # define T_KMAXVAL 270
  17. # define T_KCODE 271
  18. # define T_KCONSTANT 272
  19. # define T_FDISCARDABLE 273
  20. # define T_FNONDISCARDABLE 274
  21. # define T_FEXEC 275
  22. # define T_FFIXED 276
  23. # define T_FMOVABLE 277
  24. # define T_FSWAPPABLE 278
  25. # define T_FSHARED 279
  26. # define T_FMIXED 280
  27. # define T_FNONSHARED 281
  28. # define T_FPRELOAD 282
  29. # define T_FINVALID 283
  30. # define T_FLOADONCALL 284
  31. # define T_FRESIDENT 285
  32. # define T_FPERM 286
  33. # define T_FCONTIG 287
  34. # define T_FDYNAMIC 288
  35. # define T_FNONPERM 289
  36. # define T_KDATA 290
  37. # define T_FNONE 291
  38. # define T_FSINGLE 292
  39. # define T_FMULTIPLE 293
  40. # define T_KSEGMENTS 294
  41. # define T_KOBJECTS 295
  42. # define T_KSECTIONS 296
  43. # define T_KSTUB 297
  44. # define T_KEXPORTS 298
  45. # define T_KEXETYPE 299
  46. # define T_KSUBSYSTEM 300
  47. # define T_FDOS 301
  48. # define T_FOS2 302
  49. # define T_FUNKNOWN 303
  50. # define T_FWINDOWS 304
  51. # define T_FDEV386 305
  52. # define T_FMACINTOSH 306
  53. # define T_FWINDOWSNT 307
  54. # define T_FWINDOWSCHAR 308
  55. # define T_FPOSIX 309
  56. # define T_FNT 310
  57. # define T_FUNIX 311
  58. # define T_KIMPORTS 312
  59. # define T_KNODATA 313
  60. # define T_KOLD 314
  61. # define T_KCONFORM 315
  62. # define T_KNONCONFORM 316
  63. # define T_KEXPANDDOWN 317
  64. # define T_KNOEXPANDDOWN 318
  65. # define T_EQ 319
  66. # define T_AT 320
  67. # define T_KRESIDENTNAME 321
  68. # define T_KNONAME 322
  69. # define T_STRING 323
  70. # define T_DOT 324
  71. # define T_COLON 325
  72. # define T_COMA 326
  73. # define T_ERROR 327
  74. # define T_FHUGE 328
  75. # define T_FIOPL 329
  76. # define T_FNOIOPL 330
  77. # define T_PROTMODE 331
  78. # define T_FEXECREAD 332
  79. # define T_FRDWR 333
  80. # define T_FRDONLY 334
  81. # define T_FINITGLOB 335
  82. # define T_FINITINST 336
  83. # define T_FTERMINST 337
  84. # define T_FWINAPI 338
  85. # define T_FWINCOMPAT 339
  86. # define T_FNOTWINCOMPAT 340
  87. # define T_FPRIVATE 341
  88. # define T_FNEWFILES 342
  89. # define T_REALMODE 343
  90. # define T_FUNCTIONS 344
  91. # define T_APPLOADER 345
  92. # define T_OVL 346
  93. # define T_KVERSION 347
  94. /* SCCSID = %W% %E% */
  95. #include <minlit.h>
  96. #include <bndtrn.h>
  97. #include <bndrel.h>
  98. #include <lnkio.h>
  99. #include <newexe.h>
  100. #if EXE386
  101. #include <exe386.h>
  102. #endif
  103. #include <lnkmsg.h>
  104. #include <extern.h>
  105. #include <string.h>
  106. #include <impexp.h>
  107. #define YYS_WD(x) (x)._wd /* Access macro */
  108. #define YYS_BP(x) (x)._bp /* Access macro */
  109. #define INCLUDE_DIR 0xffff /* Include directive for the lexer */
  110. #define MAX_NEST 7
  111. #define IO_BUF_SIZE 512
  112. /*
  113. * FUNCTION PROTOTYPES
  114. */
  115. LOCAL int NEAR lookup(void);
  116. LOCAL int NEAR yylex(void);
  117. LOCAL void NEAR yyerror(char *str);
  118. LOCAL void NEAR ProcNamTab(long lfa,unsigned short cb,unsigned short fres);
  119. LOCAL void NEAR NewProc(char *szName);
  120. #if NOT EXE386
  121. LOCAL void NEAR SetExpOrds(void);
  122. #endif
  123. LOCAL void NEAR NewDescription(unsigned char *sbDesc);
  124. LOCAL APROPIMPPTR NEAR GetImport(unsigned char *sb);
  125. #if EXE386
  126. LOCAL void NEAR NewModule(unsigned char *sbModnam, unsigned char *defaultExt);
  127. LOCAL void NEAR DefaultModule(unsigned char *defaultExt);
  128. #else
  129. LOCAL void NEAR NewModule(unsigned char *sbModnam);
  130. LOCAL void NEAR DefaultModule(void);
  131. #endif
  132. #if AUTOVM
  133. BYTE FAR * NEAR FetchSym1(RBTYPE rb, WORD Dirty);
  134. #define FETCHSYM FetchSym1
  135. #define PROPSYMLOOKUP EnterName
  136. #else
  137. #define FETCHSYM FetchSym
  138. #define PROPSYMLOOKUP EnterName
  139. #endif
  140. int yylineno = -1; /* Line number */
  141. LOCAL FTYPE fFileNameExpected;
  142. LOCAL FTYPE fMixed;
  143. LOCAL FTYPE fNoExeVer;
  144. LOCAL FTYPE fHeapSize;
  145. LOCAL BYTE *sbOldver; /* Old version of the .EXE */
  146. LOCAL FTYPE vfAutodata;
  147. LOCAL FTYPE vfShrattr;
  148. LOCAL BYTE cDigits;
  149. #if EXE386
  150. LOCAL DWORD offmask; /* Seg flag bits to turn off */
  151. LOCAL BYTE fUserVersion = 0;
  152. LOCAL WORD expOtherFlags = 0;
  153. LOCAL BYTE moduleEXE[] = "\007A:\\.exe";
  154. LOCAL BYTE moduleDLL[] = "\007A:\\.dll";
  155. #else
  156. LOCAL WORD offmask; /* Seg flag bits to turn off */
  157. #endif
  158. #if OVERLAYS
  159. LOCAL WORD iOvl = NOTIOVL; // Overlay assigned to functions
  160. #endif
  161. LOCAL char *szSegName; // Segment assigned to functions
  162. LOCAL WORD nameFlags; /* Flags associated with exported name */
  163. LOCAL BSTYPE includeDisp[MAX_NEST];
  164. // Include file stack
  165. LOCAL short curLevel; // Current include nesting level
  166. // Zero means main .DEF file
  167. LOCAL char *keywds[] = /* Keyword array */
  168. {
  169. "ALIAS", (char *) T_FALIAS,
  170. "APPLOADER", (char *) T_APPLOADER,
  171. "BASE", (char *) T_KBASE,
  172. "CLASS", (char *) T_KCLASS,
  173. "CODE", (char *) T_KCODE,
  174. "CONFORMING", (char *) T_KCONFORM,
  175. "CONSTANT", (char *) T_KCONSTANT,
  176. "CONTIGUOUS", (char *) T_FCONTIG,
  177. "DATA", (char *) T_KDATA,
  178. "DESCRIPTION", (char *) T_KDESCRIPTION,
  179. "DEV386", (char *) T_FDEV386,
  180. "DEVICE", (char *) T_KDEVICE,
  181. "DISCARDABLE", (char *) T_FDISCARDABLE,
  182. "DOS", (char *) T_FDOS,
  183. "DYNAMIC", (char *) T_FDYNAMIC,
  184. "EXECUTE-ONLY", (char *) T_FEXEC,
  185. "EXECUTEONLY", (char *) T_FEXEC,
  186. "EXECUTEREAD", (char *) T_FEXECREAD,
  187. "EXETYPE", (char *) T_KEXETYPE,
  188. "EXPANDDOWN", (char *) T_KEXPANDDOWN,
  189. "EXPORTS", (char *) T_KEXPORTS,
  190. "FIXED", (char *) T_FFIXED,
  191. "FUNCTIONS", (char *) T_FUNCTIONS,
  192. "HEAPSIZE", (char *) T_KHEAPSIZE,
  193. "HUGE", (char *) T_FHUGE,
  194. "IMPORTS", (char *) T_KIMPORTS,
  195. "IMPURE", (char *) T_FNONSHARED,
  196. "INCLUDE", (char *) INCLUDE_DIR,
  197. "INITGLOBAL", (char *) T_FINITGLOB,
  198. "INITINSTANCE", (char *) T_FINITINST,
  199. "INVALID", (char *) T_FINVALID,
  200. "IOPL", (char *) T_FIOPL,
  201. "LIBRARY", (char *) T_KLIBRARY,
  202. "LOADONCALL", (char *) T_FLOADONCALL,
  203. "LONGNAMES", (char *) T_FNEWFILES,
  204. "MACINTOSH", (char *) T_FMACINTOSH,
  205. "MAXVAL", (char *) T_KMAXVAL,
  206. "MIXED1632", (char *) T_FMIXED,
  207. "MOVABLE", (char *) T_FMOVABLE,
  208. "MOVEABLE", (char *) T_FMOVABLE,
  209. "MULTIPLE", (char *) T_FMULTIPLE,
  210. "NAME", (char *) T_KNAME,
  211. "NEWFILES", (char *) T_FNEWFILES,
  212. "NODATA", (char *) T_KNODATA,
  213. "NOEXPANDDOWN", (char *) T_KNOEXPANDDOWN,
  214. "NOIOPL", (char *) T_FNOIOPL,
  215. "NONAME", (char *) T_KNONAME,
  216. "NONCONFORMING", (char *) T_KNONCONFORM,
  217. "NONDISCARDABLE", (char *) T_FNONDISCARDABLE,
  218. "NONE", (char *) T_FNONE,
  219. "NONPERMANENT", (char *) T_FNONPERM,
  220. "NONSHARED", (char *) T_FNONSHARED,
  221. "NOTWINDOWCOMPAT", (char *) T_FNOTWINCOMPAT,
  222. "NT", (char *) T_FNT,
  223. "OBJECTS", (char *) T_KOBJECTS,
  224. "OLD", (char *) T_KOLD,
  225. "OS2", (char *) T_FOS2,
  226. "OVERLAY", (char *) T_OVL,
  227. "OVL", (char *) T_OVL,
  228. "PERMANENT", (char *) T_FPERM,
  229. "PHYSICAL", (char *) T_KPHYSICAL,
  230. "POSIX", (char *) T_FPOSIX,
  231. "PRELOAD", (char *) T_FPRELOAD,
  232. "PRIVATE", (char *) T_FPRIVATE,
  233. "PRIVATELIB", (char *) T_FPRIVATE,
  234. "PROTMODE", (char *) T_PROTMODE,
  235. "PURE", (char *) T_FSHARED,
  236. "READONLY", (char *) T_FRDONLY,
  237. "READWRITE", (char *) T_FRDWR,
  238. "REALMODE", (char *) T_REALMODE,
  239. "RESIDENT", (char *) T_FRESIDENT,
  240. "RESIDENTNAME", (char *) T_KRESIDENTNAME,
  241. "SECTIONS", (char *) T_KSECTIONS,
  242. "SEGMENTS", (char *) T_KSEGMENTS,
  243. "SHARED", (char *) T_FSHARED,
  244. "SINGLE", (char *) T_FSINGLE,
  245. "STACKSIZE", (char *) T_KSTACKSIZE,
  246. "STUB", (char *) T_KSTUB,
  247. "SUBSYSTEM", (char *) T_KSUBSYSTEM,
  248. "SWAPPABLE", (char *) T_FSWAPPABLE,
  249. "TERMINSTANCE", (char *) T_FTERMINST,
  250. "UNIX", (char *) T_FUNIX,
  251. "UNKNOWN", (char *) T_FUNKNOWN,
  252. "VERSION", (char *) T_KVERSION,
  253. "VIRTUAL", (char *) T_KVIRTUAL,
  254. "WINDOWAPI", (char *) T_FWINAPI,
  255. "WINDOWCOMPAT", (char *) T_FWINCOMPAT,
  256. "WINDOWS", (char *) T_FWINDOWS,
  257. "WINDOWSCHAR", (char *) T_FWINDOWSCHAR,
  258. "WINDOWSNT", (char *) T_FWINDOWSNT,
  259. NULL
  260. };
  261. #define UNION 1
  262. typedef union
  263. {
  264. #if EXE386
  265. DWORD _wd;
  266. #else
  267. WORD _wd;
  268. #endif
  269. BYTE *_bp;
  270. } YYSTYPE;
  271. #define yyclearin yychar = -1
  272. #define yyerrok yyerrflag = 0
  273. #ifndef YYMAXDEPTH
  274. #define YYMAXDEPTH 150
  275. #endif
  276. YYSTYPE yylval, yyval;
  277. # define YYERRCODE 256
  278. LOCAL int NEAR GetChar(void)
  279. {
  280. int c; /* A character */
  281. c = GetTxtChr(bsInput);
  282. if ((c == EOF || c == CTRL_Z) && curLevel > 0)
  283. {
  284. free(bsInput->_base);
  285. fclose(bsInput);
  286. bsInput = includeDisp[curLevel];
  287. curLevel--;
  288. c = GetChar();
  289. }
  290. return(c);
  291. }
  292. LOCAL int NEAR lookup() /* Keyword lookup */
  293. {
  294. char **pcp; /* Pointer to character pointer */
  295. int i; /* Comparison value */
  296. for(pcp = keywds; *pcp != NULL; pcp += 2)
  297. { /* Look through keyword table */
  298. /* If found, return token type */
  299. if(!(i = _stricmp(&bufg[1],*pcp)))
  300. {
  301. YYS_WD(yylval) = 0;
  302. return((int) (__int64) pcp[1]);
  303. }
  304. if(i < 0) break; /* Break if we've gone too far */
  305. }
  306. return(T_ID); /* Just your basic identifier */
  307. }
  308. LOCAL int NEAR yylex() /* Lexical analyzer */
  309. {
  310. int c; /* A character */
  311. int StrBegChr; /* What kind of quotte found at the begin of string */
  312. #if EXE386
  313. DWORD x; /* Numeric token value */
  314. #else
  315. WORD x; /* Numeric token value */
  316. #endif
  317. int state; /* State variable */
  318. BYTE *cp; /* Character pointer */
  319. BYTE *sz; /* Zero-terminated string */
  320. static int lastc = 0; /* Previous character */
  321. char *fileBuf;
  322. FTYPE fFileNameSave;
  323. static int NameLineNo;
  324. state = 0; /* Assume we're not in a comment */
  325. c = '\0';
  326. /* Loop to skip white space */
  327. for(;;)
  328. {
  329. lastc = c;
  330. if (((c = GetChar()) == EOF) || c == '\032' || c == '\377')
  331. return(EOF); /* Get a character */
  332. if (c == ';')
  333. state = TRUE; /* If comment, set flag */
  334. else if(c == '\n') /* If end of line */
  335. {
  336. state = FALSE; /* End of comment */
  337. if(!curLevel)
  338. ++yylineno; /* Increment line number count */
  339. }
  340. else if (state == FALSE && c != ' ' && c != '\t' && c != '\r')
  341. break; /* Break on non-white space */
  342. }
  343. /* Handle one-character tokens */
  344. switch(c)
  345. {
  346. case '.': /* Name separator */
  347. if (fFileNameExpected)
  348. break;
  349. return(T_DOT);
  350. case '@': /* Ordinal specifier */
  351. /*
  352. * Require that whitespace precede '@' if introducing an
  353. * ordinal, to allow '@' in identifiers.
  354. */
  355. if (lastc == ' ' || lastc == '\t' || lastc == '\r')
  356. return(T_AT);
  357. break;
  358. case '=': /* Name assignment */
  359. return(T_EQ);
  360. case ':':
  361. return(T_COLON);
  362. case ',':
  363. return(T_COMA);
  364. }
  365. /* See if token is a number */
  366. if (c >= '0' && c <= '9' && !fFileNameExpected)
  367. { /* If token is a number */
  368. x = c - '0'; /* Get first digit */
  369. c = GetChar(); /* Get next character */
  370. if(x == 0) /* If octal or hex */
  371. {
  372. if(c == 'x' || c == 'X') /* If it is an 'x' */
  373. {
  374. state = 16; /* Base is hexadecimal */
  375. c = GetChar(); /* Get next character */
  376. }
  377. else state = 8; /* Else octal */
  378. cDigits = 0;
  379. }
  380. else
  381. {
  382. state = 10; /* Else decimal */
  383. cDigits = 1;
  384. }
  385. for(;;)
  386. {
  387. if(c >= '0' && c <= '9' && c < (state + '0')) c -= '0';
  388. else if(state == 16 && c >= 'A' && c <= 'F') c -= 'A' - 10;
  389. else if(state == 16 && c >= 'a' && c <= 'f') c -= 'a' - 10;
  390. else break;
  391. cDigits++;
  392. x = x*state + c;
  393. c = (BYTE) GetChar();
  394. }
  395. ungetc(c,bsInput);
  396. YYS_WD(yylval) = x;
  397. return(T_NUMBER);
  398. }
  399. /* See if token is a string */
  400. if (c == '\'' || c == '"') /* If token is a string */
  401. {
  402. StrBegChr = c;
  403. sz = &bufg[1]; /* Initialize */
  404. for(state = 0; state != 2;) /* State machine loop */
  405. {
  406. if ((c = GetChar()) == EOF)
  407. return(EOF); /* Check for EOF */
  408. if (sz >= &bufg[sizeof(bufg)])
  409. Fatal(ER_dflinemax, sizeof(bufg));
  410. switch(state) /* Transitions */
  411. {
  412. case 0: /* Inside quote */
  413. if ((c == '\'' || c == '"') && c == StrBegChr)
  414. state = 1; /* Change state if quote found */
  415. else
  416. *sz++ = (BYTE) c; /* Else save character */
  417. break;
  418. case 1: /* Inside quote with quote */
  419. if ((c == '\'' || c == '"'))
  420. { /* If consecutive quotes */
  421. *sz++ = (BYTE) c; /* Quote inside string */
  422. state = 0; /* Back to state 0 */
  423. }
  424. else
  425. state = 2; /* Else end of string */
  426. break;
  427. }
  428. }
  429. ungetc(c,bsInput); /* Put back last character */
  430. *sz = '\0'; /* Null-terminate the string */
  431. x = (WORD)(sz - &bufg[1]);
  432. if (x >= SBLEN) /* Set length of string */
  433. {
  434. bufg[0] = 0xff;
  435. bufg[0x100] = '\0';
  436. OutWarn(ER_dfnamemax, &bufg[1]);
  437. }
  438. else
  439. bufg[0] = (BYTE) x;
  440. YYS_BP(yylval) = bufg; /* Save ptr. to identifier */
  441. return(T_STRING); /* String found */
  442. }
  443. /* Assume we have identifier */
  444. sz = &bufg[1]; /* Initialize */
  445. if (fFileNameExpected && NameLineNo && NameLineNo != yylineno)
  446. {
  447. NameLineNo = 0; /* To avoid interference with INCLUDE */
  448. fFileNameExpected = FALSE;
  449. }
  450. for(;;) /* Loop to get i.d.'s */
  451. {
  452. if (fFileNameExpected)
  453. cp = " \t\r\n\f";
  454. else
  455. cp = " \t\r\n:.=';\032";
  456. while (*cp && *cp != (BYTE) c)
  457. ++cp; /* Check for end of identifier */
  458. if(*cp) break; /* Break if end of identifier found */
  459. if (sz >= &bufg[sizeof(bufg)])
  460. Fatal(ER_dflinemax, sizeof(bufg));
  461. *sz++ = (BYTE) c; /* Save the character */
  462. if ((c = GetChar()) == EOF)
  463. break; /* Get next character */
  464. }
  465. ungetc(c,bsInput); /* Put character back */
  466. *sz = '\0'; /* Null-terminate the string */
  467. x = (WORD)(sz - &bufg[1]);
  468. if (x >= SBLEN) /* Set length of string */
  469. {
  470. bufg[0] = 0xff;
  471. bufg[0x100] = '\0';
  472. OutWarn(ER_dfnamemax, &bufg[1]);
  473. }
  474. else
  475. bufg[0] = (BYTE) x;
  476. YYS_BP(yylval) = bufg; /* Save ptr. to identifier */
  477. state = lookup();
  478. if (state == T_KNAME || state == T_KLIBRARY)
  479. {
  480. fFileNameExpected = TRUE;
  481. NameLineNo = yylineno;
  482. }
  483. if (state == INCLUDE_DIR)
  484. {
  485. // Process include directive
  486. fFileNameSave = fFileNameExpected;
  487. fFileNameExpected = (FTYPE) TRUE;
  488. state = yylex();
  489. fFileNameExpected = fFileNameSave;
  490. if (state == T_ID || state == T_STRING)
  491. {
  492. if (curLevel < MAX_NEST - 1)
  493. {
  494. curLevel++;
  495. includeDisp[curLevel] = bsInput;
  496. // Because LINK uses customized version of stdio
  497. // for every file we have not only open the file
  498. // but also allocate i/o buffer.
  499. bsInput = fopen(&bufg[1], RDBIN);
  500. if (bsInput == NULL)
  501. Fatal(ER_badinclopen, &bufg[1], strerror(errno));
  502. fileBuf = GetMem(IO_BUF_SIZE);
  503. #if OSMSDOS
  504. setvbuf(bsInput, fileBuf, _IOFBF, IO_BUF_SIZE);
  505. #endif
  506. return(yylex());
  507. }
  508. else
  509. Fatal(ER_toomanyincl);
  510. }
  511. else
  512. Fatal(ER_badinclname);
  513. }
  514. else
  515. return(state);
  516. }
  517. LOCAL void NEAR yyerror(str)
  518. char *str;
  519. {
  520. Fatal(ER_dfsyntax, str);
  521. }
  522. #if NOT EXE386
  523. /*** AppLoader - define aplication specific loader
  524. *
  525. * Purpose:
  526. * Define application specific loader. Feature available only under
  527. * Windows. Linker will create logical segment LOADER_<name> where
  528. * <name> is specified in APPLOADER statement. The LOADER_<name>
  529. * segment forms separate physical segment, which is placed by the linker
  530. * as the first segment in the .EXE file. Whithin the loader segment,
  531. * the linker will create an EXTDEF of the name <name>.
  532. *
  533. * Input:
  534. * - sbName - pointer to lenght prefixed loader name
  535. *
  536. * Output:
  537. * No explicit value is returned. As a side effect the SEGDEF and
  538. * EXTDEF definitions are entered into linker symbol table.
  539. *
  540. * Exceptions:
  541. * None.
  542. *
  543. * Notes:
  544. * None.
  545. *
  546. *************************************************************************/
  547. LOCAL void NEAR AppLoader(char *sbName)
  548. {
  549. APROPSNPTR apropSn;
  550. APROPUNDEFPTR apropUndef;
  551. SBTYPE segName;
  552. WORD strLen;
  553. // Create loader segment name
  554. strcpy(&segName[1], "LOADER_");
  555. strcat(&segName[1], &sbName[1]);
  556. strLen = (WORD)strlen(&segName[1]);
  557. if (strLen >= SBLEN)
  558. {
  559. segName[0] = SBLEN - 1;
  560. segName[SBLEN-1] = '\0';
  561. OutWarn(ER_dfnamemax, &segName[1]);
  562. }
  563. else
  564. segName[0] = (BYTE) strLen;
  565. // Define loader logical segment and remember its GSN
  566. apropSn = GenSeg(segName, "\004CODE", GRNIL, (FTYPE) TRUE);
  567. gsnAppLoader = apropSn->as_gsn;
  568. apropSn->as_flags = dfCode | NSMOVE | NSPRELOAD;
  569. MARKVP();
  570. // Define EXTDEF
  571. apropUndef = (APROPUNDEFPTR ) PROPSYMLOOKUP(sbName, ATTRUND, TRUE);
  572. vpropAppLoader = vrprop;
  573. apropUndef->au_flags |= STRONGEXT;
  574. apropUndef->au_len = -1L;
  575. MARKVP();
  576. free(sbName);
  577. }
  578. #endif
  579. /*** NewProc - fill in the COMDAT descriptor for ordered procedure
  580. *
  581. * Purpose:
  582. * Fill in the linkers symbol table COMDAT descriptor. This function
  583. * is called for new descriptors generated by FUNCTIONS list in the .DEF
  584. * file. All COMDAT descriptors entered by this function form one
  585. * list linked via ac_order field. The head of this list is global
  586. * variable procOrder;
  587. *
  588. * Input:
  589. * szName - pointer to procedure name
  590. * iOvl - overlay number - global variable
  591. * szSegName - segment name - global variable
  592. *
  593. * Output:
  594. * No explicit value is returned. As a side effect symbol table entry
  595. * is updated.
  596. *
  597. * Exceptions:
  598. * Procedure already known - warning
  599. *
  600. * Notes:
  601. * None.
  602. *
  603. *************************************************************************/
  604. LOCAL void NEAR NewProc(char *szName)
  605. {
  606. RBTYPE vrComdat; // Virtual pointer to COMDAT symbol table entry
  607. APROPCOMDATPTR apropComdat; // Real pointer to COMDAT symbol table descriptor
  608. static RBTYPE lastProc; // Last procedure on the list
  609. APROPSNPTR apropSn;
  610. apropComdat = (APROPCOMDATPTR ) PROPSYMLOOKUP(szName, ATTRCOMDAT, FALSE);
  611. if ((apropComdat != NULL) && (apropComdat->ac_flags & ORDER_BIT))
  612. OutWarn(ER_duporder, &szName[1]);
  613. else
  614. {
  615. apropComdat = (APROPCOMDATPTR ) PROPSYMLOOKUP(szName, ATTRCOMDAT, TRUE);
  616. vrComdat = vrprop;
  617. // Fill in the COMDAT descriptor
  618. apropComdat->ac_flags = ORDER_BIT;
  619. #if OVERLAYS
  620. apropComdat->ac_iOvl = iOvl;
  621. // Set the maximum overlay index
  622. if (iOvl != NOTIOVL)
  623. {
  624. fOverlays = (FTYPE) TRUE;
  625. fNewExe = FALSE;
  626. if (iOvl >= iovMac)
  627. iovMac = iOvl + 1;
  628. }
  629. #endif
  630. if (szSegName != NULL)
  631. {
  632. apropSn = GenSeg(szSegName, "\004CODE", GRNIL, (FTYPE) TRUE);
  633. apropSn->as_flags = dfCode;
  634. // Allocate COMDAT in the segment
  635. apropComdat->ac_gsn = apropSn->as_gsn;
  636. apropComdat->ac_selAlloc = PICK_FIRST | EXPLICIT;
  637. AttachComdat(vrComdat, apropSn->as_gsn);
  638. }
  639. else
  640. apropComdat->ac_selAlloc = ALLOC_UNKNOWN;
  641. MARKVP(); // Page has been changed
  642. // Attach this COMDAT to the ordered procedure list
  643. if (procOrder == VNIL)
  644. procOrder = vrComdat;
  645. else
  646. {
  647. apropComdat = (APROPCOMDATPTR ) FETCHSYM(lastProc, TRUE);
  648. apropComdat->ac_order = vrComdat;
  649. }
  650. lastProc = vrComdat;
  651. }
  652. free(szName);
  653. }
  654. LOCAL void NEAR ProcNamTab(lfa,cb,fres)
  655. long lfa; /* Table starting address */
  656. WORD cb; /* Length of table */
  657. WORD fres; /* Resident name flag */
  658. {
  659. SBTYPE sbExport; /* Exported symbol name */
  660. WORD ordExport; /* Export ordinal */
  661. APROPEXPPTR exp; /* Export symbol table entry */
  662. if (fseek(bsInput,lfa,0)) /* Seek to start of table */
  663. Fatal(ER_ioerr, strerror(errno));
  664. for(cbRec = cb; cbRec != 0; ) /* Loop through table */
  665. {
  666. sbExport[0] = (BYTE) getc(bsInput);/* Get length of name */
  667. if (fread(&sbExport[1], sizeof(char), B2W(sbExport[0]), bsInput) != B2W(sbExport[0]))
  668. Fatal(ER_ioerr, strerror(errno));
  669. /* Get export name */
  670. ordExport = getc(bsInput) | (getc(bsInput) << BYTELN);
  671. if (ordExport == 0) continue;
  672. /* Skip if no ordinal assigned */
  673. exp = (APROPEXPPTR ) PROPSYMLOOKUP(sbExport, ATTREXP, FALSE);
  674. /* Look the export up */
  675. if(exp == PROPNIL || exp->ax_ord != 0) continue;
  676. /* Must exist and be unassigned */
  677. exp->ax_ord = ordExport; /* Assign ordinal */
  678. if (fres)
  679. exp->ax_nameflags |= RES_NAME;
  680. /* Set flag if from resident table */
  681. MARKVP(); /* Page has been changed */
  682. }
  683. }
  684. #if NOT EXE386
  685. LOCAL void NEAR SetExpOrds(void)/* Set export ordinals */
  686. {
  687. struct exe_hdr ehdr; /* Old .EXE header */
  688. struct new_exe hdr; /* New .EXE header */
  689. long lfahdr; /* File offset of header */
  690. if((bsInput = LinkOpenExe(sbOldver)) == NULL)
  691. { /* If old version can't be opened */
  692. /* Error message and return */
  693. OutWarn(ER_oldopn);
  694. return;
  695. }
  696. SETRAW(bsInput); /* Dec 20 hack */
  697. if (xread(&ehdr,CBEXEHDR,1,bsInput) != 1) /* Read old header */
  698. OutWarn(ER_oldbad);
  699. if(E_MAGIC(ehdr) == EMAGIC) /* If old header found */
  700. {
  701. if(E_LFARLC(ehdr) != sizeof(struct exe_hdr))
  702. { /* If no new .EXE in this file */
  703. /* Error message and return */
  704. OutWarn(ER_oldbad);
  705. return;
  706. }
  707. lfahdr = E_LFANEW(ehdr); /* Get file address of new header */
  708. }
  709. else lfahdr = 0L; /* Else no old header */
  710. if (fseek(bsInput,lfahdr,0)) /* Seek to new header */
  711. Fatal(ER_ioerr, strerror(errno));
  712. if (xread(&hdr,CBNEWEXE,1,bsInput) != 1) /* Read the header */
  713. OutWarn(ER_oldbad);
  714. if(NE_MAGIC(hdr) == NEMAGIC) /* If correct magic number */
  715. {
  716. ProcNamTab(lfahdr+NE_RESTAB(hdr),(WORD)(NE_MODTAB(hdr) - NE_RESTAB(hdr)),(WORD)TRUE);
  717. /* Process Resident Name table */
  718. ProcNamTab(NE_NRESTAB(hdr),NE_CBNRESTAB(hdr),FALSE);
  719. /* Process Non-resident Name table */
  720. }
  721. else OutWarn(ER_oldbad);
  722. fclose(bsInput); /* Close old file */
  723. }
  724. #endif
  725. LOCAL void NEAR NewDescription(BYTE *sbDesc)
  726. {
  727. #if NOT EXE386
  728. if (NonResidentName.byteMac > 3)
  729. Fatal(ER_dfdesc); /* Should be first time */
  730. AddName(&NonResidentName, sbDesc, 0);
  731. /* Description 1st in non-res table */
  732. #endif
  733. }
  734. #if EXE386
  735. LOCAL void NEAR NewModule(BYTE *sbModnam, BYTE *defaultExt)
  736. #else
  737. LOCAL void NEAR NewModule(BYTE *sbModnam)
  738. #endif
  739. {
  740. WORD length; /* Length of symbol */
  741. #if EXE386
  742. SBTYPE sbModule;
  743. BYTE *pName;
  744. #endif
  745. if(rhteModule != RHTENIL) Fatal(ER_dfname);
  746. /* Check for redefinition */
  747. PROPSYMLOOKUP(sbModnam, ATTRNIL, TRUE);
  748. /* Create hash table entry */
  749. rhteModule = vrhte; /* Save virtual hash table address */
  750. #if EXE386
  751. memcpy(sbModule, sbModnam, sbModnam[0] + 1);
  752. if (sbModule[sbModule[0]] == '.')
  753. {
  754. sbModule[sbModule[0]] = '\0';
  755. length = sbModule[0];
  756. pName = &sbModule[1];
  757. }
  758. else
  759. {
  760. UpdateFileParts(sbModule, defaultExt);
  761. length = sbModule[0] - 2;
  762. pName = &sbModule[4];
  763. }
  764. if (TargetOs == NE_WINDOWS)
  765. SbUcase(sbModule); /* Make upper case */
  766. vmmove(length, pName, AREAEXPNAME, TRUE);
  767. /* Module name 1st in Export Name Table */
  768. cbExpName = length;
  769. #else
  770. if (TargetOs == NE_WINDOWS)
  771. SbUcase(sbModnam); /* Make upper case */
  772. AddName(&ResidentName, sbModnam, 0);/* Module name 1st in resident table */
  773. #endif
  774. fFileNameExpected = (FTYPE) FALSE;
  775. }
  776. void NewExport(sbEntry,sbInternal,ordno,flags)
  777. BYTE *sbEntry; /* Entry name */
  778. BYTE *sbInternal; /* Internal name */
  779. WORD ordno; /* Ordinal number */
  780. WORD flags; /* Flag byte */
  781. {
  782. APROPEXPPTR export; /* Export record */
  783. APROPUNDEFPTR undef; /* Undefined symbol */
  784. APROPNAMEPTR PubName; /* Defined name */
  785. BYTE *sb; /* Internal name */
  786. BYTE ParWrds; /* # of parameter words */
  787. RBTYPE rbSymdef; /* Virtual addr of symbol definition */
  788. #if EXE386
  789. RBTYPE vExport; /* Virtual pointer to export descriptor */
  790. APROPNAMEPTR public; /* Matching public symbol */
  791. #endif
  792. #if DEBUG
  793. fprintf(stdout,"\r\nEXPORT: ");
  794. OutSb(stdout,sbEntry);
  795. NEWLINE(stdout);
  796. if(sbInternal != NULL)
  797. {
  798. fprintf(stdout,"INTERNAL NAME: ");
  799. OutSb(stdout,sbInternal);
  800. NEWLINE(stdout);
  801. }
  802. fprintf(stdout, " ordno %u, flags %u ", (unsigned)ordno, (unsigned)flags);
  803. fflush(stdout);
  804. #endif
  805. sb = (sbInternal != NULL)? sbInternal: sbEntry;
  806. /* Get pointer to internal name */
  807. PubName = (APROPNAMEPTR ) PROPSYMLOOKUP(sb, ATTRPNM, FALSE);
  808. #if NOT EXE386
  809. if(PubName != PROPNIL && !fDrivePass)
  810. /* If internal name already exists as a public symbol
  811. * and we are parsing definition file, issue
  812. * export internal name conflict warning.
  813. */
  814. OutWarn(ER_expcon,sbEntry+1,sb+1);
  815. else /* Else if no conflict */
  816. {
  817. #endif
  818. if (PubName == PROPNIL) /* If no matching name exists */
  819. undef = (APROPUNDEFPTR ) PROPSYMLOOKUP(sb,ATTRUND, TRUE);
  820. /* Make undefined symbol entry */
  821. #if TCE
  822. #if TCE_DEBUG
  823. fprintf(stdout, "\r\nNewExport adds UNDEF %s ", 1+GetPropName(undef));
  824. #endif
  825. undef->au_fAlive = TRUE; /* all exports are potential entry points */
  826. #endif
  827. rbSymdef = vrprop; /* Save virtual address */
  828. if (PubName == PROPNIL) /* If this is a new symbol */
  829. undef->au_len = -1L; /* Make no type assumptions */
  830. export = (APROPEXPPTR ) PROPSYMLOOKUP(sbEntry,ATTREXP, TRUE);
  831. /* Create export record */
  832. #if EXE386
  833. vExport = vrprop;
  834. #endif
  835. if(vfCreated) /* If this is a new entry */
  836. {
  837. export->ax_symdef = rbSymdef;
  838. /* Save virt addr of symbol def */
  839. export->ax_ord = ordno;
  840. /* Save ordinal number */
  841. if (nameFlags & RES_NAME)
  842. export->ax_nameflags |= RES_NAME;
  843. /* Remember if resident */
  844. else if (nameFlags & NO_NAME)
  845. export->ax_nameflags |= NO_NAME;
  846. /* Remember to discard name */
  847. export->ax_flags = (BYTE) flags;
  848. /* Save flags */
  849. ++expMac; /* One more exported symbol */
  850. }
  851. else
  852. {
  853. if (!fDrivePass) /* Else if parsing definition file */
  854. /* multiple definitions */
  855. OutWarn(ER_expmul,sbEntry + 1);
  856. /* Output error message */
  857. else
  858. { /* We were called for EXPDEF object */
  859. /* record, so we merge information */
  860. ParWrds = (BYTE) (export->ax_flags & 0xf8);
  861. if (ParWrds && (ParWrds != (BYTE) (flags & 0xf8)))
  862. Fatal(ER_badiopl);
  863. /* If the iopl_parmwords field in the */
  864. /* .DEF file is not 0 and does not match */
  865. /* value in the EXPDEF exactly issue error */
  866. else if (!ParWrds)
  867. { /* Else set value from EXPDEF record */
  868. ParWrds = (BYTE) (flags & 0xf8);
  869. export->ax_flags |= ParWrds;
  870. }
  871. }
  872. }
  873. #if EXE386
  874. if (PubName != NULL)
  875. {
  876. if (expOtherFlags & 0x1)
  877. {
  878. export->ax_nameflags |= CONSTANT;
  879. expOtherFlags = 0;
  880. }
  881. }
  882. #endif
  883. #if NOT EXE386
  884. }
  885. #endif
  886. if(!(flags & 0x8000))
  887. {
  888. free(sbEntry); /* Free space */
  889. if(sbInternal != NULL) free(sbInternal);
  890. }
  891. /* Free space */
  892. nameFlags = 0;
  893. }
  894. LOCAL APROPIMPPTR NEAR GetImport(sb) /* Get name in Imported Names Table */
  895. BYTE *sb; /* Length-prefixed names */
  896. {
  897. APROPIMPPTR import; /* Pointer to imported name */
  898. #if EXE386
  899. DWORD cbTemp; /* Temporary value */
  900. #else
  901. WORD cbTemp; /* Temporary value */
  902. #endif
  903. RBTYPE rprop; /* Property cell virtual address */
  904. import = (APROPIMPPTR ) PROPSYMLOOKUP(sb,ATTRIMP, TRUE);
  905. /* Look up module name */
  906. if(vfCreated) /* If no offset assigned yet */
  907. {
  908. rprop = vrprop; /* Save the virtual address */
  909. /*
  910. * WARNING: We must store name in virtual memory now, otherwise
  911. * if an EXTDEF was seen first, fIgnoreCase is false, and the
  912. * cases do not match between the imported name and the EXTDEF,
  913. * then the name will not go in the table exactly as given.
  914. */
  915. import = (APROPIMPPTR) FETCHSYM(rprop,TRUE);
  916. /* Retrieve from symbol table */
  917. import->am_offset = AddImportedName(sb);
  918. /* Save offset */
  919. }
  920. return(import); /* Return offset in table */
  921. }
  922. #if NOT EXE386
  923. void NewImport(sbEntry,ordEntry,sbModule,sbInternal)
  924. BYTE *sbEntry; /* Entry point name */
  925. WORD ordEntry; /* Entry point ordinal */
  926. BYTE *sbModule; /* Module name */
  927. BYTE *sbInternal; /* Internal name */
  928. {
  929. APROPNAMEPTR public; /* Public symbol */
  930. APROPIMPPTR import; /* Imported symbol */
  931. BYTE *sb; /* Symbol pointer */
  932. WORD module; /* Module name offset */
  933. FTYPE flags; /* Import flags */
  934. WORD modoff; /* module name offset */
  935. WORD entry; /* Entry name offset */
  936. BYTE *cp; /* Char pointer */
  937. RBTYPE rpropundef; /* Address of undefined symbol */
  938. char buf[32]; /* Buffer for error sgring */
  939. #if DEBUG
  940. fprintf(stderr,"\r\nIMPORT: ");
  941. OutSb(stderr,sbModule);
  942. fputc('.',stderr);
  943. if(!ordEntry)
  944. {
  945. OutSb(stderr,sbEntry);
  946. }
  947. else fprintf(stderr,"%u",ordEntry);
  948. if(sbInternal != sbEntry)
  949. {
  950. fprintf(stderr," ALIAS: ");
  951. OutSb(stderr,sbInternal);
  952. }
  953. fprintf(stdout," ordEntry %u ", (unsigned)ordEntry);
  954. fflush(stdout);
  955. #endif
  956. if((public = (APROPNAMEPTR ) PROPSYMLOOKUP(sbInternal, ATTRUND, FALSE)) !=
  957. PROPNIL && !fDrivePass) /* If internal names conflict */
  958. {
  959. if(sbEntry != NULL)
  960. sb = sbEntry;
  961. else
  962. {
  963. sprintf(buf + 1,"%u",ordEntry);
  964. sb = buf;
  965. }
  966. OutWarn(ER_impcon,sbModule + 1,sb + 1,sbInternal + 1);
  967. }
  968. else /* Else if no conflicts */
  969. {
  970. rpropundef = vrprop; /* Save virtual address of extern */
  971. flags = FIMPORT; /* We have an imported symbol */
  972. if (TargetOs == NE_WINDOWS)
  973. SbUcase(sbModule); /* Force module name to upper case */
  974. import = GetImport(sbModule); /* Get pointer to import record */
  975. if((module = import->am_mod) == 0)
  976. {
  977. // If not in Module Reference Table
  978. import->am_mod = WordArrayPut(&ModuleRefTable, import->am_offset) + 1;
  979. /* Save offset of name in table */
  980. module = import->am_mod;
  981. }
  982. if(vrhte == rhteModule) /* If importing from this module */
  983. {
  984. if(sbEntry != NULL)
  985. sb = sbEntry;
  986. else
  987. {
  988. sprintf(buf+1,"%u",ordEntry);
  989. sb = buf;
  990. }
  991. if (TargetOs == NE_OS2)
  992. OutWarn(ER_impself,sbModule + 1,sb + 1,sbInternal + 1);
  993. else
  994. OutError(ER_impself,sbModule + 1,sb + 1,sbInternal + 1);
  995. }
  996. if(sbEntry == NULL) /* If entry by ordinal */
  997. {
  998. flags |= FIMPORD; /* Set flag bit */
  999. entry = ordEntry; /* Get ordinal number */
  1000. }
  1001. else /* Else if import by name */
  1002. {
  1003. if(fIgnoreCase) SbUcase(sbEntry);
  1004. /* Upper case the name if flag set */
  1005. import = GetImport(sbEntry);
  1006. entry = import->am_offset;
  1007. /* Get offset of name in table */
  1008. }
  1009. if(public == PROPNIL) /* If no undefined symbol */
  1010. {
  1011. public = (APROPNAMEPTR )
  1012. PROPSYMLOOKUP(sbInternal,ATTRPNM, TRUE);
  1013. /* Make a public symbol */
  1014. if(!vfCreated) /* If not new */
  1015. /* Output error message */
  1016. OutWarn(ER_impmul,sbInternal + 1);
  1017. else ++pubMac; /* Else increment public count */
  1018. }
  1019. else /* Else if symbol is undefined */
  1020. {
  1021. public = (APROPNAMEPTR ) FETCHSYM(rpropundef,TRUE);
  1022. /* Look up external symbol */
  1023. ++pubMac; /* Increment public symbol count */
  1024. }
  1025. flags |= FPRINT; /* Symbol is printable */
  1026. public->an_attr = ATTRPNM; /* This is a public symbol */
  1027. public->an_gsn = SNNIL; /* Not a segment member */
  1028. public->an_ra = 0; /* No known offset */
  1029. public->an_ggr = GRNIL; /* Not a group member */
  1030. public->an_flags = flags; /* Set flags */
  1031. public->an_entry = entry; /* Save entry specification */
  1032. public->an_module = module; /* Save Module Reference Table index */
  1033. #if SYMDEB AND FALSE
  1034. if (fSymdeb) /* If debugger support on */
  1035. {
  1036. if (flags & FIMPORD)
  1037. import = GetImport(sbInternal);
  1038. else /* Add internal name to Imported Name Table */
  1039. import = GetImport(sbEntry);
  1040. import->am_public = public;
  1041. /* Remember public symbol */
  1042. if (cbImpSeg < LXIVK-1)
  1043. cbImpSeg += sizeof(CVIMP);
  1044. }
  1045. #endif
  1046. }
  1047. }
  1048. #endif
  1049. #if OVERLAYS
  1050. extern void NEAR GetName(AHTEPTR ahte, BYTE *pBuf);
  1051. #endif
  1052. /*** NewSeg - new segment definition
  1053. *
  1054. * Purpose:
  1055. * Create new segment definition based on the module definition
  1056. * file segment description. Check for duplicate definitions and
  1057. * overlay index inconsistency between attached COMDATs (if any)
  1058. * and segment itself.
  1059. *
  1060. * Input:
  1061. * sbName - segment name
  1062. * sbClass - segment class
  1063. * iOvl - segment overlay index
  1064. * flags - segment attributes
  1065. *
  1066. * Output:
  1067. * No explicit value is returned. The segment descriptor in
  1068. * symbol table is created or updated.
  1069. *
  1070. * Exceptions:
  1071. * Multiple segment definitions - warning and continue
  1072. * Change in overlay index - warning and continue
  1073. *
  1074. * Notes:
  1075. * None.
  1076. *
  1077. *************************************************************************/
  1078. void NEAR NewSeg(BYTE *sbName, BYTE *sbClass, WORD iOvl,
  1079. #if EXE386
  1080. DWORD flags)
  1081. #else
  1082. WORD flags)
  1083. #endif
  1084. {
  1085. APROPSNPTR apropSn; // Pointer to segment descriptor
  1086. #if OVERLAYS
  1087. RBTYPE vrComdat; // Virtual pointer to COMDAT descriptor
  1088. APROPCOMDATPTR apropComdat; // Symbol table entry for COMDAT symbol
  1089. SBTYPE sbComdat; // Name buffer
  1090. #endif
  1091. // Set segment attributes based on the class
  1092. if (SbSuffix(sbClass,"\004CODE",TRUE))
  1093. flags |= dfCode & ~offmask;
  1094. else
  1095. flags |= dfData & ~offmask;
  1096. #if O68K
  1097. if (f68k)
  1098. flags |= NS32BIT;
  1099. #endif
  1100. #if OVERLAYS
  1101. if (iOvl != NOTIOVL)
  1102. {
  1103. fOverlays = (FTYPE) TRUE;
  1104. fNewExe = FALSE;
  1105. if (iOvl >= iovMac) // Set the maximum overlay index
  1106. iovMac = iOvl + 1;
  1107. }
  1108. #endif
  1109. // Generate new segment definition
  1110. apropSn = GenSeg(sbName, sbClass, GRNIL, (FTYPE) TRUE);
  1111. if (vfCreated)
  1112. {
  1113. apropSn->as_flags = (WORD) flags;
  1114. // Save flags
  1115. mpgsndra[apropSn->as_gsn] = 0; // Initialize
  1116. #if OVERLAYS
  1117. apropSn->as_iov = iOvl; // Save overlay index
  1118. if (fOverlays)
  1119. CheckOvl(apropSn, iOvl);
  1120. #endif
  1121. apropSn->as_fExtra |= (BYTE) FROM_DEF_FILE;
  1122. // Remember defined in def file
  1123. if (fMixed)
  1124. {
  1125. apropSn->as_fExtra |= (BYTE) MIXED1632;
  1126. fMixed = (FTYPE) FALSE;
  1127. }
  1128. }
  1129. else
  1130. {
  1131. apropSn = CheckClass(apropSn, apropSn->as_rCla);
  1132. // Check if previous definition had the same class
  1133. OutWarn(ER_segdup,sbName + 1); // Warn about multiple definition
  1134. #if OVERLAYS
  1135. if (fOverlays && apropSn->as_iov != iOvl)
  1136. {
  1137. if (apropSn->as_iov != NOTIOVL)
  1138. OutWarn(ER_badsegovl, 1 + GetPropName(apropSn), apropSn->as_iov, iOvl);
  1139. apropSn->as_iov = iOvl; // Save new overlay index
  1140. CheckOvl(apropSn, iOvl);
  1141. // Check if segment has any COMDATs and if it has
  1142. // then check theirs overlay numbers
  1143. for (vrComdat = apropSn->as_ComDat;
  1144. vrComdat != VNIL;
  1145. vrComdat = apropComdat->ac_sameSeg)
  1146. {
  1147. apropComdat = (APROPCOMDATPTR ) FetchSym(vrComdat, FALSE);
  1148. if (apropComdat->ac_iOvl != NOTIOVL && apropComdat->ac_iOvl != iOvl)
  1149. {
  1150. GetName((AHTEPTR) apropComdat, sbComdat);
  1151. OutWarn(ER_badcomdatovl, &sbComdat[1], apropComdat->ac_iOvl, iOvl);
  1152. }
  1153. apropComdat->ac_iOvl = iOvl;
  1154. }
  1155. }
  1156. #endif
  1157. }
  1158. free(sbClass); // Free class name
  1159. free(sbName); // Free segment name
  1160. offmask = 0;
  1161. // Unless packing limit already set, disable default code packing
  1162. if (!fPackSet)
  1163. {
  1164. fPackSet = (FTYPE) TRUE; // Remember packLim was set
  1165. packLim = 0L;
  1166. }
  1167. }
  1168. /*
  1169. * Assign module name to be default, which is run file name.
  1170. *
  1171. * SIDE EFFECTS
  1172. * Assigns rhteModule
  1173. */
  1174. #if EXE386
  1175. LOCAL void NEAR DefaultModule (unsigned char *defaultExt)
  1176. #else
  1177. LOCAL void NEAR DefaultModule (void)
  1178. #endif
  1179. {
  1180. SBTYPE sbModname; /* Module name */
  1181. AHTEPTR ahte; /* Pointer to hash table entry */
  1182. #if OSXENIX
  1183. int i;
  1184. #endif
  1185. ahte = (AHTEPTR ) FETCHSYM(rhteRunfile,FALSE);
  1186. /* Get executable file name */
  1187. #if OSMSDOS
  1188. memcpy(sbModname,GetFarSb(ahte->cch),B2W(ahte->cch[0]) + 1);
  1189. /* Copy file name */
  1190. #if EXE386
  1191. NewModule(sbModname, defaultExt); /* Use run file name as module name */
  1192. #else
  1193. UpdateFileParts(sbModname,"\005A:\\.X");
  1194. /* Force path, ext with known length */
  1195. sbModname[0] -= 2; /* Remove extension from name */
  1196. sbModname[3] = (BYTE) (sbModname[0] - 3);
  1197. /* Remove path and drive from name */
  1198. NewModule(&sbModname[3]); /* Use run file name as module name */
  1199. #endif
  1200. #endif
  1201. #if OSXENIX
  1202. for(i = B2W(ahte->cch[0]); i > 0 && ahte->cch[i] != '/'; i--)
  1203. sbModname[0] = B2W(ahte->cch[0]) - i;
  1204. memcpy(sbModname+1,&GetFarSb(ahte->cch)[i+1],B2W(sbModname[0]));
  1205. for(i = B2W(ahte->cch[0]); i > 1 && sbModname[i] != '.'; i--);
  1206. if(i > 1)
  1207. sbModname[0] = i - 1;
  1208. NewModule(sbModname); /* Use run file name as module name */
  1209. #endif
  1210. }
  1211. void ParseDeffile(void)
  1212. {
  1213. SBTYPE sbDeffile; /* Definitions file name */
  1214. AHTEPTR ahte; /* Pointer to hash table entry */
  1215. #if OSMSDOS
  1216. char buf[512]; /* File buffer */
  1217. #endif
  1218. if(rhteDeffile == RHTENIL) /* If no definitions file */
  1219. #if EXE386
  1220. DefaultModule(moduleEXE);
  1221. #else
  1222. DefaultModule();
  1223. #endif
  1224. else /* Else if there is a file to parse */
  1225. {
  1226. #if ODOS3EXE
  1227. fNewExe = (FTYPE) TRUE; /* Def file forces new-format exe */
  1228. #endif
  1229. ahte = (AHTEPTR ) FETCHSYM(rhteDeffile,FALSE);
  1230. /* Fetch file name */
  1231. memcpy(sbDeffile,GetFarSb(ahte->cch),B2W(ahte->cch[0]) + 1);
  1232. /* Copy file name */
  1233. sbDeffile[B2W(sbDeffile[0]) + 1] = '\0';
  1234. /* Null-terminate the name */
  1235. if((bsInput = fopen(&sbDeffile[1],RDTXT)) == NULL)
  1236. { /* If open fails */
  1237. Fatal(ER_opndf, &sbDeffile[1]);/* Fatal error */
  1238. }
  1239. #if OSMSDOS
  1240. setvbuf(bsInput,buf,_IOFBF,sizeof(buf));
  1241. #endif
  1242. includeDisp[0] = bsInput; // Initialize include stack
  1243. sbOldver = NULL; /* Assume no old version */
  1244. yylineno = 1;
  1245. fFileNameExpected = (FTYPE) FALSE;
  1246. // HACK ALERT !!!
  1247. // Don't allocate to much page buffers
  1248. yyparse(); /* Parse the definitions file */
  1249. yylineno = -1;
  1250. fclose(bsInput); /* Close the definitions file */
  1251. #if NOT EXE386
  1252. if(sbOldver != NULL) /* If old version given */
  1253. {
  1254. SetExpOrds(); /* Use old version to set ordinals */
  1255. free(sbOldver); /* Release the space */
  1256. }
  1257. #endif
  1258. }
  1259. #if OSMSDOS
  1260. #endif /* OSMSDOS */
  1261. #if NOT EXE386
  1262. if (NonResidentName.byteMac == 0)
  1263. {
  1264. ahte = (AHTEPTR ) FETCHSYM(rhteRunfile,FALSE);
  1265. /* Get executable file name */
  1266. memcpy(sbDeffile,GetFarSb(ahte->cch),B2W(ahte->cch[0]) + 1);
  1267. /* Copy file name */
  1268. #if OSXENIX
  1269. SbUcase(sbDeffile); /* For identical executables */
  1270. #endif
  1271. if ((vFlags & NENOTP) && TargetOs == NE_OS2)
  1272. UpdateFileParts(sbDeffile, sbDotDll);
  1273. else
  1274. UpdateFileParts(sbDeffile, sbDotExe);
  1275. NewDescription(sbDeffile); /* Use run file name as description */
  1276. }
  1277. #endif
  1278. }
  1279. short yyexca[] ={
  1280. -1, 1,
  1281. 0, -1,
  1282. -2, 0,
  1283. };
  1284. # define YYNPROD 183
  1285. # define YYLAST 408
  1286. short yyact[]={
  1287. 10, 13, 14, 176, 27, 49, 53, 54, 129, 226,
  1288. 174, 50, 43, 44, 45, 46, 53, 54, 203, 161,
  1289. 190, 41, 209, 28, 181, 60, 177, 29, 30, 31,
  1290. 12, 32, 34, 35, 220, 221, 179, 59, 58, 192,
  1291. 41, 41, 189, 41, 41, 33, 148, 11, 206, 152,
  1292. 153, 154, 155, 156, 159, 183, 223, 61, 157, 158,
  1293. 217, 121, 119, 122, 15, 81, 120, 123, 124, 138,
  1294. 4, 5, 219, 139, 6, 7, 16, 36, 17, 42,
  1295. 37, 89, 90, 87, 74, 75, 79, 69, 82, 70,
  1296. 76, 71, 77, 80, 84, 85, 86, 83, 42, 42,
  1297. 215, 42, 42, 213, 212, 207, 196, 164, 56, 55,
  1298. 49, 53, 54, 167, 145, 222, 50, 43, 44, 45,
  1299. 46, 68, 96, 91, 92, 104, 105, 81, 199, 185,
  1300. 162, 67, 147, 166, 107, 48, 78, 72, 73, 115,
  1301. 88, 103, 102, 100, 101, 128, 74, 75, 79, 69,
  1302. 82, 70, 76, 71, 77, 80, 84, 85, 86, 83,
  1303. 95, 97, 98, 99, 94, 112, 66, 137, 8, 187,
  1304. 106, 52, 38, 184, 160, 125, 118, 126, 151, 117,
  1305. 114, 218, 225, 130, 216, 111, 40, 104, 105, 81,
  1306. 26, 134, 136, 25, 131, 24, 23, 22, 78, 72,
  1307. 73, 109, 110, 103, 102, 89, 90, 87, 74, 75,
  1308. 79, 69, 82, 70, 76, 71, 77, 80, 84, 85,
  1309. 86, 83, 108, 132, 9, 95, 127, 39, 47, 21,
  1310. 20, 140, 141, 57, 19, 18, 63, 62, 51, 3,
  1311. 64, 143, 2, 1, 143, 143, 175, 91, 92, 150,
  1312. 211, 163, 198, 197, 149, 113, 116, 205, 142, 178,
  1313. 78, 72, 73, 57, 88, 169, 204, 93, 171, 170,
  1314. 173, 172, 65, 165, 144, 0, 168, 146, 133, 135,
  1315. 0, 0, 182, 0, 0, 0, 0, 0, 0, 0,
  1316. 0, 0, 0, 0, 0, 0, 0, 201, 202, 191,
  1317. 0, 0, 193, 0, 194, 0, 195, 200, 0, 0,
  1318. 0, 0, 0, 0, 210, 0, 0, 0, 0, 0,
  1319. 201, 202, 0, 0, 0, 224, 0, 214, 0, 0,
  1320. 200, 0, 0, 0, 113, 0, 0, 116, 0, 0,
  1321. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1322. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1323. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1324. 0, 180, 0, 0, 0, 0, 0, 0, 0, 0,
  1325. 0, 0, 0, 186, 188, 0, 0, 0, 0, 0,
  1326. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1327. 0, 0, 0, 0, 208, 0, 0, 186 };
  1328. short yypact[]={
  1329. -189,-1000,-267,-267,-221,-225,-153,-154,-267,-1000,
  1330. -285,-286,-266,-1000,-1000,-1000,-1000,-222,-1000,-1000,
  1331. -1000,-1000,-1000,-1000,-1000,-1000,-1000, -68,-130,-222,
  1332. -222,-222,-222,-222,-1000,-241,-1000,-1000,-267,-326,
  1333. -334,-1000,-1000,-1000,-1000,-1000,-1000,-330,-334,-1000,
  1334. -1000,-320,-1000,-1000,-1000,-225,-225,-1000,-1000,-1000,
  1335. -1000,-1000,-197,-197,-1000, -68,-1000,-1000,-1000,-1000,
  1336. -1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
  1337. -1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
  1338. -1000,-1000,-1000,-130,-1000,-1000,-1000,-1000,-1000,-1000,
  1339. -1000,-1000,-1000,-1000,-1000,-1000,-222,-1000,-144,-222,
  1340. -222,-222,-1000,-273,-222,-1000,-273,-252,-1000,-1000,
  1341. -1000,-1000,-1000,-1000,-1000,-306,-159,-334,-148,-1000,
  1342. -334,-148,-1000,-330,-148,-330,-148,-1000,-316,-1000,
  1343. -1000,-1000,-1000,-1000,-343,-297,-1000,-284,-222,-1000,
  1344. -300,-159,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-223,
  1345. -222,-224,-1000,-304,-1000,-148,-1000,-280,-148,-1000,
  1346. -148,-1000,-148,-1000,-160,-192,-307,-1000,-265,-161,
  1347. -1000,-244,-1000,-1000,-222,-1000,-1000,-1000,-1000,-1000,
  1348. -162,-1000,-163,-1000,-1000,-1000,-1000,-1000,-192,-1000,
  1349. -1000,-1000,-1000,-166,-212,-194,-1000,-287,-216,-216,
  1350. -1000,-1000,-1000,-1000,-1000,-1000,-332,-1000,-1000,-1000,
  1351. -1000,-1000,-1000,-1000,-1000,-1000,-1000 };
  1352. short yypgo[]={
  1353. 0, 222, 132, 274, 272, 166, 267, 164, 266, 259,
  1354. 257, 253, 128, 252, 131, 122, 121, 251, 250, 246,
  1355. 115, 243, 242, 168, 239, 186, 145, 133, 135, 238,
  1356. 171, 224, 237, 167, 236, 235, 234, 230, 229, 197,
  1357. 196, 195, 193, 190, 170, 134, 185, 165, 184, 182,
  1358. 181, 180, 139, 179, 178, 130, 177, 176, 175, 174,
  1359. 173, 169, 129 };
  1360. short yyr1[]={
  1361. 0, 21, 21, 24, 21, 22, 22, 22, 22, 22,
  1362. 22, 22, 22, 28, 28, 28, 28, 29, 29, 30,
  1363. 30, 27, 27, 25, 25, 25, 25, 25, 26, 26,
  1364. 23, 23, 31, 31, 31, 31, 32, 31, 34, 31,
  1365. 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
  1366. 31, 31, 33, 33, 33, 35, 4, 4, 5, 5,
  1367. 16, 16, 16, 16, 16, 16, 36, 6, 6, 7,
  1368. 7, 7, 7, 7, 7, 7, 15, 15, 15, 15,
  1369. 37, 37, 37, 37, 37, 37, 44, 44, 45, 3,
  1370. 3, 19, 19, 12, 12, 12, 13, 13, 11, 11,
  1371. 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
  1372. 14, 14, 14, 14, 14, 14, 14, 14, 38, 38,
  1373. 46, 46, 47, 2, 2, 9, 9, 9, 9, 8,
  1374. 10, 10, 50, 50, 48, 48, 49, 49, 39, 39,
  1375. 51, 51, 52, 52, 1, 1, 20, 20, 53, 40,
  1376. 54, 54, 54, 54, 54, 54, 54, 54, 54, 55,
  1377. 55, 17, 17, 18, 18, 56, 43, 41, 57, 57,
  1378. 57, 57, 57, 57, 58, 42, 59, 59, 61, 61,
  1379. 60, 60, 62 };
  1380. short yyr2[]={
  1381. 0, 2, 1, 0, 2, 5, 4, 5, 4, 5,
  1382. 4, 5, 4, 1, 1, 1, 0, 2, 1, 1,
  1383. 1, 3, 0, 1, 1, 1, 1, 0, 1, 0,
  1384. 2, 1, 2, 2, 2, 2, 0, 3, 0, 3,
  1385. 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
  1386. 1, 1, 3, 1, 1, 2, 2, 1, 1, 1,
  1387. 1, 1, 1, 1, 1, 1, 2, 2, 1, 1,
  1388. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1389. 2, 1, 2, 1, 2, 1, 2, 1, 4, 2,
  1390. 0, 3, 0, 1, 1, 1, 2, 1, 1, 0,
  1391. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1392. 1, 1, 1, 1, 1, 1, 1, 1, 2, 1,
  1393. 2, 1, 6, 2, 0, 3, 3, 2, 0, 2,
  1394. 1, 0, 1, 0, 1, 0, 1, 0, 2, 1,
  1395. 2, 1, 5, 5, 1, 1, 1, 0, 0, 4,
  1396. 1, 1, 1, 1, 1, 1, 1, 2, 1, 3,
  1397. 1, 1, 0, 1, 0, 0, 3, 2, 1, 1,
  1398. 1, 1, 1, 1, 0, 4, 2, 0, 1, 1,
  1399. 2, 1, 1 };
  1400. short yychk[]={
  1401. -1000, -21, -22, -24, 259, 260, 263, 264, -23, -31,
  1402. 267, 314, 297, 268, 269, 331, 343, 345, -35, -36,
  1403. -37, -38, -39, -40, -41, -42, -43, 271, 290, 294,
  1404. 295, 296, 298, 312, 299, 300, 344, 347, -23, -1,
  1405. -25, 265, 323, 338, 339, 340, 341, -1, -28, 335,
  1406. 341, -29, -30, 336, 337, 262, 262, -31, 323, 323,
  1407. 291, 323, -32, -34, -1, -4, -5, -14, -16, 279,
  1408. 281, 283, 329, 330, 276, 277, 282, 284, 328, 278,
  1409. 285, 257, 280, 289, 286, 287, 288, 275, 332, 273,
  1410. 274, 315, 316, -6, -7, -14, -15, 291, 292, 293,
  1411. 273, 274, 334, 333, 317, 318, -44, -45, -1, -44,
  1412. -44, -46, -47, -1, -51, -52, -1, -53, -57, 303,
  1413. 307, 302, 304, 308, 309, -58, -56, -25, -26, 342,
  1414. -28, -26, -30, -1, -28, -1, -28, -33, 266, 270,
  1415. -33, -5, -7, -45, -3, 258, -47, -2, 319, -52,
  1416. -2, -54, 301, 302, 303, 304, 305, 310, 311, 306,
  1417. -59, 325, -55, -17, 266, -26, -27, 261, -26, -27,
  1418. -28, -27, -28, -27, 326, -19, 346, 323, -9, 320,
  1419. -1, 324, -55, 278, -60, -62, -1, -61, -1, 266,
  1420. 324, -27, 319, -27, -27, -27, 266, -11, -13, -12,
  1421. -14, -16, -15, 325, -8, -10, 313, 266, -1, 266,
  1422. -62, -18, 266, 266, -12, 266, -48, 272, -50, 266,
  1423. 321, 322, -20, 272, -20, -49, 341 };
  1424. short yydef[]={
  1425. 3, -2, 2, 0, 27, 16, 0, 0, 1, 31,
  1426. 0, 0, 0, 36, 38, 40, 41, 0, 43, 44,
  1427. 45, 46, 47, 48, 49, 50, 51, 0, 0, 81,
  1428. 83, 85, 119, 139, 148, 0, 174, 165, 4, 27,
  1429. 29, 144, 145, 23, 24, 25, 26, 16, 29, 13,
  1430. 14, 15, 18, 19, 20, 16, 16, 30, 32, 33,
  1431. 34, 35, 0, 0, 42, 55, 57, 58, 59, 100,
  1432. 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
  1433. 111, 112, 113, 114, 115, 116, 117, 60, 61, 62,
  1434. 63, 64, 65, 66, 68, 69, 70, 71, 72, 73,
  1435. 74, 75, 76, 77, 78, 79, 80, 87, 90, 82,
  1436. 84, 118, 121, 124, 138, 141, 124, 0, 167, 168,
  1437. 169, 170, 171, 172, 173, 177, 162, 29, 22, 28,
  1438. 29, 22, 17, 16, 22, 16, 22, 37, 53, 54,
  1439. 39, 56, 67, 86, 92, 0, 120, 128, 0, 140,
  1440. 0, 162, 150, 151, 152, 153, 154, 155, 156, 158,
  1441. 0, 0, 166, 160, 161, 22, 6, 0, 22, 8,
  1442. 22, 10, 22, 12, 0, 99, 0, 89, 131, 0,
  1443. 123, 0, 149, 157, 175, 181, 182, 176, 178, 179,
  1444. 164, 5, 0, 7, 9, 11, 52, 88, 98, 97,
  1445. 93, 94, 95, 0, 135, 133, 130, 127, 147, 147,
  1446. 180, 159, 163, 21, 96, 91, 137, 134, 129, 132,
  1447. 125, 126, 142, 146, 143, 122, 136 };
  1448. # define YYFLAG -1000
  1449. # define YYERROR goto yyerrlab
  1450. # define YYACCEPT return(0)
  1451. # define YYABORT return(1)
  1452. #ifdef YYDEBUG /* RRR - 10/9/85 */
  1453. #define yyprintf(a, b, c) printf(a, b, c)
  1454. #else
  1455. #define yyprintf(a, b, c)
  1456. #endif
  1457. /* parser for yacc output */
  1458. YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
  1459. int yychar = -1; /* current input token number */
  1460. int yynerrs = 0; /* number of errors */
  1461. short yyerrflag = 0; /* error recovery flag */
  1462. int NEAR yyparse(void)
  1463. {
  1464. short yys[YYMAXDEPTH];
  1465. short yyj, yym;
  1466. register YYSTYPE *yypvt;
  1467. register short yystate, *yyps, yyn;
  1468. register YYSTYPE *yypv;
  1469. register short *yyxi;
  1470. yystate = 0;
  1471. yychar = -1;
  1472. yynerrs = 0;
  1473. yyerrflag = 0;
  1474. yyps= &yys[-1];
  1475. yypv= &yyv[-1];
  1476. yystack: /* put a state and value onto the stack */
  1477. yyprintf( "state %d, char 0%o\n", yystate, yychar );
  1478. if( ++yyps> &yys[YYMAXDEPTH] )
  1479. {
  1480. yyerror( "yacc stack overflow" );
  1481. return(1);
  1482. }
  1483. *yyps = yystate;
  1484. ++yypv;
  1485. *yypv = yyval;
  1486. yynewstate:
  1487. yyn = yypact[yystate];
  1488. if( yyn<= YYFLAG ) goto yydefault; /* simple state */
  1489. if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
  1490. if( (yyn += (short)yychar)<0 || yyn >= YYLAST ) goto yydefault;
  1491. if( yychk[ yyn=yyact[ yyn ] ] == yychar )
  1492. {
  1493. /* valid shift */
  1494. yychar = -1;
  1495. yyval = yylval;
  1496. yystate = yyn;
  1497. if( yyerrflag > 0 ) --yyerrflag;
  1498. goto yystack;
  1499. }
  1500. yydefault:
  1501. /* default state action */
  1502. if( (yyn=yydef[yystate]) == -2 )
  1503. {
  1504. if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
  1505. /* look through exception table */
  1506. for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
  1507. for(yyxi+=2; *yyxi >= 0; yyxi+=2)
  1508. {
  1509. if( *yyxi == yychar ) break;
  1510. }
  1511. if( (yyn = yyxi[1]) < 0 ) return(0); /* accept */
  1512. }
  1513. if( yyn == 0 )
  1514. {
  1515. /* error */
  1516. /* error ... attempt to resume parsing */
  1517. switch( yyerrflag )
  1518. {
  1519. case 0: /* brand new error */
  1520. yyerror( "syntax error" );
  1521. ++yynerrs;
  1522. case 1:
  1523. case 2: /* incompletely recovered error ... try again */
  1524. yyerrflag = 3;
  1525. /* find a state where "error" is a legal shift action */
  1526. while ( yyps >= yys )
  1527. {
  1528. yyn = yypact[*yyps] + YYERRCODE;
  1529. if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE )
  1530. {
  1531. yystate = yyact[yyn]; /* simulate a shift of "error" */
  1532. goto yystack;
  1533. }
  1534. yyn = yypact[*yyps];
  1535. /* the current yyps has no shift onn "error", pop stack */
  1536. yyprintf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
  1537. --yyps;
  1538. --yypv;
  1539. }
  1540. /* there is no state on the stack with an error shift ... abort */
  1541. yyabort:
  1542. return(1);
  1543. case 3: /* no shift yet; clobber input char */
  1544. yyprintf( "error recovery discards char %d\n", yychar, 0 );
  1545. if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
  1546. yychar = -1;
  1547. goto yynewstate; /* try again in the same state */
  1548. }
  1549. }
  1550. /* reduction by production yyn */
  1551. yyprintf("reduce %d\n",yyn, 0);
  1552. yyps -= yyr2[yyn];
  1553. yypvt = yypv;
  1554. yypv -= yyr2[yyn];
  1555. yyval = yypv[1];
  1556. yym=yyn;
  1557. /* consult goto table to find next state */
  1558. yyn = yyr1[yyn];
  1559. yyj = yypgo[yyn] + *yyps + 1;
  1560. if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
  1561. switch(yym)
  1562. {
  1563. case 3:
  1564. {
  1565. #if EXE386
  1566. DefaultModule(moduleEXE);
  1567. #else
  1568. DefaultModule();
  1569. #endif
  1570. } break;
  1571. case 5:
  1572. {
  1573. #if EXE386
  1574. NewModule(yypvt[-3]._bp, moduleEXE);
  1575. #else
  1576. NewModule(yypvt[-3]._bp);
  1577. #endif
  1578. } break;
  1579. case 6:
  1580. {
  1581. #if EXE386
  1582. DefaultModule(moduleEXE);
  1583. #else
  1584. DefaultModule();
  1585. #endif
  1586. } break;
  1587. case 7:
  1588. {
  1589. #if EXE386
  1590. SetDLL(vFlags);
  1591. NewModule(yypvt[-3]._bp, moduleDLL);
  1592. #else
  1593. vFlags = NENOTP | (vFlags & ~NEINST) | NESOLO;
  1594. dfData |= NSSHARED;
  1595. NewModule(yypvt[-3]._bp);
  1596. #endif
  1597. } break;
  1598. case 8:
  1599. {
  1600. #if EXE386
  1601. SetDLL(vFlags);
  1602. DefaultModule(moduleDLL);
  1603. #else
  1604. vFlags = NENOTP | (vFlags & ~NEINST) | NESOLO;
  1605. dfData |= NSSHARED;
  1606. DefaultModule();
  1607. #endif
  1608. } break;
  1609. case 9:
  1610. {
  1611. #if EXE386
  1612. SetDLL(vFlags);
  1613. NewModule(yypvt[-2]._bp, moduleDLL);
  1614. #endif
  1615. } break;
  1616. case 10:
  1617. {
  1618. #if EXE386
  1619. SetDLL(vFlags);
  1620. DefaultModule(moduleDLL);
  1621. #endif
  1622. } break;
  1623. case 11:
  1624. {
  1625. #if EXE386
  1626. SetDLL(vFlags);
  1627. NewModule(yypvt[-2]._bp, moduleDLL);
  1628. #endif
  1629. } break;
  1630. case 12:
  1631. {
  1632. #if EXE386
  1633. SetDLL(vFlags);
  1634. DefaultModule(moduleDLL);
  1635. #endif
  1636. } break;
  1637. case 13:
  1638. {
  1639. #if EXE386
  1640. dllFlags &= ~E32_PROCINIT;
  1641. #else
  1642. vFlags &= ~NEPPLI;
  1643. #endif
  1644. } break;
  1645. case 14:
  1646. {
  1647. vFlags |= NEPRIVLIB;
  1648. } break;
  1649. case 19:
  1650. {
  1651. #if EXE386
  1652. SetINSTINIT(dllFlags);
  1653. #else
  1654. vFlags |= NEPPLI;
  1655. #endif
  1656. } break;
  1657. case 20:
  1658. {
  1659. #if EXE386
  1660. SetINSTTERM(dllFlags);
  1661. #endif
  1662. } break;
  1663. case 21:
  1664. {
  1665. #if EXE386
  1666. virtBase = yypvt[-0]._wd;
  1667. virtBase = RoundTo64k(virtBase);
  1668. #endif
  1669. } break;
  1670. case 22:
  1671. {
  1672. } break;
  1673. case 23:
  1674. {
  1675. #if EXE386
  1676. SetGUI(TargetSubsys);
  1677. #else
  1678. vFlags |= NEWINAPI;
  1679. #endif
  1680. } break;
  1681. case 24:
  1682. {
  1683. #if EXE386
  1684. SetGUICOMPAT(TargetSubsys);
  1685. #else
  1686. vFlags |= NEWINCOMPAT;
  1687. #endif
  1688. } break;
  1689. case 25:
  1690. {
  1691. #if EXE386
  1692. SetNOTGUI(TargetSubsys);
  1693. #else
  1694. vFlags |= NENOTWINCOMPAT;
  1695. #endif
  1696. } break;
  1697. case 26:
  1698. {
  1699. vFlags |= NEPRIVLIB;
  1700. } break;
  1701. case 27:
  1702. {
  1703. } break;
  1704. case 28:
  1705. {
  1706. #if NOT EXE386
  1707. vFlagsOthers |= NENEWFILES;
  1708. #endif
  1709. } break;
  1710. case 29:
  1711. {
  1712. } break;
  1713. case 32:
  1714. {
  1715. NewDescription(yypvt[-0]._bp);
  1716. } break;
  1717. case 33:
  1718. {
  1719. if(sbOldver == NULL) sbOldver = _strdup(bufg);
  1720. } break;
  1721. case 34:
  1722. {
  1723. if(rhteStub == RHTENIL) fStub = (FTYPE) FALSE;
  1724. } break;
  1725. case 35:
  1726. {
  1727. if(fStub && rhteStub == RHTENIL)
  1728. {
  1729. PROPSYMLOOKUP(yypvt[-0]._bp,ATTRNIL, TRUE);
  1730. rhteStub = vrhte;
  1731. }
  1732. } break;
  1733. case 36:
  1734. {
  1735. fHeapSize = (FTYPE) TRUE;
  1736. } break;
  1737. case 38:
  1738. {
  1739. fHeapSize = (FTYPE) FALSE;
  1740. } break;
  1741. case 40:
  1742. {
  1743. #if NOT EXE386
  1744. vFlags |= NEPROT;
  1745. #endif
  1746. } break;
  1747. case 41:
  1748. {
  1749. fRealMode = (FTYPE) TRUE;
  1750. vFlags &= ~NEPROT;
  1751. } break;
  1752. case 42:
  1753. {
  1754. #if NOT EXE386
  1755. AppLoader(yypvt[-0]._bp);
  1756. #endif
  1757. } break;
  1758. case 52:
  1759. {
  1760. if (fHeapSize)
  1761. {
  1762. cbHeap = yypvt[-2]._wd;
  1763. #if EXE386
  1764. cbHeapCommit = yypvt[-0]._wd;
  1765. #endif
  1766. }
  1767. else
  1768. {
  1769. if(cbStack)
  1770. OutWarn(ER_stackdb, yypvt[-2]._wd);
  1771. cbStack = yypvt[-2]._wd;
  1772. #if EXE386
  1773. cbStackCommit = yypvt[-0]._wd;
  1774. #endif
  1775. }
  1776. } break;
  1777. case 53:
  1778. {
  1779. if (fHeapSize)
  1780. {
  1781. cbHeap = yypvt[-0]._wd;
  1782. #if EXE386
  1783. cbHeapCommit = cbHeap;
  1784. #endif
  1785. }
  1786. else
  1787. {
  1788. if(cbStack)
  1789. OutWarn(ER_stackdb, yypvt[-0]._wd);
  1790. cbStack = yypvt[-0]._wd;
  1791. #if EXE386
  1792. cbStackCommit = cbStack;
  1793. #endif
  1794. }
  1795. } break;
  1796. case 54:
  1797. {
  1798. if (fHeapSize)
  1799. fHeapMax = (FTYPE) TRUE;
  1800. } break;
  1801. case 55:
  1802. {
  1803. // Set dfCode to specified flags; for any unspecified attributes
  1804. // use the defaults. Then reset offmask.
  1805. dfCode = yypvt[-0]._wd | (dfCode & ~offmask);
  1806. offmask = 0;
  1807. vfShrattr = (FTYPE) FALSE; /* Reset for DATA */
  1808. } break;
  1809. case 56:
  1810. {
  1811. yyval._wd |= yypvt[-0]._wd;
  1812. } break;
  1813. case 60:
  1814. {
  1815. #if EXE386
  1816. yyval._wd = OBJ_EXEC;
  1817. #else
  1818. yyval._wd = NSEXRD;
  1819. #endif
  1820. } break;
  1821. case 62:
  1822. {
  1823. #if EXE386
  1824. offmask |= OBJ_RESIDENT;
  1825. #else
  1826. yyval._wd = NSDISCARD | NSMOVE;
  1827. #endif
  1828. } break;
  1829. case 63:
  1830. {
  1831. #if EXE386
  1832. #else
  1833. offmask |= NSDISCARD;
  1834. #endif
  1835. } break;
  1836. case 64:
  1837. {
  1838. #if EXE386
  1839. #else
  1840. yyval._wd = NSCONFORM;
  1841. #endif
  1842. } break;
  1843. case 65:
  1844. {
  1845. #if EXE386
  1846. #else
  1847. offmask |= NSCONFORM;
  1848. #endif
  1849. } break;
  1850. case 66:
  1851. {
  1852. // Set dfData to specified flags; for any unspecified
  1853. // attribute use the defaults. Then reset offmask.
  1854. #if EXE386
  1855. dfData = (yypvt[-0]._wd | (dfData & ~offmask));
  1856. #else
  1857. dfData = yypvt[-0]._wd | (dfData & ~offmask);
  1858. #endif
  1859. offmask = 0;
  1860. #if NOT EXE386
  1861. if (vfShrattr && !vfAutodata)
  1862. {
  1863. // If share-attribute and no autodata attribute, share-
  1864. // attribute controls autodata.
  1865. if (yypvt[-0]._wd & NSSHARED)
  1866. vFlags = (vFlags & ~NEINST) | NESOLO;
  1867. else
  1868. vFlags = (vFlags & ~NESOLO) | NEINST;
  1869. }
  1870. else if(!vfShrattr)
  1871. {
  1872. // Else if no share-attribute, autodata attribute
  1873. // controls share-attribute.
  1874. if (vFlags & NESOLO)
  1875. dfData |= NSSHARED;
  1876. else if(vFlags & NEINST)
  1877. dfData &= ~NSSHARED;
  1878. }
  1879. #endif
  1880. } break;
  1881. case 67:
  1882. {
  1883. yyval._wd |= yypvt[-0]._wd;
  1884. } break;
  1885. case 71:
  1886. {
  1887. #if NOT EXE386
  1888. vFlags &= ~(NESOLO | NEINST);
  1889. #endif
  1890. } break;
  1891. case 72:
  1892. {
  1893. #if NOT EXE386
  1894. vFlags = (vFlags & ~NEINST) | NESOLO;
  1895. #endif
  1896. vfAutodata = (FTYPE) TRUE;
  1897. } break;
  1898. case 73:
  1899. {
  1900. #if NOT EXE386
  1901. vFlags = (vFlags & ~NESOLO) | NEINST;
  1902. #endif
  1903. vfAutodata = (FTYPE) TRUE;
  1904. } break;
  1905. case 74:
  1906. {
  1907. #if NOT EXE386
  1908. // This ONLY for compatibility with JDA IBM LINK
  1909. yyval._wd = NSDISCARD | NSMOVE;
  1910. #endif
  1911. } break;
  1912. case 75:
  1913. {
  1914. #if NOT EXE386
  1915. // This ONLY for compatibility with JDA IBM LINK
  1916. offmask |= NSDISCARD;
  1917. #endif
  1918. } break;
  1919. case 76:
  1920. {
  1921. #if EXE386
  1922. yyval._wd = OBJ_READ;
  1923. offmask |= OBJ_WRITE;
  1924. #else
  1925. yyval._wd = NSEXRD;
  1926. #endif
  1927. } break;
  1928. case 78:
  1929. {
  1930. #if FALSE AND NOT EXE386
  1931. yyval._wd = NSEXPDOWN;
  1932. #endif
  1933. } break;
  1934. case 79:
  1935. {
  1936. #if FALSE AND NOT EXE386
  1937. offmask |= NSEXPDOWN;
  1938. #endif
  1939. } break;
  1940. case 88:
  1941. {
  1942. NewSeg(yypvt[-3]._bp, yypvt[-2]._bp, yypvt[-1]._wd, yypvt[-0]._wd);
  1943. } break;
  1944. case 89:
  1945. {
  1946. yyval._bp = _strdup(yypvt[-0]._bp);
  1947. } break;
  1948. case 90:
  1949. {
  1950. yyval._bp = _strdup("\004CODE");
  1951. } break;
  1952. case 91:
  1953. {
  1954. yyval._wd = yypvt[-0]._wd;
  1955. } break;
  1956. case 92:
  1957. {
  1958. #if OVERLAYS
  1959. yyval._wd = NOTIOVL;
  1960. #endif
  1961. } break;
  1962. case 96:
  1963. {
  1964. yyval._wd |= yypvt[-0]._wd;
  1965. } break;
  1966. case 98:
  1967. {
  1968. yyval._wd = yypvt[-0]._wd;
  1969. } break;
  1970. case 99:
  1971. {
  1972. yyval._wd = 0;
  1973. } break;
  1974. case 100:
  1975. {
  1976. #if EXE386
  1977. yyval._wd = OBJ_SHARED;
  1978. #else
  1979. yyval._wd = NSSHARED;
  1980. #endif
  1981. vfShrattr = (FTYPE) TRUE;
  1982. } break;
  1983. case 101:
  1984. {
  1985. vfShrattr = (FTYPE) TRUE;
  1986. #if EXE386
  1987. offmask |= OBJ_SHARED;
  1988. #else
  1989. offmask |= NSSHARED;
  1990. #endif
  1991. } break;
  1992. case 102:
  1993. {
  1994. #if EXE386
  1995. #endif
  1996. } break;
  1997. case 103:
  1998. {
  1999. #if EXE386
  2000. #else
  2001. yyval._wd = (2 << SHIFTDPL) | NSMOVE;
  2002. offmask |= NSDPL;
  2003. #endif
  2004. } break;
  2005. case 104:
  2006. {
  2007. #if EXE386
  2008. #else
  2009. yyval._wd = (3 << SHIFTDPL);
  2010. #endif
  2011. } break;
  2012. case 105:
  2013. {
  2014. #if NOT EXE386
  2015. offmask |= NSMOVE | NSDISCARD;
  2016. #endif
  2017. } break;
  2018. case 106:
  2019. {
  2020. #if NOT EXE386
  2021. yyval._wd = NSMOVE;
  2022. #endif
  2023. } break;
  2024. case 107:
  2025. {
  2026. #if NOT EXE386
  2027. yyval._wd = NSPRELOAD;
  2028. #endif
  2029. } break;
  2030. case 108:
  2031. {
  2032. #if NOT EXE386
  2033. offmask |= NSPRELOAD;
  2034. #endif
  2035. } break;
  2036. case 109:
  2037. {
  2038. } break;
  2039. case 110:
  2040. {
  2041. } break;
  2042. case 111:
  2043. {
  2044. } break;
  2045. case 112:
  2046. {
  2047. } break;
  2048. case 113:
  2049. {
  2050. } break;
  2051. case 114:
  2052. {
  2053. } break;
  2054. case 115:
  2055. {
  2056. } break;
  2057. case 116:
  2058. {
  2059. } break;
  2060. case 117:
  2061. {
  2062. } break;
  2063. case 122:
  2064. {
  2065. NewExport(yypvt[-5]._bp,yypvt[-4]._bp,yypvt[-3]._wd,yypvt[-2]._wd);
  2066. } break;
  2067. case 123:
  2068. {
  2069. yyval._bp = yypvt[-0]._bp;
  2070. } break;
  2071. case 124:
  2072. {
  2073. yyval._bp = NULL;
  2074. } break;
  2075. case 125:
  2076. {
  2077. yyval._wd = yypvt[-1]._wd;
  2078. nameFlags |= RES_NAME;
  2079. } break;
  2080. case 126:
  2081. {
  2082. yyval._wd = yypvt[-1]._wd;
  2083. nameFlags |= NO_NAME;
  2084. } break;
  2085. case 127:
  2086. {
  2087. yyval._wd = yypvt[-0]._wd;
  2088. } break;
  2089. case 128:
  2090. {
  2091. yyval._wd = 0;
  2092. } break;
  2093. case 129:
  2094. {
  2095. yyval._wd = yypvt[-1]._wd | 1;
  2096. } break;
  2097. case 130:
  2098. {
  2099. /* return 0 */
  2100. } break;
  2101. case 131:
  2102. {
  2103. yyval._wd = 2;
  2104. } break;
  2105. case 132:
  2106. {
  2107. } break;
  2108. case 133:
  2109. {
  2110. } break;
  2111. case 134:
  2112. {
  2113. #if EXE386
  2114. expOtherFlags |= 0x1;
  2115. #endif
  2116. } break;
  2117. case 135:
  2118. {
  2119. } break;
  2120. case 142:
  2121. {
  2122. if(yypvt[-3]._bp != NULL)
  2123. {
  2124. #if EXE386
  2125. NewImport(yypvt[-1]._bp,0,yypvt[-3]._bp,yypvt[-4]._bp,yypvt[-0]._wd);
  2126. #else
  2127. NewImport(yypvt[-1]._bp,0,yypvt[-3]._bp,yypvt[-4]._bp);
  2128. #endif
  2129. free(yypvt[-3]._bp);
  2130. }
  2131. else
  2132. #if EXE386
  2133. NewImport(yypvt[-1]._bp,0,yypvt[-4]._bp,yypvt[-1]._bp,yypvt[-0]._wd);
  2134. #else
  2135. NewImport(yypvt[-1]._bp,0,yypvt[-4]._bp,yypvt[-1]._bp);
  2136. #endif
  2137. free(yypvt[-4]._bp);
  2138. free(yypvt[-1]._bp);
  2139. } break;
  2140. case 143:
  2141. {
  2142. if (yypvt[-3]._bp == NULL)
  2143. Fatal(ER_dfimport);
  2144. #if EXE386
  2145. NewImport(NULL,yypvt[-1]._wd,yypvt[-3]._bp,yypvt[-4]._bp,yypvt[-0]._wd);
  2146. #else
  2147. NewImport(NULL,yypvt[-1]._wd,yypvt[-3]._bp,yypvt[-4]._bp);
  2148. #endif
  2149. free(yypvt[-4]._bp);
  2150. free(yypvt[-3]._bp);
  2151. } break;
  2152. case 144:
  2153. {
  2154. yyval._bp = _strdup(bufg);
  2155. } break;
  2156. case 145:
  2157. {
  2158. yyval._bp = _strdup(bufg);
  2159. } break;
  2160. case 146:
  2161. {
  2162. yyval._wd = 1;
  2163. } break;
  2164. case 147:
  2165. {
  2166. yyval._wd = 0;
  2167. } break;
  2168. case 148:
  2169. {
  2170. #if EXE386
  2171. fUserVersion = (FTYPE) FALSE;
  2172. #endif
  2173. } break;
  2174. case 150:
  2175. {
  2176. TargetOs = NE_DOS;
  2177. #if ODOS3EXE
  2178. fNewExe = FALSE;
  2179. #endif
  2180. } break;
  2181. case 151:
  2182. {
  2183. TargetOs = NE_OS2;
  2184. } break;
  2185. case 152:
  2186. {
  2187. TargetOs = NE_UNKNOWN;
  2188. } break;
  2189. case 153:
  2190. {
  2191. #if EXE386
  2192. TargetSubsys = E32_SSWINGUI;
  2193. #endif
  2194. TargetOs = NE_WINDOWS;// PROTMODE is default for WINDOWS
  2195. fRealMode = (FTYPE) FALSE;
  2196. #if NOT EXE386
  2197. vFlags |= NEPROT;
  2198. #endif
  2199. } break;
  2200. case 154:
  2201. {
  2202. TargetOs = NE_DEV386;
  2203. } break;
  2204. case 155:
  2205. {
  2206. #if EXE386
  2207. TargetSubsys = E32_SSWINGUI;
  2208. #endif
  2209. } break;
  2210. case 156:
  2211. {
  2212. #if EXE386
  2213. TargetSubsys = E32_SSPOSIXCHAR;
  2214. #endif
  2215. } break;
  2216. case 157:
  2217. {
  2218. #if O68K
  2219. iMacType = MAC_SWAP;
  2220. f68k = fTBigEndian = fNewExe = (FTYPE) TRUE;
  2221. /* If we are packing code to the default value, change the
  2222. default. */
  2223. if (fPackSet && packLim == LXIVK - 36)
  2224. packLim = LXIVK / 2;
  2225. #endif
  2226. } break;
  2227. case 158:
  2228. {
  2229. #if O68K
  2230. iMacType = MAC_NOSWAP;
  2231. f68k = fTBigEndian = fNewExe = (FTYPE) TRUE;
  2232. /* If we are packing code to the default value, change the
  2233. default. */
  2234. if (fPackSet && packLim == LXIVK - 36)
  2235. packLim = LXIVK / 2;
  2236. #endif
  2237. } break;
  2238. case 159:
  2239. {
  2240. #if EXE386
  2241. if (fUserVersion)
  2242. {
  2243. UserMajorVer = (BYTE) yypvt[-2]._wd;
  2244. UserMinorVer = (BYTE) yypvt[-0]._wd;
  2245. }
  2246. else
  2247. #endif
  2248. {
  2249. ExeMajorVer = (BYTE) yypvt[-2]._wd;
  2250. ExeMinorVer = (BYTE) yypvt[-0]._wd;
  2251. }
  2252. } break;
  2253. case 160:
  2254. {
  2255. #if EXE386
  2256. if (fUserVersion)
  2257. {
  2258. UserMajorVer = (BYTE) yypvt[-0]._wd;
  2259. UserMinorVer = 0;
  2260. }
  2261. else
  2262. #endif
  2263. {
  2264. ExeMajorVer = (BYTE) yypvt[-0]._wd;
  2265. if(fNoExeVer)
  2266. ExeMinorVer = DEF_EXETYPE_WINDOWS_MINOR;
  2267. else
  2268. ExeMinorVer = 0;
  2269. }
  2270. } break;
  2271. case 161:
  2272. {
  2273. yyval._wd = yypvt[-0]._wd;
  2274. } break;
  2275. case 162:
  2276. {
  2277. yyval._wd = ExeMajorVer;
  2278. fNoExeVer = TRUE;
  2279. } break;
  2280. case 163:
  2281. {
  2282. if (cDigits >= 2)
  2283. yyval._wd = yypvt[-0]._wd;
  2284. else
  2285. yyval._wd = 10 * yypvt[-0]._wd;
  2286. } break;
  2287. case 164:
  2288. {
  2289. yyval._wd = ExeMinorVer;
  2290. } break;
  2291. case 165:
  2292. {
  2293. #if EXE386
  2294. fUserVersion = (FTYPE) TRUE;
  2295. #endif
  2296. } break;
  2297. case 168:
  2298. {
  2299. #if EXE386
  2300. TargetSubsys = E32_SSUNKNOWN;
  2301. #endif
  2302. } break;
  2303. case 169:
  2304. {
  2305. #if EXE386
  2306. TargetSubsys = E32_SSNATIVE;
  2307. #endif
  2308. } break;
  2309. case 170:
  2310. {
  2311. #if EXE386
  2312. TargetSubsys = E32_SSOS2CHAR;
  2313. #endif
  2314. } break;
  2315. case 171:
  2316. {
  2317. #if EXE386
  2318. TargetSubsys = E32_SSWINGUI;
  2319. #endif
  2320. } break;
  2321. case 172:
  2322. {
  2323. #if EXE386
  2324. TargetSubsys = E32_SSWINCHAR;
  2325. #endif
  2326. } break;
  2327. case 173:
  2328. {
  2329. #if EXE386
  2330. TargetSubsys = E32_SSPOSIXCHAR;
  2331. #endif
  2332. } break;
  2333. case 174:
  2334. {
  2335. if (szSegName != NULL)
  2336. {
  2337. free(szSegName);
  2338. szSegName = NULL;
  2339. }
  2340. #if OVERLAYS
  2341. iOvl = NOTIOVL;
  2342. #endif
  2343. } break;
  2344. case 178:
  2345. {
  2346. if (szSegName == NULL)
  2347. szSegName = yypvt[-0]._bp;
  2348. #if OVERLAYS
  2349. iOvl = NOTIOVL;
  2350. #endif
  2351. } break;
  2352. case 179:
  2353. {
  2354. #if OVERLAYS
  2355. iOvl = yypvt[-0]._wd;
  2356. fOverlays = (FTYPE) TRUE;
  2357. fNewExe = FALSE;
  2358. TargetOs = NE_DOS;
  2359. #endif
  2360. } break;
  2361. case 182:
  2362. {
  2363. NewProc(yypvt[-0]._bp);
  2364. } break;/* End of actions */
  2365. }
  2366. goto yystack; /* stack new state and value */
  2367. }