out.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* $Header$ */
  2. /*
  3. * output format for ACK assemblers
  4. */
  5. #ifndef ushort
  6. #define ushort unsigned short
  7. #endif ushort
  8. struct outhead {
  9. ushort oh_magic; /* magic number */
  10. ushort oh_stamp; /* version stamp */
  11. ushort oh_flags; /* several format flags */
  12. ushort oh_nsect; /* number of outsect structures */
  13. ushort oh_nrelo; /* number of outrelo structures */
  14. ushort oh_nname; /* number of outname structures */
  15. long oh_nemit; /* sum of all os_flen */
  16. long oh_nchar; /* size of string area */
  17. };
  18. #define O_MAGIC 0x0201 /* magic number of output file */
  19. #define O_STAMP 0 /* version stamp */
  20. #ifdef JOHAN
  21. #define HF_BREV 0x0001 /* high order byte lowest address */
  22. #define HF_WREV 0x0002 /* high order word lowest address */
  23. #endif JOHAN
  24. #define HF_LINK 0x0004 /* unresolved references left */
  25. #define HF_8086 0x0008 /* os_base specially encoded */
  26. struct outsect {
  27. long os_base; /* startaddress in machine */
  28. long os_size; /* section size in machine */
  29. long os_foff; /* startaddress in file */
  30. long os_flen; /* section size in file */
  31. long os_lign; /* section alignment */
  32. };
  33. struct outrelo {
  34. char or_type; /* type of reference */
  35. char or_sect; /* referencing section */
  36. ushort or_nami; /* referenced symbol index */
  37. long or_addr; /* referencing address */
  38. };
  39. struct outname {
  40. union {
  41. char *on_ptr; /* symbol name (in core) */
  42. long on_off; /* symbol name (in file) */
  43. } on_u;
  44. #define on_mptr on_u.on_ptr
  45. #define on_foff on_u.on_off
  46. ushort on_type; /* symbol type */
  47. ushort on_desc; /* debug info */
  48. long on_valu; /* symbol value */
  49. };
  50. /*
  51. * relocation type bits
  52. */
  53. #define RELSZ 0x07 /* relocation length */
  54. #define RELO1 1 /* 1 byte */
  55. #define RELO2 2 /* 2 bytes */
  56. #define RELO4 4 /* 4 bytes */
  57. #define RELPC 0x08 /* pc relative */
  58. #ifndef JOHAN
  59. #define RELBR 0x10 /* High order byte lowest address. */
  60. #define RELWR 0x20 /* High order word lowest address. */
  61. #endif JOHAN
  62. /*
  63. * section type bits and fields
  64. */
  65. #define S_TYP 0x007F /* undefined, absolute or relative */
  66. #define S_EXT 0x0080 /* external flag */
  67. #define S_ETC 0x7F00 /* for symbolic debug, bypassing 'as' */
  68. /*
  69. * S_TYP field values
  70. */
  71. #define S_UND 0x0000 /* undefined item */
  72. #define S_ABS 0x0001 /* absolute item */
  73. #define S_MIN 0x0002 /* first user section */
  74. #define S_MAX S_TYP /* last user section */
  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. #ifndef JOHAN
  83. #define S_COM 0x1000 /* Common name. */
  84. #endif JOHAN
  85. /*
  86. * structure format strings
  87. */
  88. #define SF_HEAD "22222244"
  89. #define SF_SECT "44444"
  90. #define SF_RELO "1124"
  91. #define SF_NAME "4224"
  92. /*
  93. * structure sizes (bytes in file; add digits in SF_*)
  94. */
  95. #define SZ_HEAD 20
  96. #define SZ_SECT 20
  97. #define SZ_RELO 8
  98. #define SZ_NAME 12
  99. /*
  100. * file access macros
  101. */
  102. #define BADMAGIC(x) ((x).oh_magic!=O_MAGIC)
  103. #define OFF_SECT(x) SZ_HEAD
  104. #define OFF_EMIT(x) (OFF_SECT(x) + ((long)(x).oh_nsect * SZ_SECT))
  105. #define OFF_RELO(x) (OFF_EMIT(x) + (x).oh_nemit)
  106. #define OFF_NAME(x) (OFF_RELO(x) + ((long)(x).oh_nrelo * SZ_RELO))
  107. #define OFF_CHAR(x) (OFF_NAME(x) + ((long)(x).oh_nname * SZ_NAME))