out.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /* $Id$ */
  6. #ifndef __OUT_H_INCLUDED
  7. #define __OUT_H_INCLUDED
  8. #include <stdint.h>
  9. /*
  10. * output format for ACK assemblers
  11. */
  12. struct outhead {
  13. uint16_t oh_magic; /* magic number */
  14. uint16_t oh_stamp; /* version stamp */
  15. uint16_t oh_flags; /* several format flags */
  16. uint16_t oh_nsect; /* number of outsect structures */
  17. uint16_t oh_nrelo; /* number of outrelo structures */
  18. uint16_t oh_nname; /* number of outname structures */
  19. uint32_t oh_nemit; /* sum of all os_flen */
  20. uint32_t oh_nchar; /* size of string area */
  21. };
  22. #define O_MAGIC 0x0201 /* magic number of output file */
  23. #define O_STAMP 0 /* version stamp */
  24. #define MAXSECT 64 /* Maximum number of sections */
  25. #define HF_LINK 0x0004 /* unresolved references left */
  26. #define HF_8086 0x0008 /* os_base specially encoded */
  27. struct outsect {
  28. uint32_t os_base; /* startaddress in machine */
  29. uint32_t os_size; /* section size in machine */
  30. uint32_t os_foff; /* startaddress in file */
  31. uint32_t os_flen; /* section size in file */
  32. uint32_t os_lign; /* section alignment */
  33. };
  34. struct outrelo {
  35. int8_t or_type; /* type of reference */
  36. int8_t or_sect; /* referencing section */
  37. uint16_t or_nami; /* referenced symbol index */
  38. uint32_t or_addr; /* referencing address */
  39. };
  40. struct outname {
  41. union {
  42. int8_t *on_ptr; /* symbol name (in core) */
  43. uint32_t on_off; /* symbol name (in file) */
  44. } on_u;
  45. #define on_mptr on_u.on_ptr
  46. #define on_foff on_u.on_off
  47. uint16_t on_type; /* symbol type */
  48. uint16_t on_desc; /* debug info */
  49. uint32_t on_valu; /* symbol value */
  50. };
  51. /*
  52. * relocation type bits
  53. */
  54. #define RELSZ 0x07 /* relocation length */
  55. #define RELO1 1 /* 1 byte */
  56. #define RELO2 2 /* 2 bytes */
  57. #define RELO4 4 /* 4 bytes */
  58. #define RELPC 0x08 /* pc relative */
  59. #define RELBR 0x10 /* High order byte lowest address. */
  60. #define RELWR 0x20 /* High order word lowest address. */
  61. /*
  62. * section type bits and fields
  63. */
  64. #define S_TYP 0x007F /* undefined, absolute or relative */
  65. #define S_EXT 0x0080 /* external flag */
  66. #define S_ETC 0x7F00 /* for symbolic debug, bypassing 'as' */
  67. /*
  68. * S_TYP field values
  69. */
  70. #define S_UND 0x0000 /* undefined item */
  71. #define S_ABS 0x0001 /* absolute item */
  72. #define S_MIN 0x0002 /* first user section */
  73. #define S_MAX (S_TYP-1) /* last user section */
  74. #define S_CRS S_TYP /* on_valu is symbol index which contains value */
  75. /*
  76. * S_ETC field values
  77. */
  78. #define S_SCT 0x0100 /* section names */
  79. #define S_LIN 0x0200 /* hll source line item */
  80. #define S_FIL 0x0300 /* hll source file item */
  81. #define S_MOD 0x0400 /* ass source file item */
  82. #define S_COM 0x1000 /* Common name. */
  83. #define S_STB 0xe000 /* entries with any of these bits set are
  84. reserved for debuggers
  85. */
  86. /*
  87. * structure format strings
  88. */
  89. #define SF_HEAD "22222244"
  90. #define SF_SECT "44444"
  91. #define SF_RELO "1124"
  92. #define SF_NAME "4224"
  93. /*
  94. * structure sizes (bytes in file; add digits in SF_*)
  95. */
  96. #define SZ_HEAD 20
  97. #define SZ_SECT 20
  98. #define SZ_RELO 8
  99. #define SZ_NAME 12
  100. /*
  101. * file access macros
  102. */
  103. #define BADMAGIC(x) ((x).oh_magic!=O_MAGIC)
  104. #define OFF_SECT(x) SZ_HEAD
  105. #define OFF_EMIT(x) (OFF_SECT(x) + ((uint32_t)(x).oh_nsect * SZ_SECT))
  106. #define OFF_RELO(x) (OFF_EMIT(x) + (x).oh_nemit)
  107. #define OFF_NAME(x) (OFF_RELO(x) + ((uint32_t)(x).oh_nrelo * SZ_RELO))
  108. #define OFF_CHAR(x) (OFF_NAME(x) + ((uint32_t)(x).oh_nname * SZ_NAME))
  109. #endif /* __OUT_H_INCLUDED */