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