| 1 | /* COFF spec for AMD 290*0 | 
|---|
| 2 |  | 
|---|
| 3 | Copyright 2001 Free Software Foundation, Inc. | 
|---|
| 4 |  | 
|---|
| 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 2 of the License, or | 
|---|
| 8 | (at your option) any later version. | 
|---|
| 9 |  | 
|---|
| 10 | This program is distributed in the hope that it will be useful, | 
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 13 | GNU General Public License for more details. | 
|---|
| 14 |  | 
|---|
| 15 | You should have received a copy of the GNU General Public License | 
|---|
| 16 | along with this program; if not, write to the Free Software | 
|---|
| 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 
|---|
| 18 |  | 
|---|
| 19 | Contributed by David Wood @ New York University. */ | 
|---|
| 20 |  | 
|---|
| 21 | #ifndef AMD | 
|---|
| 22 | # define AMD | 
|---|
| 23 | #endif | 
|---|
| 24 |  | 
|---|
| 25 | #define L_LNNO_SIZE 2 | 
|---|
| 26 | #include "coff/external.h" | 
|---|
| 27 |  | 
|---|
| 28 | /* | 
|---|
| 29 | ** Magic numbers for Am29000 | 
|---|
| 30 | **      (AT&T will assign the "real" magic number) | 
|---|
| 31 | */ | 
|---|
| 32 |  | 
|---|
| 33 | #define SIPFBOMAGIC     0572    /* Am29000 (Byte 0 is MSB) */ | 
|---|
| 34 | #define SIPRBOMAGIC     0573    /* Am29000 (Byte 0 is LSB) */ | 
|---|
| 35 |  | 
|---|
| 36 | #define A29K_MAGIC_BIG          SIPFBOMAGIC | 
|---|
| 37 | #define A29K_MAGIC_LITTLE       SIPRBOMAGIC | 
|---|
| 38 | #define A29KBADMAG(x)   ( ((x).f_magic != A29K_MAGIC_BIG) && \ | 
|---|
| 39 | ((x).f_magic != A29K_MAGIC_LITTLE)) | 
|---|
| 40 |  | 
|---|
| 41 | #define OMAGIC A29K_MAGIC_BIG | 
|---|
| 42 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ | 
|---|
| 43 |  | 
|---|
| 44 | /* | 
|---|
| 45 | ** File header flags currently known to us. | 
|---|
| 46 | ** | 
|---|
| 47 | ** Am29000 will use the F_AR32WR and F_AR32W flags to indicate | 
|---|
| 48 | ** the byte ordering in the file. | 
|---|
| 49 | */ | 
|---|
| 50 |  | 
|---|
| 51 | /*--------------------------------------------------------------*/ | 
|---|
| 52 |  | 
|---|
| 53 |  | 
|---|
| 54 | /* aouthdr magic numbers */ | 
|---|
| 55 | #define NMAGIC          0410    /* separate i/d executable */ | 
|---|
| 56 | #define SHMAGIC 0406            /* NYU/Ultra3 shared data executable | 
|---|
| 57 | (writable text) */ | 
|---|
| 58 | #undef  _ETEXT | 
|---|
| 59 | #define _ETEXT          "_etext" | 
|---|
| 60 |  | 
|---|
| 61 | /*--------------------------------------------------------------*/ | 
|---|
| 62 |  | 
|---|
| 63 |  | 
|---|
| 64 | /* More names of "special" sections.  */ | 
|---|
| 65 | #define _LIT    ".lit" | 
|---|
| 66 |  | 
|---|
| 67 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ | 
|---|
| 68 |  | 
|---|
| 69 | /* | 
|---|
| 70 | ** Section types - with additional section type for global | 
|---|
| 71 | ** registers which will be relocatable for the Am29000. | 
|---|
| 72 | ** | 
|---|
| 73 | ** In instances where it is necessary for a linker to produce an | 
|---|
| 74 | ** output file which contains text or data not based at virtual | 
|---|
| 75 | ** address 0, e.g. for a ROM, then the linker should accept | 
|---|
| 76 | ** address base information as command input and use PAD sections | 
|---|
| 77 | ** to skip over unused addresses. | 
|---|
| 78 | */ | 
|---|
| 79 |  | 
|---|
| 80 | #define STYP_BSSREG     0x1200  /* Global register area (like STYP_INFO) */ | 
|---|
| 81 | #define STYP_ENVIR      0x2200  /* Environment (like STYP_INFO) */ | 
|---|
| 82 | #define STYP_ABS        0x4000  /* Absolute (allocated, not reloc, loaded) */ | 
|---|
| 83 |  | 
|---|
| 84 | /*--------------------------------------------------------------*/ | 
|---|
| 85 |  | 
|---|
| 86 | /* | 
|---|
| 87 | ** Relocation information declaration and related definitions | 
|---|
| 88 | */ | 
|---|
| 89 |  | 
|---|
| 90 | struct external_reloc | 
|---|
| 91 | { | 
|---|
| 92 | char r_vaddr[4];      /* (virtual) address of reference */ | 
|---|
| 93 | char r_symndx[4];     /* index into symbol table */ | 
|---|
| 94 | char r_type[2];       /* relocation type */ | 
|---|
| 95 | }; | 
|---|
| 96 |  | 
|---|
| 97 | #define RELOC           struct external_reloc | 
|---|
| 98 | #define RELSZ           10              /* sizeof (RELOC) */ | 
|---|
| 99 |  | 
|---|
| 100 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ | 
|---|
| 101 |  | 
|---|
| 102 | /* | 
|---|
| 103 | ** Relocation types for the Am29000 | 
|---|
| 104 | */ | 
|---|
| 105 |  | 
|---|
| 106 | #define R_ABS           0       /* reference is absolute */ | 
|---|
| 107 |  | 
|---|
| 108 | #define R_IREL          030     /* instruction relative (jmp/call) */ | 
|---|
| 109 | #define R_IABS          031     /* instruction absolute (jmp/call) */ | 
|---|
| 110 | #define R_ILOHALF       032     /* instruction low half  (const)  */ | 
|---|
| 111 | #define R_IHIHALF       033     /* instruction high half (consth) part 1 */ | 
|---|
| 112 | #define R_IHCONST       034     /* instruction high half (consth) part 2 */ | 
|---|
| 113 | /* constant offset of R_IHIHALF relocation */ | 
|---|
| 114 | #define R_BYTE          035     /* relocatable byte value */ | 
|---|
| 115 | #define R_HWORD         036     /* relocatable halfword value */ | 
|---|
| 116 | #define R_WORD          037     /* relocatable word value */ | 
|---|
| 117 |  | 
|---|
| 118 | #define R_IGLBLRC       040     /* instruction global register RC */ | 
|---|
| 119 | #define R_IGLBLRA       041     /* instruction global register RA */ | 
|---|
| 120 | #define R_IGLBLRB       042     /* instruction global register RB */ | 
|---|
| 121 |  | 
|---|
| 122 | /* | 
|---|
| 123 | NOTE: | 
|---|
| 124 | All the "I" forms refer to 29000 instruction formats.  The linker is | 
|---|
| 125 | expected to know how the numeric information is split and/or aligned | 
|---|
| 126 | within the instruction word(s).  R_BYTE works for instructions, too. | 
|---|
| 127 |  | 
|---|
| 128 | If the parameter to a CONSTH instruction is a relocatable type, two | 
|---|
| 129 | relocation records are written.  The first has an r_type of R_IHIHALF | 
|---|
| 130 | (33 octal) and a normal r_vaddr and r_symndx.  The second relocation | 
|---|
| 131 | record has an r_type of R_IHCONST (34 octal), a normal r_vaddr (which | 
|---|
| 132 | is redundant), and an r_symndx containing the 32-bit constant offset | 
|---|
| 133 | to the relocation instead of the actual symbol table index.  This | 
|---|
| 134 | second record is always written, even if the constant offset is zero. | 
|---|
| 135 | The constant fields of the instruction are set to zero. | 
|---|
| 136 | */ | 
|---|
| 137 |  | 
|---|
| 138 | /*--------------------------------------------------------------*/ | 
|---|
| 139 |  | 
|---|
| 140 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ | 
|---|
| 141 |  | 
|---|
| 142 | /* | 
|---|
| 143 | ** Storage class definitions - new classes for global registers. | 
|---|
| 144 | */ | 
|---|
| 145 |  | 
|---|
| 146 | #define C_GLBLREG       19              /* global register */ | 
|---|
| 147 | #define C_EXTREG        20              /* external global register */ | 
|---|
| 148 | #define C_DEFREG        21              /* ext. def. of global register */ | 
|---|