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.

905 lines
37 KiB

  1. /* SCCSID = %W% %E% */
  2. /*
  3. * Copyright Microsoft Corporation, 1983-1987
  4. *
  5. * This Module contains Proprietary Information of Microsoft
  6. * Corporation and should be treated as Confidential.
  7. *
  8. * bndtrn.h:
  9. *
  10. * Constant definitions:
  11. */
  12. /*
  13. * Aligment types
  14. */
  15. #define ALGNNIL 0 /* Unaligned LSEG */
  16. #define ALGNABS 0 /* Absolute LSEG */
  17. #define ALGNBYT 1 /* Byte-aligned LSEG */
  18. #define ALGNWRD 2 /* Word-aligned LSEG */
  19. #define ALGNDBL 5 /* Double-word aligned LSEG */
  20. #define ALGNPAR 3 /* Paragraph-aligned LSEG */
  21. #define ALGNPAG 4 /* Page-aligned LSEG */
  22. /*
  23. * Symbol attributes types
  24. */
  25. #define ATTRNIL 0 /* Nil attribute */
  26. #define ATTRPSN 1 /* Public segment attribute */
  27. #define ATTRLSN 2 /* Local segment attribute */
  28. #define ATTRPNM 3 /* Public name attribute */
  29. #define ATTRLNM 4 /* Local name attribute */
  30. #define ATTRFIL 5 /* File name attribute */
  31. #define ATTRGRP 6 /* Group name attribute */
  32. #define ATTRUND 7 /* Undefined symbol attribute */
  33. #define ATTRSKIPLIB 8 /* Default library name to skip */
  34. #define ATTRCOMDAT 9 /* Named data block - COMDAT */
  35. #define ATTRALIAS 10 /* Alias name attribute */
  36. #define ATTREXP 11 /* Exported name attribute */
  37. #define ATTRIMP 12 /* Imported name attribute */
  38. #define ATTRMAX 13 /* Highest attribute no. plus 1 */
  39. /*
  40. * LINK limits
  41. */
  42. #define BIGBIT 2 /* Big bit in ACBP byte */
  43. #define BNDABS 0xFE /* Bundle of absolute entries */
  44. #define BNDMAX 255 /* Maximum entries per bundle */
  45. #define BNDMOV 0xFF /* Bundle of movable entries */
  46. #define BNDNIL 0 /* Null bundle */
  47. #define CBELMAX 0xffff /* Max COMDEF elem. length in bytes */
  48. #if EXE386
  49. #define CBMAXSEG32 (0xffffffffL) /* Maximum 32-bit segment size under OS/2 */
  50. #else
  51. #define CBMAXSEG32 (1L<<LG2SEG32) /* Maximum 32-bit segment size under DOS = 32Mb */
  52. #endif
  53. #if CPUVAX OR CPU68K
  54. #define CBMAXSYMSRES 0x8000L /* 32K resident symbol table */
  55. #else
  56. #define CBMAXSYMSRES 0x3000 /* 12K resident symbol table */
  57. #endif
  58. #define CBRLC 4 /* Bytes in old .EXE reloc record */
  59. #if OSXENIX
  60. #define CHPATH '/' /* Path delimiter */
  61. #else
  62. #define CHPATH '\\' /* Path delimiter */
  63. #endif
  64. #define CODE386BIT 1 /* 386 code segment in ACBP byte */
  65. #define COMBCOM 6 /* Combine as common */
  66. #define COMBPUB 2 /* Combine as public */
  67. #define COMBSTK 5 /* Combine as stack */
  68. #define CSLOTMAX 37 /* No. of buckets on dictionary page */
  69. #define DATAMAX 1024 /* Max. bytes data in LEDATA record */
  70. #define DFGSNMAX 128 /* Default 128 segments maximum */
  71. #define DFINTNO 0x3F /* Default interrupt number */
  72. #define OVLTHUNKSIZE 6 /* Thunk size for dynamic overlays */
  73. #define THUNKNIL ((WORD)-1) /* NO thunk assigned */
  74. #if EXE386
  75. #define DFPGALIGN 12 /* Default object page alignment shift */
  76. #define DFOBJALIGN 16 /* Default memory object alignment shift */
  77. #endif
  78. #define DFSAALIGN 9 /* Default segment alignment shift */
  79. #define EXPMAX 0xfffe /* Max. number of exported entries */
  80. #define EXTMAX 2048 /* Max. no. of EXTDEFs per module */
  81. #define FHNIL ((char) 0xFF) /* Nil library number */
  82. #define FSTARTADDRESS 0x40 /* Fixdat byte field mask */
  83. #define GGRMAX 32 /* Max. no. of GRPDEFs */
  84. #define GRMAX 32 /* Max. no. of GRPDEFs per module */
  85. #define GRNIL 0 /* Nil group number */
  86. #if EXE386 /* Absolute max. no. of segments */
  87. #define GSNMAX (0xffdf/sizeof(RATYPE))
  88. #else
  89. #define GSNMAX (0xffdf/sizeof(RATYPE))
  90. #endif
  91. #define HEPLEN 241 /* Entry point hash table length */
  92. #define HTDELTA 17 /* Hash delta for htgsnosn[] */
  93. #define IFHLIBMAX 130 /* Max. no. of libraries + 2*/
  94. #define IMAX 1024 /* Max. of SNMAX, GRMAX, and EXTMAX */
  95. #define INDIR '@' /* Indirect file char */
  96. #define INIL 0xFFFF /* Nil index (generic) */
  97. #if OVERLAYS
  98. #define IOVMAX OSNMAX /* Max. no. of overlays */
  99. #else
  100. #define IOVMAX 1 /* Max. no. of overlays */
  101. #endif
  102. #define IOVROOT 0 /* Root overlay number */
  103. #define NOTIOVL 0xffff // Overlay index not specified
  104. #define LBUFSIZ 32768 /* Size of main I/O buffer */
  105. #define LG2OSN 11 /* Log2 OSNMAX */
  106. #define LG2Q 15 /* Log2 QUANTUM */
  107. #if EXE386
  108. #define LG2SEG32 32 /* Log2 max 32-bit seg size under OS/2 */
  109. #else
  110. #define LG2SEG32 25 /* Log2 max 32-bit seg size under DOS */
  111. #endif
  112. #define LNAMEMAX 255 /* Maximum LNAME length */
  113. #define LXIVK (0x10000L) /* 64K */
  114. #define MEGABYTE (0x100000L) /* 1024k = 1048576 bytes */
  115. #define LG2PAG 9 // 2^9 = 512
  116. #define PAGLEN (1U << LG2PAG)
  117. #define MASKRB 0x1FF
  118. #define MASKTYSNCOMBINE 034
  119. #define OSNMAX 0x800 /* Maximum number +1 of overlay segs*/
  120. #define PARAPRVSEG 0x60 /* Paragraph-aligned private seg */
  121. #define DWORDPRVSEG 0xa0 /* DWORD-aligned private seg */
  122. #define PARAPUBSEG 0x68 /* Paragraph-aligned public segment */
  123. #define DWORDPUBSEG 0xa8 /* DWORD-aligned public segment */
  124. #define PROPNIL (PROPTYPE)0 /* Nil pointer */
  125. #define QUANTUM (1U<<LG2Q) /* Block size for lib dict., VM mgr */
  126. #if BIGSYM
  127. #define RBMAX (1L<<20) /* 1 + largest symtab pointer */
  128. #else
  129. #define RBMAX LXIVK /* 1 + largest symtab pointer */
  130. #endif
  131. #define RECTNIL 0 /* Nil record type */
  132. #define RHTENIL (RBTYPE)0 /* Nil pointer */
  133. #define RLCMAX 4 /* Maximum no. of thread definitions */
  134. #define SAMAX 256 /* Max. no. of physical segments */
  135. #define SANIL 0 /* The null file segment */
  136. #define SEGNIL 0 /* Nil segment number */
  137. #define SHPNTOPAR 5 /* Log(2) of page/para */
  138. #define SNMAX 255 /* Max. no. of SEGDEFs per module */
  139. #define SNNIL 0 /* Nil SEGDEF number */
  140. #define SYMSCALE 4 /* Symbol table address scale factor */
  141. #define SYMMAX 2048 /* Max. no. of symbols */
  142. #define STKSIZ 0x2000 /* 8K stack needed */
  143. #define TYPEFAR 0x61 /* Far communal variable */
  144. #define TYPENEAR 0x62 /* Near communal variable */
  145. #define TYPMAX 256 /* Max. no. of TYPDEFs */
  146. #define TYSNABS '\0'
  147. #define TYSNSTACK '\024'
  148. #define TYSNCOMMON '\030'
  149. #define VFPNIL 0 /* Null hash bucket number */
  150. #define BKTLNK 0 /* Offset of link word */
  151. #define BKTCNT 1 /* Offset of count word */
  152. #define BKTMAX ((WORD) 65535) /* Maximum number of buckets */
  153. #define VEPNIL 0 /* Nil virtual entry point offset */
  154. #define VNIL 0L /* Virtual nil pointer */
  155. /*
  156. * Module flags
  157. */
  158. #define FNEWOMF 0x01 /* Set if mod. has MS OMF extensions */
  159. #define FPRETYPES 0x02 /* Set if COMMENT A0 subtype 07 was found */
  160. #define DEF_EXETYPE_WINDOWS_MAJOR 3 /* Default version of windows */
  161. #define DEF_EXETYPE_WINDOWS_MINOR 10
  162. /*
  163. * Segment flags
  164. */
  165. #define FCODE 0x1 /* Set if the segment is a code seg */
  166. #define FNOTEMPTY 0x2 /* Set if the segment is not empty */
  167. #define FHUGE 0x4 /* Huge data segment attribute flag */
  168. #define FCODE386 0x8 /* 386 code segment */
  169. /*
  170. * OMF Record types:
  171. */
  172. #define BLKDEF 0x7A /* Block definition record */
  173. #define THEADR 0x80 /* Module header record */
  174. #define LHEADR 0x82 /* Module header record */
  175. #define COMENT 0x88 /* COMmENT record */
  176. #define MODEND 0x8A /* MODule END record */
  177. #define EXTDEF 0x8C /* EXTernal DEFinition record */
  178. #define TYPDEF 0x8E /* TYPe DEFinition record */
  179. #define PUBDEF 0x90 /* PUBlic DEFinition record */
  180. #define LINNUM 0x94 /* LINe NUMbers record */
  181. #define LNAMES 0x96 /* LNAMES record */
  182. #define SEGDEF 0x98 /* SEGment DEFinition record */
  183. #define GRPDEF 0x9A /* GRouP DEFinition record */
  184. #define FIXUPP 0x9C /* Fixup record */
  185. #define LEDATA 0xA0 /* Logical Enumerated DATA record */
  186. #define LIDATA 0xA2 /* Logical Iterated DATA record */
  187. #define COMDEF 0xB0 /* COMmunal DEFinition record */
  188. #define BAKPAT 0xB2 /* BAcKPATch record */
  189. #define LEXTDEF 0xB4 /* Local EXTDEF */
  190. #define LPUBDEF 0xB6 /* Local PUBDEF */
  191. #define LCOMDEF 0xB8 /* Local COMDEF */
  192. #define CEXTDEF 0xbc /* COMDAT EXTDEF */
  193. #define COMDAT 0xc2 /* COMDAT - MS OMF Extension */
  194. #define LINSYM 0xc4 /* Line numbers for COMDAT */
  195. #define ALIAS 0xc6 /* ALIAS record */
  196. #define NBAKPAT 0xc8 /* BAKPAT for COMDAT */
  197. #define LLNAMES 0xca /* Local LNAME */
  198. #define LIBHDR 0xF0 /* Library header record type */
  199. #define DICHDR 0xF1 /* Dictionary header type (F1H) */
  200. #if OMF386
  201. #define IsBadRec(r) (r < 0x6E || r > 0xca)
  202. #else
  203. #define IsBadRec(r) (r < 0x6E || r > 0xca || (r & 1) != 0)
  204. #endif
  205. #if _MSC_VER < 700
  206. #define __cdecl _cdecl
  207. #endif
  208. /*
  209. * Version-specific constants
  210. */
  211. #if OIAPX286
  212. #define DFSTBIAS 0x3F /* Default bias of seg. table ref.s */
  213. #endif
  214. #if LIBMSDOS
  215. #define sbPascalLib "\012PASCAL.LIB"
  216. /* Pascal library name as SBTYPE */
  217. #endif
  218. #if LIBXENIX
  219. #define MAGICARCHIVE 0177545 /* Magic number for archive */
  220. #define ARHEADLEN 26 /* Length of archive header */
  221. #define ARDICTLEN (2 + ARHEADLEN) /* Length of archive dictionary */
  222. #define ARDICTLOC (2 + ARDICTLEN) /* Offset of archive dictionary */
  223. /* Note: Fields in the following struct definition are defined as
  224. * byte arrays for generality. On the DEC20, for instance, a byte,
  225. * and a word and a long all use 36 bits; on the 8086, the corresponding
  226. * numbers are 8, 16, and 32 bits. It is a shame to have to define
  227. * the record in such a fashion, but since there is no "standard,"
  228. * that's the way it goes.
  229. */
  230. typedef struct
  231. {
  232. BYTE arName[14]; /* Archive name */
  233. BYTE arDate[4]; /* Archive date */
  234. BYTE arUid; /* User I.D. */
  235. BYTE arGid; /* Group I.D. */
  236. BYTE arMode[2]; /* Mode */
  237. BYTE arLen[4]; /* Length of archive */
  238. }
  239. ARHEADTYPE; /* Archive header type */
  240. #endif
  241. typedef BYTE ALIGNTYPE;
  242. typedef WORD AREATYPE;
  243. typedef BYTE ATTRTYPE;
  244. typedef BYTE FIXUTYPE;
  245. typedef BYTE FTYPE;
  246. typedef BYTE GRTYPE;
  247. typedef BYTE FAR *HTETYPE;
  248. typedef WORD IOVTYPE;
  249. typedef BYTE KINDTYPE;
  250. typedef WORD LNAMETYPE; /* LNAME index */
  251. typedef void FAR *PROPTYPE;
  252. #if EXE386 OR OMF386
  253. typedef DWORD RATYPE;
  254. #else
  255. typedef WORD RATYPE;
  256. #endif
  257. #if NEWSYM
  258. typedef BYTE FAR *RBTYPE;
  259. #else
  260. #if BIGSYM
  261. typedef long RBTYPE;
  262. #else
  263. typedef WORD RBTYPE;
  264. #endif
  265. #endif
  266. typedef WORD RECTTYPE;
  267. typedef WORD SATYPE;
  268. typedef WORD SEGTYPE;
  269. typedef WORD SNTYPE;
  270. typedef BYTE TYSNTYPE;
  271. #if MSGMOD
  272. typedef WORD MSGTYPE;
  273. #else
  274. typedef char *MSGTYPE;
  275. #endif
  276. typedef struct _SYMBOLUSELIST
  277. {
  278. int cEntries; /* # of entries on the list */
  279. int cMaxEntries; /* max # of entries on the list */
  280. RBTYPE *pEntries;
  281. } SYMBOLUSELIST;
  282. typedef struct _AHTETYPE /* Attribute hash table entry */
  283. {
  284. RBTYPE rhteNext; /* Virt addr of next entry */
  285. ATTRTYPE attr; /* Attribute */
  286. RBTYPE rprop; /* Virt addr of property list */
  287. WORD hashval; /* Hash value */
  288. BYTE cch[1]; /* Length-prefixed symbol */
  289. }
  290. AHTETYPE;
  291. typedef struct _APROPTYPE /* Property sheet */
  292. {
  293. RBTYPE a_next; /* Link to next entry */
  294. ATTRTYPE a_attr; /* Attribute */
  295. BYTE a_rgb[1]; /* Rest of record */
  296. }
  297. APROPTYPE;
  298. typedef struct _APROPEXPTYPE
  299. {
  300. RBTYPE ax_next; /* Next item in property list */
  301. ATTRTYPE ax_attr; /* Property cell type */
  302. RBTYPE ax_symdef; /* Pointer to PUBDEF or EXTDEF */
  303. WORD ax_ord; /* Export ordinal */
  304. SATYPE ax_sa; /* Segment number */
  305. RATYPE ax_ra; /* Offset in segment */
  306. BYTE ax_nameflags; /* Resident name/no name flag */
  307. BYTE ax_flags; /* Flag byte information */
  308. RBTYPE ax_NextOrd; /* Next item in export list */
  309. }
  310. APROPEXPTYPE; /* Exported name type */
  311. #if OSEGEXE
  312. /*
  313. * Format of ax_nameflags - flags used internaly by linker
  314. *
  315. * 7 6 5 4 3 2 1 0 - bit no
  316. * | | | |
  317. * | | | +-- resident name
  318. * | | +---- discard name after processing
  319. * | +------ forwarder
  320. * +-------- constant export
  321. */
  322. #define RES_NAME 0x01
  323. #define NO_NAME 0x02
  324. #define FORWARDER_NAME 0x04
  325. #define CONSTANT 0x08
  326. #endif
  327. typedef struct _CONTRIBUTOR
  328. {
  329. struct _CONTRIBUTOR FAR *next; /* Next on list */
  330. DWORD len; /* Size of contribution */
  331. DWORD offset; /* Offset in logical segment */
  332. RBTYPE file; /* OBJ file descriptor */
  333. }
  334. CONTRIBUTOR;
  335. typedef struct _APROPSNTYPE
  336. {
  337. RBTYPE as_next; /* Next item in property list */
  338. ATTRTYPE as_attr; /* Attribute */
  339. #if OSEGEXE
  340. BYTE as_fExtra; /* Extra linker ONLY flags */
  341. #endif
  342. DWORD as_cbMx; /* Size of segment */
  343. DWORD as_cbPv; /* Size of previous segment */
  344. SNTYPE as_gsn; /* Global SEGDEF number */
  345. GRTYPE as_ggr; /* Global GRPDEF number */
  346. #if OVERLAYS
  347. IOVTYPE as_iov; /* Segment's overlay number */
  348. #endif
  349. RBTYPE as_rCla; /* Pointer to segment class symbol */
  350. WORD as_key; /* Segment definition key */
  351. #if OSEGEXE
  352. #if EXE386
  353. DWORD as_flags;
  354. #else
  355. WORD as_flags;
  356. #endif
  357. #else
  358. BYTE as_flags;
  359. #endif
  360. BYTE as_tysn; /* Segment's combine-type */
  361. CONTRIBUTOR FAR *as_CHead; /* Head of contributing .OBJ files list */
  362. CONTRIBUTOR FAR *as_CTail; /* Tail of contributing .OBJ files list */
  363. RBTYPE as_ComDat; /* Head of list of COMDATs allocated in this segment */
  364. RBTYPE as_ComDatLast; /* Tail of list of COMDATs allocated in this segment */
  365. }
  366. APROPSNTYPE; /* SEGDEF property cell */
  367. #if OSEGEXE
  368. /*
  369. * Format of as_fExtra - flags used internaly by linker
  370. *
  371. * 7 6 5 4 3 2 1 0 - bit no
  372. * | | | |
  373. * | | | +-- segment defined in the .DEF file
  374. * | | +---- mixing use16 and use32 allowed
  375. * | +------ don't pad this segment for /INCREMENTAL
  376. * +-------- COMDAT_SEGx created by the linker
  377. */
  378. #define FROM_DEF_FILE 0x01
  379. #define MIXED1632 0x02
  380. #define NOPAD 0x04
  381. #define COMDAT_SEG 0x08
  382. #endif
  383. typedef struct _APROPNAMETYPE
  384. {
  385. RBTYPE an_next;
  386. ATTRTYPE an_attr;
  387. RBTYPE an_sameMod; // Next PUBDEF from the same obj file
  388. WORD an_CVtype; // CodeView type index
  389. // Have to be in the order as in
  390. // struct _APROPUNDEFTYPE
  391. GRTYPE an_ggr;
  392. #if NEWLIST
  393. RBTYPE an_rbNxt;
  394. #endif
  395. SNTYPE an_gsn;
  396. RATYPE an_ra;
  397. #if OVERLAYS
  398. RATYPE an_thunk; // Thunk offset - used by /DYNAMIC or EXE386
  399. #endif
  400. #if OSEGEXE
  401. #if EXE386
  402. RBTYPE an_nextImp; /* Next import on the list */
  403. DWORD an_thunk; /* Address of the thunk */
  404. DWORD an_name; /* Imported procedure name offset */
  405. DWORD an_entry; /* Entry name offset or ordinal */
  406. DWORD an_iatEntry; /* Value stored in the Import Address Table */
  407. WORD an_module; /* Module directory entry index */
  408. WORD an_flags; /* Flags */
  409. #else
  410. WORD an_entry; /* Entry name offset or ordinal */
  411. WORD an_module; /* Module name offset */
  412. BYTE an_flags; /* Flags for various attributes */
  413. #endif /* also used for imod if !(an_flags&FIMPORT) */
  414. #endif
  415. }
  416. APROPNAMETYPE;
  417. /*
  418. * Format of an_flags
  419. *
  420. * NOTE: 16-bit version is used only by link386
  421. *
  422. * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - bit no.
  423. * | | | | | | | | | | |
  424. * | | | | | | | | | | +-- public is an import
  425. * | | | | | | | | | +---- import by ordinal
  426. * | | | | | | | | +------ public identifier is printable
  427. * | | | | | +-+-+-------- floating-point special symbol type
  428. * | | | | +-------------- secondary floating-point special symbol
  429. * | | | +---------------- unreferenced public symbol
  430. * | | +------------------ 16-bit reference to imported symbol
  431. * | +-------------------- 32-bit reference to imported symbol
  432. * +---------------------- importing DATA symbol
  433. */
  434. #define FIMPORT 0x01 /* Set if the public is an import */
  435. #define FIMPORD 0x02 /* Set if the import ib by ordinal */
  436. #define FPRINT 0x04 /* Set if public is printable */
  437. #define FUNREF 0x80 /* Set if public is not referenced */
  438. #define FFPMASK 0x38 /* Floating-point symbol mask */
  439. #define FFPSHIFT 3 /* Shift constant to get to FFPMASK */
  440. #define FFP2ND 0x40 /* Secondary f.p. symbol (FJxRQQ) */
  441. #if EXE386
  442. #define REF16 0x100 // 16-bit reference to imported symbol
  443. #define REF32 0x200 // 32-bit reference to imported symbol
  444. #define IMPDATA 0x400 // importing DATA symbol
  445. #endif
  446. typedef struct _APROPIMPTYPE
  447. {
  448. RBTYPE am_next; /* Next property cell on list */
  449. ATTRTYPE am_attr; /* Property cell type */
  450. #if EXE386
  451. DWORD am_offset; /* Offset in imported names table */
  452. #else
  453. WORD am_offset; /* Offset in imported names table */
  454. #endif
  455. WORD am_mod; /* Index into Module Reference Table */
  456. #if SYMDEB
  457. APROPNAMETYPE FAR *am_public; /* Pointer to matching public symbol */
  458. #endif
  459. }
  460. APROPIMPTYPE; /* Imported name record */
  461. typedef struct _APROPCOMDAT
  462. {
  463. RBTYPE ac_next; /* Next property cell on list */
  464. ATTRTYPE ac_attr; /* Property cell type */
  465. GRTYPE ac_ggr; /* Global group index */
  466. SNTYPE ac_gsn; /* Global segment index */
  467. RATYPE ac_ra; /* Offset relative from COMDAT symbol */
  468. DWORD ac_size; /* Size of data block */
  469. WORD ac_flags; /* Low byte - COMDAT flags */
  470. /* High byte - linker exclusive flags */
  471. #if OVERLAYS
  472. IOVTYPE ac_iOvl; /* Overlay number where comdat has to be allocated */
  473. #endif
  474. BYTE ac_selAlloc; /* Selection/Allocation criteria */
  475. BYTE ac_align; /* COMDAT aligment if different from segment aligment */
  476. DWORD ac_data; /* Data block check sum */
  477. RBTYPE ac_obj; /* Object file */
  478. long ac_objLfa; /* Offset in the object file */
  479. RBTYPE ac_concat; /* Concatenation data blocks */
  480. RBTYPE ac_sameSeg; /* Next COMDAT in the same segment */
  481. RBTYPE ac_sameFile; /* Next COMDAT from the same object file */
  482. RBTYPE ac_order; /* Next COMDAT on the ordered list */
  483. RBTYPE ac_pubSym; /* PUBDEF for this COMDAT */
  484. #if TCE
  485. SYMBOLUSELIST ac_uses; /* List of referenced functions */
  486. int ac_fAlive; /* The result of TCE, TRUE if this COMDAT is needed
  487. /* in the final memory image */
  488. #endif
  489. }
  490. APROPCOMDAT;
  491. /*
  492. * Format of ac_flags:
  493. *
  494. * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - bit no
  495. * | | | | | | | | | |
  496. * | | | | | | | | | +-- continuation bit
  497. * | | | | | | | | +---- iterated data bit
  498. * | | | | | | | +------ COMDAT symbol has local scope
  499. * | | | | | | +-------- allocate in the root when doing overlays
  500. * | | | | | +------------------ COMDAT for ordered procedure
  501. * | | | | +-------------------- definition of ordered COMDAT found among .OBJ files
  502. * | | | +---------------------- anonymus allocation completed
  503. * | | +------------------------- referenced COMDAT
  504. * | +---------------------------- selected copy of COMDAT
  505. * +------------------------------- skip continuation records
  506. */
  507. #define CONCAT_BIT 0x01
  508. #define ITER_BIT 0x02
  509. #define LOCAL_BIT 0x04
  510. #define VTABLE_BIT 0x08
  511. #define ORDER_BIT 0x10
  512. #define DEFINED_BIT 0x20
  513. #define ALLOCATED_BIT 0x40
  514. #define REFERENCED_BIT 0x80
  515. #define SELECTED_BIT 0x100
  516. #define SKIP_BIT 0x200
  517. /*
  518. * Format of ac_selAlloc:
  519. *
  520. * 7 6 5 4 3 2 1 0 - bit no
  521. * | | | | | | | |
  522. * | | | | +-+-+-+-- allocation criteria
  523. * +-+-+-+---------- selection criteria
  524. */
  525. #define SELECTION_MASK 0xf0
  526. #define ALLOCATION_MASK 0x0f
  527. #define ONLY_ONCE 0x00
  528. #define PICK_FIRST 0x10
  529. #define SAME_SIZE 0x20
  530. #define EXACT 0x30
  531. #define EXPLICIT 0x00
  532. #define CODE16 0x01
  533. #define DATA16 0x02
  534. #define CODE32 0x03
  535. #define DATA32 0x04
  536. #define ALLOC_UNKNOWN 0x05
  537. typedef struct _APROPALIAS
  538. {
  539. RBTYPE al_next; // Next property cell on list
  540. ATTRTYPE al_attr; // Property cell type
  541. RBTYPE al_sameMod; // Next ALIAS/PUBDEF from the same obj file
  542. RBTYPE al_sym; // Substitute symbol
  543. }
  544. APROPALIAS;
  545. #if SYMDEB
  546. typedef struct _CVCODE
  547. {
  548. struct _CVCODE FAR *next; // Next code segment
  549. RATYPE cb; // Length of code segment
  550. SEGTYPE seg; // Logical segment index
  551. RATYPE ra; // Offset in the logical code segment
  552. }
  553. CVCODE; // Code segment descriptor for CV
  554. typedef struct _CVINFO
  555. {
  556. DWORD cv_cbTyp; // Length of $$TYPES
  557. BYTE FAR *cv_typ; // $$TYPES
  558. DWORD cv_cbSym; // Length of $$SYMBOLS
  559. BYTE FAR *cv_sym; // $$SYMBOLS
  560. }
  561. CVINFO;
  562. #endif
  563. typedef struct _APROPFILETYPE
  564. {
  565. RBTYPE af_next; /* Next in chain */
  566. ATTRTYPE af_attr; /* Attribute number */
  567. IOVTYPE af_iov; /* Overlay number */
  568. RBTYPE af_FNxt; /* Next file in list */
  569. long af_lfa; /* Starting address in file */
  570. RBTYPE af_rMod; /* Pointer to module name symbol */
  571. BYTE af_flags; /* Info about module */
  572. #if SYMDEB
  573. CVINFO FAR *af_cvInfo; // CodeView information
  574. WORD af_cCodeSeg; // Number of code segments
  575. struct _CVCODE FAR *af_Code; // List of code segments
  576. struct _CVCODE FAR *af_CodeLast; // Tail of the list of code segments
  577. RBTYPE af_publics; // List of public symbols
  578. struct _CVSRC FAR *af_Src; // List of source lines
  579. struct _CVSRC FAR *af_SrcLast; // Tail of the list of source lines
  580. #endif
  581. RBTYPE af_ComDat; /* First COMDAT picked from this object module */
  582. RBTYPE af_ComDatLast; /* Last on the list */
  583. #if ILINK
  584. WORD af_cont; /* count of contributions */
  585. WORD af_ientOnt; /* first index of ENTONTTYPEs */
  586. WORD af_imod; /* module index */
  587. #define IMODNIL ((WORD) 0)
  588. #endif
  589. char af_ifh; /* Library number */
  590. #if NEWIO
  591. char af_fh; /* File handle */
  592. #endif
  593. }
  594. APROPFILETYPE; /* File property cell */
  595. #if SYMDEB
  596. typedef struct _GSNINFO
  597. {
  598. SNTYPE gsn; // Global contribution index
  599. RATYPE comdatRa; // COMDAT offset
  600. DWORD comdatSize; // COMDAT size
  601. WORD comdatAlign; // COMDAT alignment
  602. WORD fComdat; // TRUE if COMDAT gsn
  603. }
  604. GSNINFO;
  605. #if FALSE
  606. typedef struct _CVIMP
  607. {
  608. WORD iMod; /* Index to Module Reference Table */
  609. #if EXE386
  610. DWORD iName; /* Index to Imported Name Table */
  611. #else
  612. WORD iName; /* Index to Imported Name Table */
  613. #endif
  614. char far *address; /* Address of import */
  615. }
  616. CVIMP; /* Import descriptor for CV */
  617. #endif
  618. #endif
  619. typedef struct _APROPGROUPTYPE
  620. {
  621. RBTYPE ag_next; /* Next in chain */
  622. ATTRTYPE ag_attr; /* Attribute */
  623. BYTE ag_ggr; /* Global GRPDEF number */
  624. }
  625. APROPGROUPTYPE; /* GRPDEF property cell */
  626. typedef struct _PLTYPE /* Property list type */
  627. {
  628. struct _PLTYPE FAR *pl_next; /* Link to next in chain */
  629. RBTYPE pl_rprop; /* Symbol table pointer */
  630. }
  631. PLTYPE;
  632. typedef struct _APROPUNDEFTYPE
  633. {
  634. RBTYPE au_next; /* Next in chain */
  635. ATTRTYPE au_attr; /* Attribute */
  636. RBTYPE au_sameMod; // Next COMDEF from the same obj file
  637. WORD au_CVtype; // CodeView type index
  638. // Have to be in the same order as in
  639. // struct _APROPNAMETYPE
  640. ATTRTYPE au_flags; /* Flags */
  641. RBTYPE au_Default; /* Default resolution for weak externs */
  642. union
  643. {
  644. /* The union of these fields assumes that au_fFil is only used
  645. * for a list of references to an unresolved external. Au_module
  646. * is used for COMDEFs, which are always resolved.
  647. */
  648. WORD au_module; /* Module index */
  649. PLTYPE FAR *au_rFil; /* List of file references */
  650. } u;
  651. long au_len; /* Length of object */
  652. WORD au_cbEl; /* Size of an element in bytes */
  653. #if TCE
  654. int au_fAlive; /* Set is referenced from non-COMDAT record */
  655. #endif
  656. }
  657. APROPUNDEFTYPE; /* Undefined symbol property cell */
  658. /*
  659. * Format of au_flags
  660. *
  661. * 7 6 5 4 3 2 1 0 - bit no
  662. * | | | | | |
  663. * | | | | | +--- C communal
  664. * | | | | +----- weak external - au_Default valid
  665. * | | | +------- undecided yet
  666. * | | +--------- strong external - au_Default invalid
  667. * | +----------- aliased external - au_Default point to ALIAS record
  668. * +------------- search library for aliased external
  669. */
  670. #define COMMUNAL 0x01 /* C communal */
  671. #define WEAKEXT 0x02 /* Weak external - use default resolution */
  672. #define UNDECIDED 0x04 /* Undecided yet but don't throw away default resolution */
  673. #define STRONGEXT 0x08 /* Strong external - don't use default resolution */
  674. #define SUBSTITUTE 0x10 /* Aliased external - use au_Dafault to find ALIAS */
  675. #define SEARCH_LIB 0x20 /* Search library for aliased external */
  676. typedef struct _EPTYPE /* Entry point type */
  677. {
  678. struct _EPTYPE FAR *ep_next; /* Link to next in chain */
  679. WORD ep_sa; /* Segment containing entry point */
  680. DWORD ep_ra; /* Offset of entry point */
  681. WORD ep_ord; /* Entry Table ordinal */
  682. }
  683. EPTYPE;
  684. #define CBHTE (sizeof(AHTETYPE))
  685. #define CBPROPSN (sizeof(APROPSNTYPE))
  686. #define CBPROPNAME (sizeof(APROPNAMETYPE))
  687. #define CBPROPFILE (sizeof(APROPFILETYPE))
  688. #define CBPROPGROUP (sizeof(APROPGROUPTYPE))
  689. #define CBPROPUNDEF (sizeof(APROPUNDEFTYPE))
  690. #define CBPROPEXP (sizeof(APROPEXPTYPE))
  691. #define CBPROPIMP (sizeof(APROPIMPTYPE))
  692. #define CBPROPCOMDAT (sizeof(APROPCOMDAT))
  693. #define CBPROPALIAS (sizeof(APROPALIAS))
  694. #define UPPER(b) (b >= 'a' && b <= 'z'? b - 'a' + 'A': b)
  695. /* Upper casing macro */
  696. #if OSMSDOS
  697. #define sbDotDef "\004.def" /* Definitions file extension */
  698. #define sbDotCom "\004.com" /* COM file extension */
  699. #define sbDotExe "\004.exe" /* EXE file extension */
  700. #define sbDotLib "\004.lib" /* Library file extension */
  701. #define sbDotMap "\004.map" /* Map file extension */
  702. #define sbDotObj "\004.obj" /* Object file extension */
  703. #define sbDotDll "\004.dll" /* Dynlink file extension */
  704. #define sbDotQlb "\004.qlb" /* Quick library extension */
  705. #define sbDotDbg "\004.dbg" /* Cv info for .COM */
  706. #if EXE386
  707. #define sbFlat "\004FLAT" /* Pseudo-group name */
  708. #endif
  709. #endif
  710. #if OSXENIX
  711. #define sbDotDef "\004.def" /* Definitions file extension */
  712. #define sbDotExe "\004.exe" /* EXE file extension */
  713. #define sbDotCom "\004.com" /* COM file extension */
  714. #define sbDotLib "\004.lib" /* Library file extension */
  715. #define sbDotMap "\004.map" /* Map file extension */
  716. #define sbDotObj "\004.obj" /* Object file extension */
  717. #define sbDotDll "\004.dll" /* Dynlink file extension */
  718. #define sbDotQlb "\004.qlb" /* Quick library extension */
  719. #endif
  720. #if M_WORDSWAP AND NOT M_BYTESWAP
  721. #define CBEXEHDR sizeof(struct exe_hdr)
  722. #define CBLONG sizeof(long)
  723. #define CBNEWEXE sizeof(struct new_exe)
  724. #define CBNEWRLC sizeof(struct new_rlc)
  725. #define CBNEWSEG sizeof(struct new_seg)
  726. #define CBWORD sizeof(WORD)
  727. #else
  728. #define CBEXEHDR _cbexehdr
  729. #define CBLONG _cblong
  730. #define CBNEWEXE _cbnewexe
  731. #define CBNEWRLC _cbnewrlc
  732. #define CBNEWSEG _cbnewseg
  733. #define CBWORD _cbword
  734. extern char _cbexehdr[];
  735. extern char _cblong[];
  736. extern char _cbnewexe[];
  737. extern char _cbnewrlc[];
  738. extern char _cbnewseg[];
  739. extern char _cbword[];
  740. #endif
  741. /*
  742. * Structure to represent floating-point symbols, i.e. FIxRQQ, FJxRQQ
  743. * pairs.
  744. */
  745. struct fpsym
  746. {
  747. BYTE *sb; /* Primary symbol, length-prefixed */
  748. BYTE *sb2; /* Secondary symbol, length-prefixed */
  749. };
  750. #if ECS
  751. extern BYTE fLeadByte[0x80];
  752. #define IsLeadByte(b) ((unsigned char)(b) >= 0x80 && \
  753. fLeadByte[(unsigned char)(b)-0x80])
  754. #endif
  755. #ifdef _MBCS
  756. #define IsLeadByte(b) _ismbblead(b)
  757. #endif
  758. #if OSEGEXE
  759. #if EXE386
  760. #define RELOCATION struct le_rlc
  761. typedef struct le_rlc *RLCPTR;
  762. #define IsIOPL(f) (FALSE) /* Check if IOPL bit set */
  763. #define Is32BIT(f) (TRUE) /* Check if 32-bit segment */
  764. #define Is16BIT(f) (!Is32BIT(f)) /* Check if 16-bit segment */
  765. #define IsDataFlg(f) (((f) & OBJ_CODE) == 0)
  766. #define IsCodeFlg(f) (((f) & OBJ_CODE) != 0)
  767. #define RoundTo64k(x) (((x) + 0xffffL) & ~0xffffL)
  768. #else
  769. #define RELOCATION struct new_rlc
  770. typedef struct new_rlc FAR *RLCPTR;
  771. #define IsIOPL(f) (((f) & NSDPL) == (2 << SHIFTDPL))
  772. /* Check if IOPL bit set */
  773. #define Is32BIT(f) (((f) & NS32BIT) != 0)
  774. /* Check if 32-bit code segment */
  775. #define IsDataFlg(x) (((x) & NSTYPE) == NSDATA)
  776. #define IsCodeFlg(x) (((x) & NSTYPE) == NSCODE)
  777. #define IsConforming(x) (((x) & NSCONFORM) != 0)
  778. #define NonConfIOPL(x) (!IsConforming(x) && IsIOPL(x))
  779. #endif
  780. #define HASH_SIZE 128
  781. #define BUCKET_DEF 4
  782. typedef struct _RLCBUCKET
  783. {
  784. WORD count; // Number of relocations in the bucket
  785. WORD countMax; // Allocated size
  786. RLCPTR rgRlc; // Run-time relocations
  787. }
  788. RLCBUCKET;
  789. typedef struct _RLCHASH // Hash vector for run-time relocations
  790. {
  791. WORD count; // Number of relocations
  792. RLCBUCKET FAR *hash[HASH_SIZE]; // Hash vector
  793. }
  794. RLCHASH;
  795. # if ODOS3EXE
  796. extern FTYPE fNewExe;
  797. # else
  798. #define fNewExe TRUE
  799. # endif
  800. # endif
  801. #if NOT OSEGEXE
  802. #define fNewExe FALSE
  803. #define dfData 0
  804. #define dfCode FCODE
  805. #define IsCodeFlg(x) ((x & FCODE) != 0)
  806. #define IsDataFlg(x) ((x & FCODE) == 0)
  807. #endif /* NOT OSEGEXE */
  808. /*
  809. * TYPEOF = macro to get basic record type of records which may have
  810. * a 386 extension. Used for LEDATA, LIDATA, and FIXUPP.
  811. */
  812. #if OMF386
  813. #define TYPEOF(r) (r&~1)
  814. #else
  815. #define TYPEOF(r) r
  816. #endif
  817. typedef AHTETYPE FAR *AHTEPTR;
  818. typedef APROPTYPE FAR *APROPPTR;
  819. typedef APROPEXPTYPE FAR *APROPEXPPTR;
  820. typedef APROPSNTYPE FAR *APROPSNPTR;
  821. typedef APROPNAMETYPE FAR *APROPNAMEPTR;
  822. typedef APROPIMPTYPE FAR *APROPIMPPTR;
  823. typedef APROPFILETYPE FAR *APROPFILEPTR;
  824. typedef APROPGROUPTYPE FAR *APROPGROUPPTR;
  825. typedef APROPUNDEFTYPE FAR *APROPUNDEFPTR;
  826. typedef APROPCOMDAT FAR *APROPCOMDATPTR;
  827. typedef APROPALIAS FAR *APROPALIASPTR;
  828. #ifdef O68K
  829. #define MAC_NONE 0 /* Not a Macintosh exe */
  830. #define MAC_NOSWAP 1 /* Not a swappable Macintosh exe */
  831. #define MAC_SWAP 2 /* Swappable Macintosh exe */
  832. #endif