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

VxWorks

开发平台:

C/C++

  1. /* a_out.h - a.out object module header */
  2. /* Copyright 1984-1992 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01p,22sep92,rrr  added support for c++
  7. 01o,04jul92,jcf  cleaned up.
  8. 01n,19jun92,rrr  changed UINT to unsigned to work with the hsp stuff
  9. 01m,26may92,rrr  the tree shuffle
  10.                   -moved define of a_machtype into else part of HOST_SUN
  11. 01l,15may92,jmm  changed UINT8 bitfields to unsigned
  12.                  removed a comma from SPARC enum
  13. 01k,04oct91,rrr  passed through the ansification filter
  14.   -fixed #else and #endif
  15.   -changed TINY and UTINY to INT8 and UINT8
  16.   -changed copyright notice
  17. 01j,03sep91,wmd  removed typedef of NLIST, put back inadvertently by last revision.
  18. 01i,02aug91,ajm  added mips target support
  19. 01h,21may91,jcc  removed useless typedef of NLIST, identical to nlist.
  20. 01g,15may91,elr  added #ifdef HOST_MOTOROLA
  21. 01f,05oct90,shl  added copyright notice.
  22.                  made #endif ANSI style.
  23. 01e,05oct90,lpf  added N_DATOFF macro.
  24. 01d,30apr90,gae  added kludge of a_machtype for HOST_HP.
  25. 01c,11sep89,shl  removed some of the #ifdef HOST_SUN so vxWorks can be
  26.  made on other hosts as well.
  27.  added #ifdef HOST_ISI.
  28. 01b,19apr89,ecs  conditional to reflect SunOS 4.0.
  29. 01a,16feb87,llk  created.
  30. */
  31. /*
  32. This file reflects Unix 4.2 a.out format.
  33. */
  34. #ifndef __INCa_outh
  35. #define __INCa_outh
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. struct exec
  40.     {
  41. #if defined(HOST_SUN)
  42.     unsigned  a_dynamic:1;     /* has a __DYNAMIC */
  43.     unsigned  a_toolversion:7; /* version of toolset used to create file */
  44.     unsigned  a_machtype: 8;   /* machine type */
  45.     unsigned  a_magic:16;      /* magic number */
  46. #else
  47.     long a_magic; /* magic number */
  48. #define a_machtype  a_magic
  49. #endif /* HOST_SUN */
  50.     unsigned long a_text; /* size of text segment */
  51.     unsigned long a_data; /* size of initialized data */
  52.     unsigned long a_bss; /* size of uninitialized data */
  53.     unsigned long a_syms; /* size of symbol table */
  54.     unsigned long a_entry; /* entry point */
  55.     unsigned long a_trsize; /* size of text relocation */
  56.     unsigned long a_drsize; /* size of data relocation */
  57.     };
  58. /* machine types */
  59. #define M_OLDSUN2       0       /* old sun-2 (or not sun at all) */
  60. #define M_68010         1       /* runs on either 68010 or 68020 */
  61. #define M_68020         2       /* runs only on 68020 */
  62. #define M_SPARC         3       /* runs only on SPARC */
  63. #define M_R3000         4       /* runs only on R3000 */
  64. #define ZMAGIC 0413 /* demand load format */
  65. /*
  66.  * Macros which take exec structures as arguments and tell whether
  67.  * the file has a reasonable magic number or offsets to text|symbols|strings.
  68.  */
  69. #define N_OLDOFF(x) 
  70. ((x).a_magic==ZMAGIC ? 0 : sizeof (struct exec))
  71. #define N_TXTOFF(x) 
  72. (sizeof (struct exec))
  73. #define N_DATOFF(x) 
  74. (N_TXTOFF(x) + (x).a_text)
  75. #define N_SYMOFF(x) 
  76. (N_OLDOFF(x) + (x).a_text+(x).a_data + (x).a_trsize+(x).a_drsize)
  77. #define N_STROFF(x) 
  78. (N_SYMOFF(x) + (x).a_syms)
  79. typedef struct  /* RINFO_68K - 680X0 relocation datum (a_machtype != M_SPARC) */    {
  80.     unsigned    r_address;      /* address which is relocated */
  81.     unsigned    r_symbolnum:24; /* local symbol ordinal */
  82.     unsigned    r_pcrel    : 1; /* was relocated pc relative already */
  83.     unsigned    r_length   : 2; /* 0=byte, 1=word, 2=long */
  84.     unsigned    r_extern   : 1; /* does not include value of sym referenced */
  85.     unsigned    r_baserel  : 1; /* linkage table relative */
  86.     unsigned    r_jmptable : 1; /* pc-relative to jump table */
  87.     unsigned    r_relative : 1; /* relative relocation */
  88.     unsigned               : 1; /* <unused> */
  89.     } RINFO_68K;
  90. typedef enum    /* RTYPE_SPARC - sparc relocation types */
  91.     {
  92.     RELOC_8,        RELOC_16,        RELOC_32,          /* simplest relocs    */
  93.     RELOC_DISP8,    RELOC_DISP16,    RELOC_DISP32,      /* Disp's (pc-rel)    */
  94.     RELOC_WDISP30,  RELOC_WDISP22,                      /* SR word disp's     */
  95.     RELOC_HI22,     RELOC_22,                           /* SR 22-bit relocs   */
  96.     RELOC_13,       RELOC_LO10,                         /* SR 13&10-bit relocs*/
  97.     RELOC_SFA_BASE, RELOC_SFA_OFF13,                    /* SR S.F.A. relocs   */
  98.     RELOC_BASE10,   RELOC_BASE13,    RELOC_BASE22,      /* base_relative pic  */
  99.     RELOC_PC10,     RELOC_PC22,                         /* special pc-rel pic */
  100.     RELOC_JMP_TBL,                                      /* jmp_tbl_rel in pic */
  101.     RELOC_SEGOFF16,                                     /* ShLib offset-in-seg*/
  102.     RELOC_GLOB_DAT, RELOC_JMP_SLOT,  RELOC_RELATIVE     /* rtld relocs        */
  103.     } RTYPE_SPARC;
  104. typedef struct  /* RINFO_SPARC - sparc reloc datum (a_machtype == M_SPARC) */
  105.     {
  106.     unsigned    r_address;      /* relocation addr (offset in segment)*/
  107.     unsigned    r_index   :24;  /* segment index or symbol index      */
  108.     unsigned    r_extern  : 1;  /* if F, r_index==SEG#; if T, SYM idx */
  109.     unsigned              : 2;  /* <unused>                           */
  110.     unsigned    r_type    : 5;  /* type of relocation to perform      */
  111.     long        r_addend;       /* addend for relocation value        */
  112.     } RINFO_SPARC;
  113. typedef struct /* RINFO_MIPS - mips reloc datum (a_machtype == M_R3000) */
  114.     {
  115.     int r_address;              /* address which is relocated */
  116.     unsigned int
  117.     r_symbolnum:24,  /* local symbol ordinal */
  118.     r_pcrel:1,       /* was relocated pc relative already */
  119.     r_length:2,      /* 0=byte, 1=word, 2=long */
  120.     r_extern:1,      /* does not include value of sym referenced */
  121.     r_type:4;        /* relocation type */
  122.     } RINFO_MIPS;
  123. /*
  124.  * Format of a symbol table entry; this file is included by <a.out.h>
  125.  * and should be used if you aren't interested the a.out header
  126.  * or relocation information.
  127.  */
  128. struct nlist
  129.     {
  130.     union
  131. {
  132. char *n_name;   /* for use when in-core */
  133. long n_strx;   /* index into file string table */
  134. } n_un;
  135.     unsigned char n_type;   /* type flag, i.e. N_TEXT etc; see below */
  136.     char n_other;  /* unused */
  137.     short n_desc;   /* see <stab.h> */
  138.     unsigned long  n_value;  /* value of this symbol (or sdb offset) */
  139.     };
  140. #define n_hash n_desc   /* used internally by ld */
  141. /*
  142.  * Simple values for n_type.
  143.  */
  144. #define N_UNDF 0x0 /* undefined */
  145. #define N_ABS 0x2 /* absolute */
  146. #define N_TEXT 0x4 /* text */
  147. #define N_DATA 0x6 /* data */
  148. #define N_BSS 0x8 /* bss */
  149. #define N_COMM 0x12 /* common (internal to ld) */
  150. #define N_FN 0x1f /* file name symbol */
  151. #define N_EXT 01 /* external bit, or'ed in */
  152. #define N_TYPE 0x1e /* mask for all the type bits */
  153. /*
  154.  * Sdb entries have some of the N_STAB bits set.
  155.  * These are given in <stab.h>
  156.  */
  157. #define N_STAB 0xe0 /* if any of these bits set, a SDB entry */
  158. /*
  159.  * Format for namelist values.
  160.  */
  161. #define N_FORMAT "%08x"
  162. #ifdef __cplusplus
  163. }
  164. #endif
  165. #endif /* __INCa_outh */