home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Atari / Gnu / gdb36p4s.zoo / gnu-out.h < prev    next >
C/C++ Source or Header  |  1993-04-02  |  8KB  |  289 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(atarist) || defined(CROSSATARI) || defined(atariminix) || defined(MINIX)
  121. #  ifdef vax
  122. #    undef vax
  123. #  endif
  124. #  ifdef is68k
  125. #    undef is68k
  126. #  endif
  127. #  ifdef pyr
  128. #    undef pyr
  129. #  endif
  130. #  ifdef hp300
  131. #    undef hp300
  132. #  endif
  133. #  ifdef sony
  134. #    undef sony
  135. #  endif
  136. #  ifdef PORTAR
  137. #    undef PORTAR
  138. #  endif
  139. #endif
  140.  
  141. #if defined(vax) || defined(hp300) || defined(pyr)
  142. #define SEGMENT_SIZE page_size
  143. #endif
  144. #ifdef    sony
  145. #define    SEGMENT_SIZE    0x2000
  146. #endif    /* Sony.  */
  147. #ifdef is68k
  148. #define SEGMENT_SIZE 0x20000
  149. #endif
  150. #if defined(m68k) && defined(PORTAR)
  151. #define PAGE_SIZE 0x400
  152. #define SEGMENT_SIZE PAGE_SIZE
  153. #endif
  154. #if defined(atarist) || defined(CROSSATARI) || defined(atariminix) || defined(MINIX)
  155. #define SEGMENT_SIZE 2
  156. #endif
  157.  
  158. #define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
  159.  
  160. #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
  161.  
  162. #ifndef N_DATADDR
  163. #define N_DATADDR(x) \
  164.     (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
  165.      : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
  166. #endif
  167.  
  168. /* Address of bss segment in memory after it is loaded.  */
  169. #if !defined (N_BSSADDR)
  170. #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
  171. #endif
  172.  
  173. #if !defined (N_NLIST_DECLARED)
  174. struct nlist {
  175.   union {
  176.     char *n_name;
  177.     struct nlist *n_next;
  178.     long n_strx;
  179.   } n_un;
  180.   unsigned char n_type;
  181.   char n_other;
  182.   short n_desc;
  183.   unsigned long n_value;
  184. };
  185. #endif /* no N_NLIST_DECLARED.  */
  186.  
  187. #if !defined (N_UNDF)
  188. #define N_UNDF 0
  189. #endif
  190. #if !defined (N_ABS)
  191. #define N_ABS 2
  192. #endif
  193. #if !defined (N_TEXT)
  194. #define N_TEXT 4
  195. #endif
  196. #if !defined (N_DATA)
  197. #define N_DATA 6
  198. #endif
  199. #if !defined (N_BSS)
  200. #define N_BSS 8
  201. #endif
  202. #if !defined (N_FN)
  203. #define N_FN 15
  204. #endif
  205. #if !defined (N_COMM)
  206. #define N_COMM 18
  207. #endif
  208.  
  209. #if !defined (N_EXT)
  210. #define N_EXT 1
  211. #endif
  212. #if !defined (N_TYPE)
  213. #define N_TYPE 036
  214. #endif
  215. #if !defined (N_STAB)
  216. #define N_STAB 0340
  217. #endif
  218.  
  219. /* The following type indicates the definition of a symbol as being
  220.    an indirect reference to another symbol.  The other symbol
  221.    appears as an undefined reference, immediately following this symbol.
  222.  
  223.    Indirection is asymmetrical.  The other symbol's value will be used
  224.    to satisfy requests for the indirect symbol, but not vice versa.
  225.    If the other symbol does not have a definition, libraries will
  226.    be searched to find a definition.  */
  227. #define N_INDR 0xa
  228.  
  229. /* The following symbols refer to set elements.
  230.    All the N_SET[ATDB] symbols with the same name form one set.
  231.    Space is allocated for the set in the text section, and each set
  232.    element's value is stored into one word of the space.
  233.    The first word of the space is the length of the set (number of elements).
  234.  
  235.    The address of the set is made into an N_SETV symbol
  236.    whose name is the same as the name of the set.
  237.    This symbol acts like a N_DATA global symbol
  238.    in that it can satisfy undefined external references.  */
  239.  
  240. /* These appear as input to LD, in a .o file.  */
  241. #define    N_SETA    0x14        /* Absolute set element symbol */
  242. #define    N_SETT    0x16        /* Text set element symbol */
  243. #define    N_SETD    0x18        /* Data set element symbol */
  244. #define    N_SETB    0x1A        /* Bss set element symbol */
  245.  
  246. /* This is output from LD.  */
  247. #define N_SETV    0x1C        /* Pointer to set vector in data area.  */
  248.  
  249. #if !defined (N_RELOCATION_INFO_DECLARED)
  250. /* This structure describes a single relocation to be performed.
  251.    The text-relocation section of the file is a vector of these structures,
  252.    all of which apply to the text section.
  253.    Likewise, the data-relocation section applies to the data section.  */
  254.  
  255. struct relocation_info
  256. {
  257.   /* Address (within segment) to be relocated.  */
  258.   int r_address;
  259.   /* The meaning of r_symbolnum depends on r_extern.  */
  260.   unsigned int r_symbolnum:24;
  261.   /* Nonzero means value is a pc-relative offset
  262.      and it should be relocated for changes in its own address
  263.      as well as for changes in the symbol or section specified.  */
  264.   unsigned int r_pcrel:1;
  265.   /* Length (as exponent of 2) of the field to be relocated.
  266.      Thus, a value of 2 indicates 1<<2 bytes.  */
  267.   unsigned int r_length:2;
  268.   /* 1 => relocate with value of symbol.
  269.           r_symbolnum is the index of the symbol
  270.       in file's the symbol table.
  271.      0 => relocate with the address of a segment.
  272.           r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
  273.       (the N_EXT bit may be set also, but signifies nothing).  */
  274.   unsigned int r_extern:1;
  275.   /* Four bits that aren't used, but when writing an object file
  276.      it is desirable to clear them.  */
  277. #ifdef NS32K
  278.   unsigned r_bsr:1;
  279.   unsigned r_disp:1;
  280.   unsigned r_pad:2;
  281. #else
  282.   unsigned int r_pad:4;
  283. #endif
  284. };
  285. #endif /* no N_RELOCATION_INFO_DECLARED.  */
  286.  
  287.  
  288. #endif /* __A_OUT_GNU_H__ */
  289.