bout.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /* This file is a modified version of 'a.out.h'. It is to be used in all
  2. GNU tools modified to support the i80960 (or tools that operate on
  3. object files created by such tools).
  4. Copyright (C) 2001-2022 Free Software Foundation, Inc.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  16. MA 02110-1301, USA. */
  17. /* All i80960 development is done in a CROSS-DEVELOPMENT environment. I.e.,
  18. object code is generated on, and executed under the direction of a symbolic
  19. debugger running on, a host system. We do not want to be subject to the
  20. vagaries of which host it is or whether it supports COFF or a.out format,
  21. or anything else. We DO want to:
  22. o always generate the same format object files, regardless of host.
  23. o have an 'a.out' header that we can modify for our own purposes
  24. (the 80960 is typically an embedded processor and may require
  25. enhanced linker support that the normal a.out.h header can't
  26. accommodate).
  27. As for byte-ordering, the following rules apply:
  28. o Text and data that is actually downloaded to the target is always
  29. in i80960 (little-endian) order.
  30. o All other numbers (in the header, symbols, relocation directives)
  31. are in host byte-order: object files CANNOT be lifted from a
  32. little-end host and used on a big-endian (or vice versa) without
  33. modification.
  34. ==> THIS IS NO LONGER TRUE USING BFD. WE CAN GENERATE ANY BYTE ORDER
  35. FOR THE HEADER, AND READ ANY BYTE ORDER. PREFERENCE WOULD BE TO
  36. USE LITTLE-ENDIAN BYTE ORDER THROUGHOUT, REGARDLESS OF HOST. <==
  37. o The downloader ('comm960') takes care to generate a pseudo-header
  38. with correct (i80960) byte-ordering before shipping text and data
  39. off to the NINDY monitor in the target systems. Symbols and
  40. relocation info are never sent to the target. */
  41. #define BMAGIC 0415
  42. /* We don't accept the following (see N_BADMAG macro).
  43. They're just here so GNU code will compile. */
  44. #define OMAGIC 0407 /* old impure format */
  45. #define NMAGIC 0410 /* read-only text */
  46. #define ZMAGIC 0413 /* demand load format */
  47. /* FILE HEADER
  48. All 'lengths' are given as a number of bytes.
  49. All 'alignments' are for relinkable files only; an alignment of
  50. 'n' indicates the corresponding segment must begin at an
  51. address that is a multiple of (2**n). */
  52. struct external_exec
  53. {
  54. /* Standard stuff */
  55. unsigned char e_info[4]; /* Identifies this as a b.out file */
  56. unsigned char e_text[4]; /* Length of text */
  57. unsigned char e_data[4]; /* Length of data */
  58. unsigned char e_bss[4]; /* Length of uninitialized data area */
  59. unsigned char e_syms[4]; /* Length of symbol table */
  60. unsigned char e_entry[4]; /* Runtime start address */
  61. unsigned char e_trsize[4]; /* Length of text relocation info */
  62. unsigned char e_drsize[4]; /* Length of data relocation info */
  63. /* Added for i960 */
  64. unsigned char e_tload[4]; /* Text runtime load address */
  65. unsigned char e_dload[4]; /* Data runtime load address */
  66. unsigned char e_talign[1]; /* Alignment of text segment */
  67. unsigned char e_dalign[1]; /* Alignment of data segment */
  68. unsigned char e_balign[1]; /* Alignment of bss segment */
  69. unsigned char e_relaxable[1];/* Assembled with enough info to allow linker to relax */
  70. };
  71. #define EXEC_BYTES_SIZE (sizeof (struct external_exec))
  72. /* These macros use the a_xxx field names, since they operate on the exec
  73. structure after it's been byte-swapped and realigned on the host machine. */
  74. #define N_BADMAG(x) (((x)->a_info)!=BMAGIC)
  75. #define N_TXTOFF(x) EXEC_BYTES_SIZE
  76. #define N_DATOFF(x) ( N_TXTOFF(x) + (x)->a_text )
  77. #define N_TROFF(x) ( N_DATOFF(x) + (x)->a_data )
  78. #define N_TRELOFF N_TROFF
  79. #define N_DROFF(x) ( N_TROFF(x) + (x)->a_trsize )
  80. #define N_DRELOFF N_DROFF
  81. #define N_SYMOFF(x) ( N_DROFF(x) + (x)->a_drsize )
  82. #define N_STROFF(x) ( N_SYMOFF(x) + (x)->a_syms )
  83. #define N_DATADDR(x) ( (x)->a_dload )
  84. /* Address of text segment in memory after it is loaded. */
  85. #if !defined (N_TXTADDR)
  86. #define N_TXTADDR(x) 0
  87. #endif
  88. /* A single entry in the symbol table. */
  89. struct nlist
  90. {
  91. union
  92. {
  93. char* n_name;
  94. struct nlist * n_next;
  95. long n_strx; /* Index into string table */
  96. } n_un;
  97. unsigned char n_type; /* See below */
  98. char n_other; /* Used in i80960 support -- see below */
  99. short n_desc;
  100. unsigned long n_value;
  101. };
  102. /* Legal values of n_type. */
  103. #define N_UNDF 0 /* Undefined symbol */
  104. #define N_ABS 2 /* Absolute symbol */
  105. #define N_TEXT 4 /* Text symbol */
  106. #define N_DATA 6 /* Data symbol */
  107. #define N_BSS 8 /* BSS symbol */
  108. #define N_FN 31 /* Filename symbol */
  109. #define N_EXT 1 /* External symbol (OR'd in with one of above) */
  110. #define N_TYPE 036 /* Mask for all the type bits */
  111. #define N_STAB 0340 /* Mask for all bits used for SDB entries */
  112. /* MEANING OF 'n_other'
  113. If non-zero, the 'n_other' fields indicates either a leaf procedure or
  114. a system procedure, as follows:
  115. 1 <= n_other <= 32 :
  116. The symbol is the entry point to a system procedure.
  117. 'n_value' is the address of the entry, as for any other
  118. procedure. The system procedure number (which can be used in
  119. a 'calls' instruction) is (n_other-1). These entries come from
  120. '.sysproc' directives.
  121. n_other == N_CALLNAME
  122. the symbol is the 'call' entry point to a leaf procedure.
  123. The *next* symbol in the symbol table must be the corresponding
  124. 'bal' entry point to the procedure (see following). These
  125. entries come from '.leafproc' directives in which two different
  126. symbols are specified (the first one is represented here).
  127. n_other == N_BALNAME
  128. the symbol is the 'bal' entry point to a leaf procedure.
  129. These entries result from '.leafproc' directives in which only
  130. one symbol is specified, or in which the same symbol is
  131. specified twice.
  132. Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry,
  133. but not every N_BALNAME entry must have an N_CALLNAME entry. */
  134. #define N_CALLNAME ((char)-1)
  135. #define N_BALNAME ((char)-2)
  136. #define IS_CALLNAME(x) (N_CALLNAME == (x))
  137. #define IS_BALNAME(x) (N_BALNAME == (x))
  138. #define IS_OTHER(x) ((x)>0 && (x) <=32)
  139. #define b_out_relocation_info relocation_info
  140. struct relocation_info
  141. {
  142. int r_address; /* File address of item to be relocated. */
  143. unsigned
  144. #define r_index r_symbolnum
  145. r_symbolnum:24, /* Index of symbol on which relocation is based,
  146. if r_extern is set. Otherwise set to
  147. either N_TEXT, N_DATA, or N_BSS to
  148. indicate section on which relocation is
  149. based. */
  150. r_pcrel:1, /* 1 => relocate PC-relative; else absolute
  151. On i960, pc-relative implies 24-bit
  152. address, absolute implies 32-bit. */
  153. r_length:2, /* Number of bytes to relocate:
  154. 0 => 1 byte
  155. 1 => 2 bytes -- used for 13 bit pcrel
  156. 2 => 4 bytes. */
  157. r_extern:1,
  158. r_bsr:1, /* Something for the GNU NS32K assembler. */
  159. r_disp:1, /* Something for the GNU NS32K assembler. */
  160. r_callj:1, /* 1 if relocation target is an i960 'callj'. */
  161. r_relaxable:1; /* 1 if enough info is left to relax the data. */
  162. };