home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Atari / Gnu / gassrc04.zoo / a.out.gnu.h next >
C/C++ Source or Header  |  1991-01-24  |  7KB  |  262 lines

  1. #ifndef __A_OUT_GNU_H__
  2. #define __A_OUT_GNU_H__
  3.  
  4. #define __GNU_EXEC_MACROS__
  5.  
  6. #ifndef __STRUCT_EXEC_OVERRIDE__
  7.  
  8. struct exec
  9. {
  10.   unsigned long a_info;        /* Use macros N_MAGIC, etc for access */
  11.   unsigned a_text;        /* length of text, in bytes */
  12.   unsigned a_data;        /* length of data, in bytes */
  13.   unsigned a_bss;        /* length of uninitialized data area for file, in bytes */
  14.   unsigned a_syms;        /* length of symbol table data in file, in bytes */
  15.   unsigned a_entry;        /* start address */
  16.   unsigned a_trsize;        /* length of relocation info for text, in bytes */
  17.   unsigned a_drsize;        /* length of relocation info for data, in bytes */
  18. };
  19.  
  20. #endif /* __STRUCT_EXEC_OVERRIDE__ */
  21.  
  22. /* these go in the N_MACHTYPE field */
  23. enum machine_type {
  24. #if defined (M_OLDSUN2)
  25.   M__OLDSUN2 = M_OLDSUN2,
  26. #else
  27.   M_OLDSUN2 = 0,
  28. #endif
  29. #if defined (M_68010)
  30.   M__68010 = M_68010,
  31. #else
  32.   M_68010 = 1,
  33. #endif
  34. #if defined (M_68020)
  35.   M__68020 = M_68020,
  36. #else
  37.   M_68020 = 2,
  38. #endif
  39. #if defined (M_SPARC)
  40.   M__SPARC = M_SPARC,
  41. #else
  42.   M_SPARC = 3,
  43. #endif
  44.   /* skip a bunch so we don't run into any of sun's numbers */
  45.   M_386 = 100,
  46. };
  47.  
  48. #if !defined (N_MAGIC)
  49. #define N_MAGIC(exec) ((exec).a_info & 0xffff)
  50. #endif
  51. #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
  52. #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
  53. #define N_SET_INFO(exec, magic, type, flags) \
  54.     ((exec).a_info = ((magic) & 0xffff) \
  55.      | (((int)(type) & 0xff) << 16) \
  56.      | (((flags) & 0xff) << 24))
  57. #define N_SET_MAGIC(exec, magic) \
  58.     ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
  59.  
  60. #define N_SET_MACHTYPE(exec, machtype) \
  61.     ((exec).a_info = \
  62.      ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
  63.  
  64. #define N_SET_FLAGS(exec, flags) \
  65.     ((exec).a_info = \
  66.      ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
  67.  
  68. /* Code indicating object file or impure executable.  */
  69. #define OMAGIC 0407
  70. /* Code indicating pure executable.  */
  71. #define NMAGIC 0410
  72. /* Code indicating demand-paged executable.  */
  73. #define ZMAGIC 0413
  74.  
  75. #if !defined (N_BADMAG)
  76. #define N_BADMAG(x)                    \
  77.  (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC        \
  78.   && N_MAGIC(x) != ZMAGIC)
  79. #endif
  80.  
  81. #define _N_BADMAG(x)                    \
  82.  (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC        \
  83.   && N_MAGIC(x) != ZMAGIC)
  84.  
  85. #define _N_HDROFF(x) (1024 - sizeof (struct exec))
  86.  
  87. #if !defined (N_TXTOFF)
  88. #define N_TXTOFF(x) \
  89.  (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec))
  90. #endif
  91.  
  92. #if !defined (N_DATOFF)
  93. #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
  94. #endif
  95.  
  96. #if !defined (N_TRELOFF)
  97. #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
  98. #endif
  99.  
  100. #if !defined (N_DRELOFF)
  101. #define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
  102. #endif
  103.  
  104. #if !defined (N_SYMOFF)
  105. #define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
  106. #endif
  107.  
  108. #if !defined (N_STROFF)
  109. #define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
  110. #endif
  111.  
  112. /* Address of text segment in memory after it is loaded.  */
  113. #if !defined (N_TXTADDR)
  114. #define N_TXTADDR(x) 0
  115. #endif
  116.  
  117. /* Address of data segment in memory after it is loaded.
  118.    Note that it is up to you to define SEGMENT_SIZE
  119.    on machines not listed here.  */
  120. #if defined(vax) || defined(hp300) || defined(pyr)
  121. #define SEGMENT_SIZE page_size
  122. #endif
  123. #ifdef    sony
  124. #define    SEGMENT_SIZE    0x2000
  125. #endif    /* Sony.  */
  126. #ifdef is68k
  127. #define SEGMENT_SIZE 0x20000
  128. #endif
  129. #if defined(m68k) && defined(PORTAR)
  130. #define PAGE_SIZE 0x400
  131. #define SEGMENT_SIZE PAGE_SIZE
  132. #endif
  133.  
  134. #define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
  135.  
  136. #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
  137.  
  138. #ifndef N_DATADDR
  139. #define N_DATADDR(x) \
  140.     (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
  141.      : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
  142. #endif
  143.  
  144. /* Address of bss segment in memory after it is loaded.  */
  145. #if !defined (N_BSSADDR)
  146. #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
  147. #endif
  148.  
  149. #if !defined (N_NLIST_DECLARED)
  150. struct nlist {
  151.   union {
  152.     char *n_name;
  153.     struct nlist *n_next;
  154.     long n_strx;
  155.   } n_un;
  156.   unsigned char n_type;
  157.   char n_other;
  158.   short n_desc;
  159.   unsigned long n_value;
  160. };
  161. #endif /* no N_NLIST_DECLARED.  */
  162.  
  163. #if !defined (N_UNDF)
  164. #define N_UNDF 0
  165. #endif
  166. #if !defined (N_ABS)
  167. #define N_ABS 2
  168. #endif
  169. #if !defined (N_TEXT)
  170. #define N_TEXT 4
  171. #endif
  172. #if !defined (N_DATA)
  173. #define N_DATA 6
  174. #endif
  175. #if !defined (N_BSS)
  176. #define N_BSS 8
  177. #endif
  178. #if !defined (N_FN)
  179. #define N_FN 15
  180. #endif
  181.  
  182. #if !defined (N_EXT)
  183. #define N_EXT 1
  184. #endif
  185. #if !defined (N_TYPE)
  186. #define N_TYPE 036
  187. #endif
  188. #if !defined (N_STAB)
  189. #define N_STAB 0340
  190. #endif
  191.  
  192. /* The following type indicates the definition of a symbol as being
  193.    an indirect reference to another symbol.  The other symbol
  194.    appears as an undefined reference, immediately following this symbol.
  195.  
  196.    Indirection is asymmetrical.  The other symbol's value will be used
  197.    to satisfy requests for the indirect symbol, but not vice versa.
  198.    If the other symbol does not have a definition, libraries will
  199.    be searched to find a definition.  */
  200. #define N_INDR 0xa
  201.  
  202. /* The following symbols refer to set elements.
  203.    All the N_SET[ATDB] symbols with the same name form one set.
  204.    Space is allocated for the set in the text section, and each set
  205.    element's value is stored into one word of the space.
  206.    The first word of the space is the length of the set (number of elements).
  207.  
  208.    The address of the set is made into an N_SETV symbol
  209.    whose name is the same as the name of the set.
  210.    This symbol acts like a N_DATA global symbol
  211.    in that it can satisfy undefined external references.  */
  212.  
  213. /* These appear as input to LD, in a .o file.  */
  214. #define    N_SETA    0x14        /* Absolute set element symbol */
  215. #define    N_SETT    0x16        /* Text set element symbol */
  216. #define    N_SETD    0x18        /* Data set element symbol */
  217. #define    N_SETB    0x1A        /* Bss set element symbol */
  218.  
  219. /* This is output from LD.  */
  220. #define N_SETV    0x1C        /* Pointer to set vector in data area.  */
  221.  
  222. #if !defined (N_RELOCATION_INFO_DECLARED)
  223. /* This structure describes a single relocation to be performed.
  224.    The text-relocation section of the file is a vector of these structures,
  225.    all of which apply to the text section.
  226.    Likewise, the data-relocation section applies to the data section.  */
  227.  
  228. struct relocation_info
  229. {
  230.   /* Address (within segment) to be relocated.  */
  231.   int r_address;
  232.   /* The meaning of r_symbolnum depends on r_extern.  */
  233.   unsigned int r_symbolnum:24;
  234.   /* Nonzero means value is a pc-relative offset
  235.      and it should be relocated for changes in its own address
  236.      as well as for changes in the symbol or section specified.  */
  237.   unsigned int r_pcrel:1;
  238.   /* Length (as exponent of 2) of the field to be relocated.
  239.      Thus, a value of 2 indicates 1<<2 bytes.  */
  240.   unsigned int r_length:2;
  241.   /* 1 => relocate with value of symbol.
  242.           r_symbolnum is the index of the symbol
  243.       in file's the symbol table.
  244.      0 => relocate with the address of a segment.
  245.           r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
  246.       (the N_EXT bit may be set also, but signifies nothing).  */
  247.   unsigned int r_extern:1;
  248.   /* Four bits that aren't used, but when writing an object file
  249.      it is desirable to clear them.  */
  250. #ifdef NS32K
  251.   unsigned r_bsr:1;
  252.   unsigned r_disp:1;
  253.   unsigned r_pad:2;
  254. #else
  255.   unsigned int r_pad:4;
  256. #endif
  257. };
  258. #endif /* no N_RELOCATION_INFO_DECLARED.  */
  259.  
  260.  
  261. #endif /* __A_OUT_GNU_H__ */
  262.