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