symbol.odin 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package debug_pe
  2. COFF_SYMBOL_SIZE :: 18
  3. COFF_Symbol :: struct {
  4. name: [8]u8,
  5. value: u32le,
  6. section_number: i16le,
  7. type: IMAGE_SYM_TYPE,
  8. storage_class: IMAGE_SYM_CLASS,
  9. number_of_aux_symbols: u8,
  10. }
  11. // COFF_Symbol_Aux_Format5 describes the expected form of an aux symbol
  12. // attached to a section definition symbol. The PE format defines a
  13. // number of different aux symbol formats: format 1 for function
  14. // definitions, format 2 for .be and .ef symbols, and so on. Format 5
  15. // holds extra info associated with a section definition, including
  16. // number of relocations + line numbers, as well as COMDAT info. See
  17. // https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#auxiliary-format-5-section-definitions
  18. // for more on what's going on here.
  19. COFF_Symbol_Aux_Format5 :: struct {
  20. size: u32le,
  21. num_relocs: u16le,
  22. num_line_numbers: u16le,
  23. checksum: u32le,
  24. sec_num: u16le,
  25. selection: IMAGE_COMDAT_SELECT,
  26. _: [3]u8, // padding
  27. }
  28. IMAGE_COMDAT_SELECT :: enum u8 {
  29. NODUPLICATES = 1,
  30. ANY = 2,
  31. SAME_SIZE = 3,
  32. EXACT_MATCH = 4,
  33. ASSOCIATIVE = 5,
  34. LARGEST = 6,
  35. }
  36. // The symbol record is not yet assigned a section. A value of zero indicates
  37. // that a reference to an external symbol is defined elsewhere. A value of
  38. // non-zero is a common symbol with a size that is specified by the value.
  39. IMAGE_SYM_UNDEFINED :: 0
  40. // The symbol has an absolute (non-relocatable) value and is not an address.
  41. IMAGE_SYM_ABSOLUTE :: -1
  42. // The symbol provides general type or debugging information but does not
  43. // correspond to a section. Microsoft tools use this setting along
  44. // with .file records (storage class FILE).
  45. IMAGE_SYM_DEBUG :: -2
  46. IMAGE_SYM_TYPE :: enum u16le {
  47. NULL = 0,
  48. VOID = 1,
  49. CHAR = 2,
  50. SHORT = 3,
  51. INT = 4,
  52. LONG = 5,
  53. FLOAT = 6,
  54. DOUBLE = 7,
  55. STRUCT = 8,
  56. UNION = 9,
  57. ENUM = 10,
  58. MOE = 11,
  59. BYTE = 12,
  60. WORD = 13,
  61. UINT = 14,
  62. DWORD = 15,
  63. PCODE = 32768,
  64. DTYPE_NULL = 0,
  65. DTYPE_POINTER = 0x10,
  66. DTYPE_FUNCTION = 0x20,
  67. DTYPE_ARRAY = 0x30,
  68. }
  69. IMAGE_SYM_CLASS :: enum u8 {
  70. NULL = 0,
  71. AUTOMATIC = 1,
  72. EXTERNAL = 2,
  73. STATIC = 3,
  74. REGISTER = 4,
  75. EXTERNAL_DEF = 5,
  76. LABEL = 6,
  77. UNDEFINED_LABEL = 7,
  78. MEMBER_OF_STRUCT = 8,
  79. ARGUMENT = 9,
  80. STRUCT_TAG = 10,
  81. MEMBER_OF_UNION = 11,
  82. UNION_TAG = 12,
  83. TYPE_DEFINITION = 13,
  84. UNDEFINED_STATIC = 14,
  85. ENUM_TAG = 15,
  86. MEMBER_OF_ENUM = 16,
  87. REGISTER_PARAM = 17,
  88. BIT_FIELD = 18,
  89. FAR_EXTERNAL = 68, // Not in PECOFF v8 spec
  90. BLOCK = 100,
  91. FUNCTION = 101,
  92. END_OF_STRUCT = 102,
  93. FILE = 103,
  94. SECTION = 104,
  95. WEAK_EXTERNAL = 105,
  96. CLR_TOKEN = 107,
  97. END_OF_FUNCTION = 255,
  98. }