coffconsts.pp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2008 by Giulio Bernardi
  4. Constants used by COFF resource reader and writer
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$IFNDEF FPC_DOTTEDUNITS}
  12. unit coffconsts;
  13. {$ENDIF FPC_DOTTEDUNITS}
  14. {$MODE OBJFPC}
  15. interface
  16. //Machine types
  17. const
  18. IMAGE_FILE_MACHINE_UNKNOWN = 0;
  19. IMAGE_FILE_MACHINE_I386 = $014c; // Intel 386.
  20. {
  21. IMAGE_FILE_MACHINE_R3000 = $0162; // MIPS little-endian, 0x160 big-endian
  22. IMAGE_FILE_MACHINE_R4000 = $0166; // MIPS little-endian
  23. IMAGE_FILE_MACHINE_R10000 = $0168; // MIPS little-endian
  24. IMAGE_FILE_MACHINE_WCEMIPSV2 = $0169; // MIPS little-endian WCE v2
  25. IMAGE_FILE_MACHINE_ALPHA = $0184; // Alpha_AXP
  26. IMAGE_FILE_MACHINE_SH3 = $01a2; // SH3 little-endian
  27. IMAGE_FILE_MACHINE_SH3DSP = $01a3;
  28. IMAGE_FILE_MACHINE_SH3E = $01a4; // SH3E little-endian
  29. IMAGE_FILE_MACHINE_SH4 = $01a6; // SH4 little-endian
  30. IMAGE_FILE_MACHINE_SH5 = $01a8; // SH5
  31. }
  32. IMAGE_FILE_MACHINE_ARM = $01c0; // ARM Little-Endian
  33. {
  34. IMAGE_FILE_MACHINE_THUMB = $01c2;
  35. IMAGE_FILE_MACHINE_AM33 = $01d3;
  36. }
  37. IMAGE_FILE_MACHINE_POWERPC32_AIX = $01DF; // IBM AIX 32 bit PowerPC
  38. IMAGE_FILE_MACHINE_POWERPC64_AIX = $01EF; // IBM AIX 62 bit PowerPC
  39. {
  40. IMAGE_FILE_MACHINE_POWERPC = $01F0; // IBM PowerPC Little-Endian
  41. IMAGE_FILE_MACHINE_POWERPCFP = $01f1;
  42. IMAGE_FILE_MACHINE_IA64 = $0200; // Intel 64
  43. IMAGE_FILE_MACHINE_MIPS16 = $0266; // MIPS
  44. IMAGE_FILE_MACHINE_ALPHA64 = $0284; // ALPHA64
  45. IMAGE_FILE_MACHINE_MIPSFPU = $0366; // MIPS
  46. IMAGE_FILE_MACHINE_MIPSFPU16 = $0466; // MIPS
  47. IMAGE_FILE_MACHINE_AXP64 = IMAGE_FILE_MACHINE_ALPHA64;
  48. IMAGE_FILE_MACHINE_TRICORE = $0520; // Infineon
  49. IMAGE_FILE_MACHINE_CEF = $0CEF;
  50. IMAGE_FILE_MACHINE_EBC = $0EBC; // EFI Byte Code
  51. }
  52. IMAGE_FILE_MACHINE_AMD64 = $8664; // AMD64 (K8)
  53. IMAGE_FILE_MACHINE_ARM64 = $aa64; // ARM64 little endian
  54. {
  55. IMAGE_FILE_MACHINE_M32R = $9041; // M32R little-endian
  56. IMAGE_FILE_MACHINE_CEE = $C0EE;
  57. }
  58. //Coff header characteristics
  59. const
  60. IMAGE_FILE_RELOCS_STRIPPED = $0001; // Relocation info stripped from file.
  61. IMAGE_FILE_EXECUTABLE_IMAGE = $0002; // File is executable (i.e. no unresolved externel references).
  62. IMAGE_FILE_LINE_NUMS_STRIPPED = $0004; // Line nunbers stripped from file.
  63. IMAGE_FILE_LOCAL_SYMS_STRIPPED = $0008; // Local symbols stripped from file.
  64. IMAGE_FILE_AGGRESIVE_WS_TRIM = $0010; // Agressively trim working set
  65. IMAGE_FILE_LARGE_ADDRESS_AWARE = $0020; // App can handle >2gb addresses
  66. IMAGE_FILE_BYTES_REVERSED_LO = $0080; // Bytes of machine word are reversed.
  67. IMAGE_FILE_32BIT_MACHINE = $0100; // 32 bit word machine.
  68. IMAGE_FILE_DEBUG_STRIPPED = $0200; // Debugging info stripped from file in .DBG file
  69. IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP = $0400; // If Image is on removable media, copy and run from the swap file.
  70. IMAGE_FILE_NET_RUN_FROM_SWAP = $0800; // If Image is on Net, copy and run from the swap file.
  71. IMAGE_FILE_SYSTEM = $1000; // System File.
  72. IMAGE_FILE_DLL = $2000; // File is a DLL.
  73. IMAGE_FILE_UP_SYSTEM_ONLY = $4000; // File should only be run on a UP machine
  74. IMAGE_FILE_BYTES_REVERSED_HI = $8000; // Bytes of machine word are reversed.
  75. //Section header characteristics
  76. const
  77. IMAGE_SCN_CNT_CODE = $00000020; // Section contains code.
  78. IMAGE_SCN_CNT_INITIALIZED_DATA = $00000040; // Section contains initialized data.
  79. IMAGE_SCN_CNT_UNINITIALIZED_DATA = $00000080; // Section contains uninitialized data.
  80. IMAGE_SCN_LNK_OTHER = $00000100; // Reserved.
  81. IMAGE_SCN_LNK_INFO = $00000200; // Section contains comments or some other type of information.
  82. IMAGE_SCN_LNK_REMOVE = $00000800; // Section contents will not become part of image.
  83. IMAGE_SCN_LNK_COMDAT = $00001000; // Section contents comdat.
  84. IMAGE_SCN_GPREL = $00008000; // Section content can be accessed relative to GP
  85. IMAGE_SCN_ALIGN_1BYTES = $00100000; //
  86. IMAGE_SCN_ALIGN_2BYTES = $00200000; //
  87. IMAGE_SCN_ALIGN_4BYTES = $00300000; //
  88. IMAGE_SCN_ALIGN_8BYTES = $00400000; //
  89. IMAGE_SCN_ALIGN_16BYTES = $00500000; // Default alignment if no others are specified.
  90. IMAGE_SCN_ALIGN_32BYTES = $00600000; //
  91. IMAGE_SCN_ALIGN_64BYTES = $00700000; //
  92. IMAGE_SCN_ALIGN_128BYTES = $00800000; //
  93. IMAGE_SCN_ALIGN_256BYTES = $00900000; //
  94. IMAGE_SCN_ALIGN_512BYTES = $00A00000; //
  95. IMAGE_SCN_ALIGN_1024BYTES = $00B00000; //
  96. IMAGE_SCN_ALIGN_2048BYTES = $00C00000; //
  97. IMAGE_SCN_ALIGN_4096BYTES = $00D00000; //
  98. IMAGE_SCN_ALIGN_8192BYTES = $00E00000; //
  99. IMAGE_SCN_LNK_NRELOC_OVFL = $01000000; // Section contains extended relocations.
  100. IMAGE_SCN_MEM_DISCARDABLE = $02000000; // Section can be discarded.
  101. IMAGE_SCN_MEM_NOT_CACHED = $04000000; // Section is not cachable.
  102. IMAGE_SCN_MEM_NOT_PAGED = $08000000; // Section is not pageable.
  103. IMAGE_SCN_MEM_SHARED = $10000000; // Section is shareable.
  104. IMAGE_SCN_MEM_EXECUTE = $20000000; // Section is executable.
  105. IMAGE_SCN_MEM_READ = $40000000; // Section is readable.
  106. IMAGE_SCN_MEM_WRITE = $80000000; // Section is writeable.
  107. const
  108. // I386 relocation types.
  109. IMAGE_REL_I386_ABSOLUTE = $0000; // Reference is absolute, no relocation is necessary
  110. IMAGE_REL_I386_DIR16 = $0001; // Direct 16-bit reference to the symbols virtual address
  111. IMAGE_REL_I386_REL16 = $0002; // PC-relative 16-bit reference to the symbols virtual address
  112. IMAGE_REL_I386_DIR32 = $0006; // Direct 32-bit reference to the symbols virtual address
  113. IMAGE_REL_I386_DIR32NB = $0007; // Direct 32-bit reference to the symbols virtual address, base not included
  114. IMAGE_REL_I386_SEG12 = $0009; // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address
  115. IMAGE_REL_I386_SECTION = $000A;
  116. IMAGE_REL_I386_SECREL = $000B;
  117. IMAGE_REL_I386_TOKEN = $000C; // clr token
  118. IMAGE_REL_I386_SECREL7 = $000D; // 7 bit offset from base of section containing target
  119. IMAGE_REL_I386_REL32 = $0014; // PC-relative 32-bit reference to the symbols virtual address
  120. // ARM relocation types.
  121. IMAGE_REL_ARM_ABSOLUTE = $0000; // No relocation required
  122. IMAGE_REL_ARM_ADDR32 = $0001; // 32 bit address
  123. IMAGE_REL_ARM_ADDR32NB = $0002; // 32 bit address w/o image base
  124. IMAGE_REL_ARM_BRANCH24 = $0003; // 24 bit offset << 2 & sign ext.
  125. IMAGE_REL_ARM_BRANCH11 = $0004; // Thumb: 2 11 bit offsets
  126. IMAGE_REL_ARM_TOKEN = $0005; // clr token
  127. IMAGE_REL_ARM_GPREL12 = $0006; // GP-relative addressing (ARM)
  128. IMAGE_REL_ARM_GPREL7 = $0007; // GP-relative addressing (Thumb)
  129. IMAGE_REL_ARM_BLX24 = $0008;
  130. IMAGE_REL_ARM_BLX11 = $0009;
  131. IMAGE_REL_ARM_SECTION = $000E; // Section table index
  132. IMAGE_REL_ARM_SECREL = $000F; // Offset within section
  133. // x64 relocation types.
  134. IMAGE_REL_AMD64_ABSOLUTE = $0000; // Reference is absolute, no relocation is necessary
  135. IMAGE_REL_AMD64_ADDR64 = $0001; // 64-bit address (VA).
  136. IMAGE_REL_AMD64_ADDR32 = $0002; // 32-bit address (VA).
  137. IMAGE_REL_AMD64_ADDR32NB = $0003; // 32-bit address w/o image base (RVA).
  138. IMAGE_REL_AMD64_REL32 = $0004; // 32-bit relative address from byte following reloc
  139. IMAGE_REL_AMD64_REL32_1 = $0005; // 32-bit relative address from byte distance 1 from reloc
  140. IMAGE_REL_AMD64_REL32_2 = $0006; // 32-bit relative address from byte distance 2 from reloc
  141. IMAGE_REL_AMD64_REL32_3 = $0007; // 32-bit relative address from byte distance 3 from reloc
  142. IMAGE_REL_AMD64_REL32_4 = $0008; // 32-bit relative address from byte distance 4 from reloc
  143. IMAGE_REL_AMD64_REL32_5 = $0009; // 32-bit relative address from byte distance 5 from reloc
  144. IMAGE_REL_AMD64_SECTION = $000A; // Section index
  145. IMAGE_REL_AMD64_SECREL = $000B; // 32 bit offset from base of section containing target
  146. IMAGE_REL_AMD64_SECREL7 = $000C; // 7 bit unsigned offset from base of section containing target
  147. IMAGE_REL_AMD64_TOKEN = $000D; // 32 bit metadata token
  148. IMAGE_REL_AMD64_SREL32 = $000E; // 32 bit signed span-dependent value emitted into object
  149. IMAGE_REL_AMD64_PAIR = $000F;
  150. IMAGE_REL_AMD64_SSPAN32 = $0010; // 32 bit signed span-dependent value applied at link time
  151. // aarch64 relocation types
  152. IMAGE_REL_ARM64_ABSOLUTE = $0000; // The relocation is ignored.
  153. IMAGE_REL_ARM64_ADDR32 = $0001; // The 32-bit VA of the target.
  154. IMAGE_REL_ARM64_ADDR32NB = $0002; // The 32-bit RVA of the target.
  155. IMAGE_REL_ARM64_BRANCH26 = $0003; // The 26-bit relative displacement to the target, for B and BL instructions.
  156. IMAGE_REL_ARM64_PAGEBASE_REL21= $0004; // The page base of the target, for ADRP instruction.
  157. IMAGE_REL_ARM64_REL21 = $0005; // The 12-bit relative displacement to the target, for instruction ADR
  158. IMAGE_REL_ARM64_PAGEOFFSET_12A= $0006; // The 12-bit page offset of the target, for instructions ADD/ADDS (immediate) with zero shift.
  159. IMAGE_REL_ARM64_PAGEOFFSET_12L= $0007; // The 12-bit page offset of the target, for instruction LDR (indexed, unsigned immediate).
  160. IMAGE_REL_ARM64_SECREL = $0008; // The 32-bit offset of the target from the beginning of its section. This is used to support debugging information and static thread local storage.
  161. IMAGE_REL_ARM64_SECREL_LOW12A = $0009; // Bit 0:11 of section offset of the target, for instructions ADD/ADDS (immediate) with zero shift.
  162. IMAGE_REL_ARM64_SECREL_HIGH12A= $000A; // Bit 12:23 of section offset of the target, for instructions ADD/ADDS (immediate) with zero shift.
  163. IMAGE_REL_ARM64_SECREL_LOW12L = $000B; // Bit 0:11 of section offset of the target, for instruction LDR (indexed, unsigned immediate).
  164. IMAGE_REL_ARM64_TOKEN = $000C; // CLR token.
  165. IMAGE_REL_ARM64_SECTION = $000D; // The 16-bit section index of the section that contains the target. This is used to support debugging information.
  166. IMAGE_REL_ARM64_ADDR64 = $000E; // The 64-bit VA of the relocation target.
  167. IMAGE_REL_ARM64_BRANCH19 = $000F; // The 19-bit offset to the relocation target, for conditional B instruction.
  168. IMAGE_REL_ARM64_BRANCH14 = $0010; // The 14-bit offset to the relocation target, for instructions TBZ and TBNZ.
  169. IMAGE_REL_ARM64_REL32 = $0011; // The 32-bit relative address from the byte following the relocation.
  170. // AIX PPC32/PPC64 relocation types.
  171. IMAGE_REL_PPC_POS = $1F00; // A(sym) Positive Relocation
  172. const
  173. // storage classes
  174. IMAGE_SYM_CLASS_STATIC = $0003;
  175. // XCOFF
  176. IMAGE_SYM_CLASS_EXT = 2;
  177. IMAGE_SYM_CLASS_HIDEXT = 107;
  178. XTY_ER = 0;
  179. XTY_SD = 1;
  180. XTY_LD = 2;
  181. XTY_CM = 3;
  182. XMC_RW = 5;
  183. // section types
  184. STYP_DATA = $40;
  185. STYP_BSS = $80;
  186. const
  187. XCoffRsrcSectName = 'fpc.resources';
  188. XCoffHandlesSectName = 'fpc.reshandles';
  189. implementation
  190. end.