hpAout.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:8k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* hpAout.h - HP/UX a.out header */
  2. /* Copyright 1984-1992 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01h,22sep92,rrr  added support for c++
  7. 01g,18sep92,jcf  cleaned up some more.
  8. 01f,04jul92,jcf  cleaned up.
  9. 01e,26may92,rrr  the tree shuffle
  10. 01d,04oct91,rrr  passed through the ansification filter
  11.   -changed copyright notice
  12. 01c,05oct90,shl  added copyright notice.
  13.                  made #endif ANSI style.
  14. 01b,12dec87,gae  added modification history; included HP/UX's magic.h.
  15. 01a,12dec87,hin  borrowed from HP/UX a.out.h file.
  16. */
  17. #ifndef __INChpAouth
  18. #define __INChpAouth
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. /* See WRS: comments where changed */
  23. /* HPUX_ID: @(#)a.out.h 27.5     85/06/27  */
  24. /*
  25.  * Layout of a.out file :
  26.  * _________________________
  27.  * | header |
  28.  * |_______________________|
  29.  * | text section |
  30.  * |_______________________|
  31.  * | data section |
  32.  * |_______________________|
  33.  * | pascal section |
  34.  * |_______________________|
  35.  * | symbol table |
  36.  * |_______________________|
  37.  * | debug name table |
  38.  * |_______________________|
  39.  * | source line table |
  40.  * |_______________________|
  41.  * | value table |
  42.  * |_______________________|
  43.  * | text relocation area |
  44.  * |_______________________|
  45.  * | data relocation area |
  46.  * |_______________________|
  47.  *
  48.  * header: 0
  49.  * text: sizeof(header)
  50.  * data: sizeof(header)+textsize
  51.  * MIS: sizeof(header)+textsize+datasize
  52.  * LEST: sizeof(header)+textsize+datasize+
  53.  * MISsize
  54.  * DNTT sizeof(header)+textsize+datasize+
  55.  * MISsize+LESTsize
  56.  * SLT sizeof(header)+textsize+datasize+
  57.  * MISsize+LESTsize+DNTTsize
  58.  * VT sizeof(header)+textsize+datasize+
  59.  * MISsize+LESTsize+DNTTsize+SLTsize
  60.  * text relocation: sizeof(header)+textsize+datasize+
  61.  * MISsize+LESTsize+DNTTsize+SLTsize+
  62.  * VTsize
  63.  * data relocation: sizeof(header)+textsize+datasize+
  64.  * MISsize+LESTsize+DNTTsize+SLTsize+
  65.  * VTsize+rtextsize
  66.  *
  67.  * NOTE - header, data, and text are padded to a multiple of
  68.  *        EXEC_PAGESIZE bytes (using EXEC_ALIGN macro) in
  69.  *        demand-load files.
  70.  *
  71.  */
  72. /* header of a.out files */
  73. /*#include <magic.h>*/
  74. /*#include <nlist.h> included for all machines */
  75. /*------------------------start-of-magic.h------------------------------------*/
  76. /* @(#) $Revision: 2.1 $ */
  77. /*
  78.    magic.h:  info about HP-UX "magic numbers"
  79. */
  80. /* where to find the magic number in a file and what it looks like: */
  81. #define MAGIC_OFFSET    0L
  82. struct magic
  83.          {
  84.           unsigned short int system_id;
  85.           unsigned short int file_type;
  86.          };
  87. typedef struct magic MAGIC;
  88. /* predefined (required) file types: */
  89. #define RELOC_MAGIC     0x106           /* relocatable only */
  90. #define EXEC_MAGIC      0x107           /* normal executable */
  91. #define SHARE_MAGIC     0x108           /* shared executable */
  92. #define AR_MAGIC        0xFF65
  93. /* optional (implementation-dependent) file types: */
  94. #define DEMAND_MAGIC    0x10B           /* demand-load executable */
  95. /* predefined HP-UX target system machine IDs */
  96. #define HP9000_ID       0x208
  97. #define HP98x6_ID       0x20A
  98. #define HP9000S200_ID   0x20C
  99. /*--------------------------end-of-magic.h------------------------------------*/
  100. /* WRS: munge name to not conflict with usual a.out.h */
  101. struct execHP {
  102. /*  0 */ MAGIC a_magic; /* magic number */
  103. /*  4 */ short a_stamp; /* version id */
  104. /*  6 */ short a_unused;
  105. /*  8 */ long a_sparehp;
  106. /* 12 */ long a_text; /* size of text segment */
  107. /* 16 */ long a_data; /* size of data segment */
  108. /* 20 */ long a_bss; /* size of bss segment */
  109. /* 24 */ long a_trsize; /* text relocation size */
  110. /* 28 */ long a_drsize; /* data relocation size */
  111. /* 32 */ long a_pasint; /* pascal interface size */
  112. /* 36 */ long a_lesyms; /* symbol table size */
  113. /* 40 */ long a_dnttsize; /* debug name table size */
  114. /* 44 */ long a_entry; /* entry point */
  115. /* 48 */ long a_sltsize; /* source line table size */
  116. /* 52 */ long a_vtsize; /* value table size */
  117. /* 56 */ long a_spare3;
  118. /* 60 */ long a_spare4;
  119. };
  120. #define EXEC_PAGESIZE 4096 /* not always the same as the MMU page size */
  121. #define EXEC_PAGESHIFT 12 /* log2(EXEC_PAGESIZE) */
  122. #define EXEC_ALIGN(bytes) (((bytes)+EXEC_PAGESIZE-1) & ~(EXEC_PAGESIZE-1))
  123. # define TEXT_OFFSET(hdr) ((hdr).a_magic.file_type == DEMAND_MAGIC ? 
  124. EXEC_ALIGN(sizeof(hdr)) : sizeof(hdr))
  125. # define DATA_OFFSET(hdr)  ((hdr).a_magic.file_type == DEMAND_MAGIC ? 
  126. EXEC_ALIGN(sizeof(hdr)) +        
  127. EXEC_ALIGN((hdr).a_text) : 
  128. sizeof(hdr) + (hdr).a_text)
  129. # define MODCAL_OFFSET(hdr) ((hdr).a_magic.file_type == DEMAND_MAGIC ? 
  130. EXEC_ALIGN(sizeof(hdr)) +        
  131. EXEC_ALIGN((hdr).a_text) + 
  132. EXEC_ALIGN((hdr).a_data) : 
  133. sizeof(hdr) + (hdr).a_text + (hdr).a_data)
  134. # define LESYM_OFFSET(hdr)     MODCAL_OFFSET(hdr) + (hdr).a_pasint
  135. # define DNTT_OFFSET(hdr)  LESYM_OFFSET(hdr) + (hdr).a_lesyms
  136. # define SLT_OFFSET(hdr)   DNTT_OFFSET(hdr) + (hdr).a_dnttsize
  137. # define VT_OFFSET(hdr)    SLT_OFFSET(hdr) + (hdr).a_sltsize
  138. # define RTEXT_OFFSET(hdr) VT_OFFSET(hdr) + (hdr).a_vtsize
  139. # define RDATA_OFFSET(hdr) RTEXT_OFFSET(hdr) + (hdr).a_trsize
  140. # define DNTT_SIZE(hdr)  (hdr).a_dnttsize
  141. # define VT_SIZE(hdr)    (hdr).a_vtsize
  142. # define SLT_SIZE(hdr)   (hdr).a_sltsize
  143. /* macros which define various positions in file based on an exec: filhdr */
  144. #define TEXTPOS TEXT_OFFSET(filhdr)
  145. #define DATAPOS  DATA_OFFSET(filhdr)
  146. #define MODCALPOS MODCAL_OFFSET(filhdr)
  147. #define LESYMPOS LESYM_OFFSET(filhdr)
  148. #define DNTTPOS DNTT_OFFSET(filhdr)
  149. #define SLTPOS SLT_OFFSET(filhdr)
  150. #define VTPOS VT_OFFSET(filhdr)
  151. #define RTEXTPOS RTEXT_OFFSET(filhdr)
  152. #define RDATAPOS RDATA_OFFSET(filhdr)
  153. /* symbol management */
  154. /* WRS: munge name to not conflict with usual a.out.h */
  155. struct nlistHP {
  156. long n_value;
  157. unsigned char n_type;
  158. unsigned char n_length; /* length of ascii symbol name */
  159. short n_almod;
  160. short n_unused;
  161. };
  162. #define A_MAGIC1 FMAGIC        /* normal */
  163. #define A_MAGIC2 NMAGIC        /* read-only text */
  164. /* relocation commands */
  165. /* WRS: munge name to not conflict with usual a.out.h */
  166. struct r_infoHP { /* mit= reloc{rpos,rsymbol,rsegment,rsize,rdisp} */
  167. long r_address; /* position of relocation in segment */
  168. short r_symbolnum; /* id of the symbol of external relocations */
  169. char r_segment; /* RTEXT, RDATA, RBSS, REXTERN, or RNOOP */
  170. char r_length; /* RBYTE, RWORD, or RLONG */
  171. };
  172. /* symbol types */
  173. #define EXTERN 040 /* = 0x20 */
  174. #define ALIGN 020 /* = 0x10 */ /* special alignment symbol type */
  175. #define UNDEF 00
  176. #define ABS 01
  177. #define TEXT 02
  178. #define DATA 03
  179. #define BSS 04
  180. #define COMM 05 /* internal use only */
  181. #define REG 06
  182. /* relocation regions */
  183. #define RTEXT 00
  184. #define RDATA 01
  185. #define RBSS 02
  186. #define REXT 03
  187. #define RNOOP 077 /* no-op relocation  record, does nothing */
  188. /* relocation sizes */
  189. #define RBYTE 00
  190. #define RWORD 01
  191. #define RLONG 02
  192. #define RALIGN 03 /* special reloc flag to support .align symbols */
  193. /* values for type flag */
  194. #define N_UNDF_ 0 /* undefined */
  195. #define N_TYPE_ 037
  196. #define N_FN_ 037 /* file name symbol */
  197. #define N_ABS_ 01 /* absolute */
  198. #define N_TEXT_ 02 /* text symbol */
  199. #define N_DATA_ 03 /* data symbol */
  200. #define N_BSS_ 04 /* bss symbol */
  201. #define N_REG_ 024 /* register name */
  202. #define N_EXT_ 040 /* external bit, or'ed in */
  203. #define FORMAT_ "%06o" /* to print a value */
  204. #define SYMLENGTH_ 255 /* maximum length of a symbol */
  205. #ifdef WRS_UNWANTED
  206. /* WRS: the following is not needed (and possibly conflicts) */
  207. /* These suffixes must also be maintained in the cc shell file */
  208. #define OUT_NAME "a.out"
  209. #define OBJ_SUFFIX ".o"
  210. #define C_SUFFIX ".c"
  211. #define ASM_SUFFIX ".s"
  212. #define N_BADTYPE(x) (((x).a_magic.file_type)!=EXEC_MAGIC&&
  213. ((x).a_magic.file_type)!=SHARE_MAGIC&&
  214. ((x).a_magic.file_type)!=DEMAND_MAGIC&&
  215. ((x).a_magic.file_type)!=RELOC_MAGIC)
  216. #define N_BADMACH(x) ((x).a_magic.system_id!=HP9000S200_ID&&
  217. (x).a_magic.system_id!=HP98x6_ID)
  218. #define N_BADMAG(x)  (N_BADTYPE(x) || N_BADMACH(x))
  219. #endif /* WRS_UNWANTED */
  220. #ifdef __cplusplus
  221. }
  222. #endif
  223. #endif /* __INChpAouth */