Windows NT 4.0 source code leak
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.

127 lines
3.7 KiB

4 years ago
  1. /***********************************************************************
  2. * Microsoft (R) 32-Bit Incremental Linker
  3. *
  4. * Copyright (C) Microsoft Corp 1992-1996. All rights reserved.
  5. *
  6. * File: tce.h
  7. *
  8. * File Comments:
  9. *
  10. * Data structures and API for Transitive Comdat Elimination (TCE).
  11. *
  12. ***********************************************************************/
  13. #ifndef __TCE_H__
  14. #define __TCE_H__
  15. // contribution colour 'referenced' - make sure
  16. // ntimage.h doesn't define this bit in the section
  17. // characteristics field of a COFF section
  18. #define TCE_Referenced 0x00002000
  19. typedef struct NOD { // Node in TCE graph
  20. WORD iedg; // Current adjacent node to allocate
  21. WORD cedg; // Count of EDGs in TCE graph
  22. struct EDG *rgedg; // Array of edges
  23. struct NOD *pnodNext; // Pointer to overflow NOD with mode EDGs
  24. PCON pconNext; // Next CON in adjacency list
  25. char *sz; // name of comdat... may be screwed for section
  26. } NOD, *PNOD;
  27. typedef struct EDG { // Symbolic edge in graph
  28. // UNDONE: The Sym union is only used when pcon == NULL.
  29. // UNDONE: All three of these fields can be in a union.
  30. PCON pcon; // CON to resolve edge with
  31. union {
  32. DWORD isym; // index of sym in symtab (used to find sz)
  33. PEXTERNAL pext; // symbol to resolve edge with
  34. } Sym;
  35. union {
  36. BOOL fFromNative; // Determines whether NEP should be colored
  37. PCON pconPcodeNEP; // CON where native entry point lives
  38. } NEPInfo;
  39. } EDG, *PEDG;
  40. #define TCE_con 0x1
  41. #define TCE_ext 0x2
  42. #define TCE_sz 0x3
  43. typedef struct ENT { // Entry point to graph
  44. union { // discriminated by e
  45. PEXTERNAL pext; // external for entry point to graph (TCE_ext)
  46. PCON pcon; // contributor (might not have an ext) (TCE_con)
  47. const char *sz; // might be a name from command line (TCE_sz)
  48. };
  49. struct ENT *pentNext;
  50. WORD e;
  51. } ENT, *PENT, **PPENT;
  52. typedef struct ENM_NOD { // enumerate a TCE adjacency list NODs
  53. ENM_BASE enm_base;
  54. PCON pcon;
  55. PNOD pnod;
  56. PCON pconStart;
  57. } ENM_NOD, *PENM_NOD;
  58. typedef struct ENM_EDG { // enumerate a TCE edge list of EDGs
  59. ENM_BASE enm_base;
  60. WORD iedg;
  61. PEDG pedg;
  62. PNOD pnod;
  63. } ENM_EDG, *PENM_EDG;
  64. typedef struct ENM_ENT { // enumerate a TCE graph entry point list of ENTs
  65. ENM_BASE enm_base;
  66. PENT pent;
  67. PENT pentStart;
  68. } ENM_ENT, *PENM_ENT;
  69. // data structure manipulators
  70. VOID Init_TCE(VOID);
  71. VOID Cleanup_TCE(VOID);
  72. VOID CreateGraph_TCE(PST);
  73. VOID DisplayDiscardedPcon(PCON, PNOD);
  74. BOOL FDiscardPCON_TCE(PCON);
  75. PNOD PnodPcon(PCON);
  76. VOID ProcessRelocForTCE(PIMAGE, PCON, PIMAGE_SYMBOL, PIMAGE_RELOCATION);
  77. VOID Verbose_TCE(VOID);
  78. VOID WalkGraphEntryPoints_TCE(PENT, PST);
  79. // data structure constructors
  80. VOID InitNodPcon(PCON, const char *, BOOL);
  81. VOID InitNodPmod(PMOD);
  82. VOID MakeEdgePextFromISym(PMOD);
  83. PEDG PedgNew_TCE(DWORD, PCON, PCON);
  84. PENT PentNew_TCE(const char *, PEXTERNAL, PCON, PPENT);
  85. // data structure enumerator initializers
  86. VOID InitEnmNod(PENM_NOD, PCON);
  87. VOID InitEnmEdg(PENM_EDG, PNOD);
  88. VOID InitEnmEnt(PENM_ENT, PENT);
  89. // data structure enumerator next element extractors
  90. BOOL FNextEnmNod(PENM_NOD);
  91. BOOL FNextEnmEdg(PENM_EDG);
  92. BOOL FNextEnmEnt(PENM_ENT);
  93. // data structure enumerator terminators
  94. VOID EndEnmNod(PENM_NOD);
  95. VOID EndEnmEdg(PENM_EDG);
  96. VOID EndEnmEnt(PENM_ENT);
  97. // dumpers
  98. VOID DumpPNOD_TCE(PCON, PNOD);
  99. VOID DumpGraph_TCE(VOID);
  100. VOID DumpPEDG_TCE(PEDG);
  101. // pcode support (mac)
  102. VOID StorepconPcodeNEP(PEDG, PCON);
  103. // graph root
  104. extern PCON pconHeadGraph;
  105. extern PENT pentHeadImage;
  106. #endif // __TCE_H__