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

VxWorks

开发平台:

C/C++

  1. /* b_out.h - b.out object module header */
  2. /*
  3. modification history
  4. --------------------
  5. 01f,22sep92,rrr  added support for c++
  6. 01e,04jul92,jcf  cleaned up.
  7. 01d,26may92,rrr  the tree shuffle
  8. 01c,04oct91,rrr  passed through the ansification filter
  9.   -fixed #else and #endif
  10.   -changed copyright notice
  11. 01b,09jun91,del  added pragma for building w/o -mic-compat flag w/ gcc960.
  12. 01a,31mar91,del  installed from gnu960.
  13. */
  14. #ifndef __INCb_outh
  15. #define __INCb_outh
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19.  
  20. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  21. #pragma align 1 /* tell gcc960 not to optimize alignments */
  22. #endif /* CPU_FAMILY==I960 */
  23. /* This file is a modified version of 'a.out.h'.  It is to be used in all
  24.  * all GNU tools modified to support the i80960 (or tools that operate on
  25.  * object files created by such tools).
  26.  *
  27.  * All i80960 development is done in a CROSS-DEVELOPMENT environment.  I.e.,
  28.  * object code is generated on, and executed under the direction of a symbolic
  29.  * debugger running on, a host system.  We do not want to be subject to the
  30.  * vagaries of which host it is or whether it supports COFF or a.out format,
  31.  * or anything else.  We DO want to:
  32.  *
  33.  * o always generate the same format object files, regardless of host.
  34.  *
  35.  * o have an 'a.out' header that we can modify for our own purposes
  36.  *   (the 80960 is typically an embedded processor and may require
  37.  *   enhanced linker support that the normal a.out.h header can't
  38.  *   accommodate).
  39.  *
  40.  * As for byte-ordering, the following rules apply:
  41.  *
  42.  * o Text and data that is actually downloaded to the target is always
  43.  *   in i80960 (little-endian) order.
  44.  *
  45.  * o All other numbers (in the header, symbols, relocation directives)
  46.  *   are in host byte-order:  object files CANNOT be lifted from a
  47.  *   little-end host and used on a big-endian (or vice versa) without
  48.  *   modification.
  49.  *
  50.  * o The downloader ('comm960') takes care to generate a pseudo-header
  51.  *   with correct (i80960) byte-ordering before shipping text and data
  52.  *   off to the NINDY monitor in the target systems.  Symbols and
  53.  *   relocation info are never sent to the target.
  54.  */
  55. #define BMAGIC 0415
  56. /* We don't accept the following (see N_BADMAG macro).
  57.  * They're just here so GNU code will compile.
  58.  */
  59. #define OMAGIC 0407 /* old impure format */
  60. #define NMAGIC 0410 /* read-only text */
  61. #define ZMAGIC 0413 /* demand load format */
  62. /* FILE HEADER
  63.  * All 'lengths' are given as a number of bytes.
  64.  * All 'alignments' are for relinkable files only;  an alignment of
  65.  * 'n' indicates the corresponding segment must begin at an
  66.  * address that is a multiple of (2**n).
  67.  */
  68. struct exec {
  69. /* Standard stuff */
  70. unsigned long a_magic; /* Identifies this as a b.out file */
  71. unsigned long a_text; /* Length of text */
  72. unsigned long a_data; /* Length of data */
  73. unsigned long a_bss; /* Length of runtime uninitialized data area */
  74. unsigned long a_syms; /* Length of symbol table */
  75. unsigned long a_entry; /* Runtime start address */
  76. unsigned long a_trsize; /* Length of text relocation info */
  77. unsigned long a_drsize; /* Length of data relocation info */
  78. /* Added for i960 */
  79. unsigned long a_tload; /* Text runtime load address */
  80. unsigned long a_dload; /* Data runtime load address */
  81. unsigned char a_talign; /* Alignment of text segment */
  82. unsigned char a_dalign; /* Alignment of data segment */
  83. unsigned char a_balign; /* Alignment of bss segment */
  84. unsigned char unused; /* (Just to make struct size a multiple of 4) */
  85. };
  86. #define N_BADMAG(x) (((x).a_magic)!=BMAGIC)
  87. #define N_TXTOFF(x) ( sizeof(struct exec) )
  88. #define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
  89. #define N_TROFF(x) ( N_DATOFF(x) + (x).a_data )
  90. #define N_DROFF(x) ( N_TROFF(x) + (x).a_trsize )
  91. #define N_SYMOFF(x) ( N_DROFF(x) + (x).a_drsize )
  92. #define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
  93. /* A single entry in the symbol table
  94.  */
  95. struct nlist {
  96. union {
  97. char *n_name;
  98. struct nlist *n_next;
  99. long n_strx; /* Index into string table */
  100. } n_un;
  101. char n_type; /* See below */
  102. char n_other; /* Used in i80960 support -- see below */
  103. short n_desc;
  104. unsigned n_value;
  105. };
  106. /* Legal values of n_type
  107.  */
  108. #define N_UNDF 0 /* Undefined symbol */
  109. #define N_ABS 2 /* Absolute symbol */
  110. #define N_TEXT 4 /* Text symbol */
  111. #define N_DATA 6 /* Data symbol */
  112. #define N_BSS 8 /* BSS symbol */
  113. #define N_FN 31 /* Filename symbol */
  114. #define N_BAL 0x10 /* I80960 BAL entry point to function */
  115. #define N_EXT 1 /* External symbol (OR'd in with one of above) */
  116. #define N_TYPE 036 /* Mask for all the type bits */
  117. #define N_STAB 0340 /* Mask for all bits used for SDB entries  */
  118. /* MEANING OF 'n_other'
  119.  *
  120.  * If non-zero, the 'n_other' fields indicates either a leaf procedure or
  121.  * a system procedure, as follows:
  122.  *
  123.  * 1 <= n_other <= 32 :
  124.  * The symbol is the entry point to a system procedure.
  125.  * 'n_value' is the address of the entry, as for any other
  126.  * procedure.  The system procedure number (which can be used in
  127.  * a 'calls' instruction) is (n_other-1).  These entries come from
  128.  * '.sysproc' directives.
  129.  *
  130.  * n_other == N_CALLNAME
  131.  * the symbol is the 'call' entry point to a leaf procedure.
  132.  * The *next* symbol in the symbol table must be the corresponding
  133.  * 'bal' entry point to the procedure (see following).  These
  134.  * entries come from '.leafproc' directives in which two different
  135.  * symbols are specified (the first one is represented here).
  136.  *
  137.  *
  138.  * n_other == N_BALNAME
  139.  * the symbol is the 'bal' entry point to a leaf procedure.
  140.  * These entries result from '.leafproc' directives in which only
  141.  * one symbol is specified, or in which the same symbol is
  142.  * specified twice.
  143.  *
  144.  * Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry,
  145.  * but not every N_BALNAME entry must have an N_CALLNAME entry.
  146.  */
  147. #define N_CALLNAME -1
  148. #define N_BALNAME -2
  149. struct relocation_info {
  150. int  r_address; /* File address of item to be relocated */
  151. unsigned
  152. r_symbolnum:24,/* Index of symbol on which relocation is based*/
  153. r_pcrel:1, /* 1 => relocate PC-relative; else absolute
  154.  * On i960, pc-relative implies 24-bit
  155.  * address, absolute implies 32-bit.
  156.  */
  157. r_length:2, /* Number of bytes to relocate:
  158.  * 0 => 1 byte
  159.  * 1 => 2 bytes
  160.  * 2 => 4 bytes -- only value used for i960
  161.  */
  162. r_extern:1,
  163. r_bsr:1, /* Something for the GNU NS32K assembler */
  164. r_disp:1, /* Something for the GNU NS32K assembler */
  165. r_callj:1, /* 1 if relocation target is an i960 'callj' */
  166. nuthin:1; /* Unused */
  167. };
  168. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  169. #pragma align 0 /* turn off alignment requirement */
  170. #endif /* CPU_FAMILY==I960 */
  171. #ifdef __cplusplus
  172. }
  173. #endif
  174. #endif /* __INCb_outh */