15f210c2aSfgsch /* This file is a modified version of 'a.out.h'. It is to be used in all 25f210c2aSfgsch GNU tools modified to support the i80960 (or tools that operate on 35f210c2aSfgsch object files created by such tools). 42159047fSniklas 55f210c2aSfgsch Copyright 2001 Free Software Foundation, Inc. 65f210c2aSfgsch 75f210c2aSfgsch This program is free software; you can redistribute it and/or modify 85f210c2aSfgsch it under the terms of the GNU General Public License as published by 95f210c2aSfgsch the Free Software Foundation; either version 2 of the License, or 105f210c2aSfgsch (at your option) any later version. 115f210c2aSfgsch 125f210c2aSfgsch This program is distributed in the hope that it will be useful, 135f210c2aSfgsch but WITHOUT ANY WARRANTY; without even the implied warranty of 145f210c2aSfgsch MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 155f210c2aSfgsch GNU General Public License for more details. 165f210c2aSfgsch 175f210c2aSfgsch You should have received a copy of the GNU General Public License 185f210c2aSfgsch along with this program; if not, write to the Free Software 195f210c2aSfgsch Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 205f210c2aSfgsch 215f210c2aSfgsch /* All i80960 development is done in a CROSS-DEVELOPMENT environment. I.e., 225f210c2aSfgsch object code is generated on, and executed under the direction of a symbolic 235f210c2aSfgsch debugger running on, a host system. We do not want to be subject to the 245f210c2aSfgsch vagaries of which host it is or whether it supports COFF or a.out format, 255f210c2aSfgsch or anything else. We DO want to: 265f210c2aSfgsch 275f210c2aSfgsch o always generate the same format object files, regardless of host. 285f210c2aSfgsch 295f210c2aSfgsch o have an 'a.out' header that we can modify for our own purposes 305f210c2aSfgsch (the 80960 is typically an embedded processor and may require 315f210c2aSfgsch enhanced linker support that the normal a.out.h header can't 325f210c2aSfgsch accommodate). 335f210c2aSfgsch 345f210c2aSfgsch As for byte-ordering, the following rules apply: 355f210c2aSfgsch 365f210c2aSfgsch o Text and data that is actually downloaded to the target is always 375f210c2aSfgsch in i80960 (little-endian) order. 385f210c2aSfgsch 395f210c2aSfgsch o All other numbers (in the header, symbols, relocation directives) 405f210c2aSfgsch are in host byte-order: object files CANNOT be lifted from a 415f210c2aSfgsch little-end host and used on a big-endian (or vice versa) without 425f210c2aSfgsch modification. 435f210c2aSfgsch ==> THIS IS NO LONGER TRUE USING BFD. WE CAN GENERATE ANY BYTE ORDER 445f210c2aSfgsch FOR THE HEADER, AND READ ANY BYTE ORDER. PREFERENCE WOULD BE TO 455f210c2aSfgsch USE LITTLE-ENDIAN BYTE ORDER THROUGHOUT, REGARDLESS OF HOST. <== 465f210c2aSfgsch 475f210c2aSfgsch o The downloader ('comm960') takes care to generate a pseudo-header 485f210c2aSfgsch with correct (i80960) byte-ordering before shipping text and data 495f210c2aSfgsch off to the NINDY monitor in the target systems. Symbols and 505f210c2aSfgsch relocation info are never sent to the target. */ 512159047fSniklas 522159047fSniklas #define BMAGIC 0415 532159047fSniklas /* We don't accept the following (see N_BADMAG macro). 54*c074d1c9Sdrahn They're just here so GNU code will compile. */ 552159047fSniklas #define OMAGIC 0407 /* old impure format */ 562159047fSniklas #define NMAGIC 0410 /* read-only text */ 572159047fSniklas #define ZMAGIC 0413 /* demand load format */ 582159047fSniklas 592159047fSniklas /* FILE HEADER 60*c074d1c9Sdrahn All 'lengths' are given as a number of bytes. 61*c074d1c9Sdrahn All 'alignments' are for relinkable files only; an alignment of 62*c074d1c9Sdrahn 'n' indicates the corresponding segment must begin at an 63*c074d1c9Sdrahn address that is a multiple of (2**n). */ 64*c074d1c9Sdrahn struct external_exec 65*c074d1c9Sdrahn { 662159047fSniklas /* Standard stuff */ 672159047fSniklas unsigned char e_info[4]; /* Identifies this as a b.out file */ 682159047fSniklas unsigned char e_text[4]; /* Length of text */ 692159047fSniklas unsigned char e_data[4]; /* Length of data */ 702159047fSniklas unsigned char e_bss[4]; /* Length of uninitialized data area */ 712159047fSniklas unsigned char e_syms[4]; /* Length of symbol table */ 722159047fSniklas unsigned char e_entry[4]; /* Runtime start address */ 732159047fSniklas unsigned char e_trsize[4]; /* Length of text relocation info */ 742159047fSniklas unsigned char e_drsize[4]; /* Length of data relocation info */ 752159047fSniklas 762159047fSniklas /* Added for i960 */ 772159047fSniklas unsigned char e_tload[4]; /* Text runtime load address */ 782159047fSniklas unsigned char e_dload[4]; /* Data runtime load address */ 792159047fSniklas unsigned char e_talign[1]; /* Alignment of text segment */ 802159047fSniklas unsigned char e_dalign[1]; /* Alignment of data segment */ 812159047fSniklas unsigned char e_balign[1]; /* Alignment of bss segment */ 822159047fSniklas unsigned char e_relaxable[1];/* Assembled with enough info to allow linker to relax */ 832159047fSniklas }; 842159047fSniklas 852159047fSniklas #define EXEC_BYTES_SIZE (sizeof (struct external_exec)) 862159047fSniklas 872159047fSniklas /* These macros use the a_xxx field names, since they operate on the exec 882159047fSniklas structure after it's been byte-swapped and realigned on the host machine. */ 892159047fSniklas #define N_BADMAG(x) (((x).a_info)!=BMAGIC) 902159047fSniklas #define N_TXTOFF(x) EXEC_BYTES_SIZE 912159047fSniklas #define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text ) 922159047fSniklas #define N_TROFF(x) ( N_DATOFF(x) + (x).a_data ) 932159047fSniklas #define N_TRELOFF N_TROFF 942159047fSniklas #define N_DROFF(x) ( N_TROFF(x) + (x).a_trsize ) 952159047fSniklas #define N_DRELOFF N_DROFF 962159047fSniklas #define N_SYMOFF(x) ( N_DROFF(x) + (x).a_drsize ) 972159047fSniklas #define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms ) 982159047fSniklas #define N_DATADDR(x) ( (x).a_dload ) 992159047fSniklas 1002159047fSniklas /* Address of text segment in memory after it is loaded. */ 1012159047fSniklas #if !defined (N_TXTADDR) 1022159047fSniklas #define N_TXTADDR(x) 0 1032159047fSniklas #endif 1042159047fSniklas 105*c074d1c9Sdrahn /* A single entry in the symbol table. */ 106*c074d1c9Sdrahn struct nlist 107*c074d1c9Sdrahn { 108*c074d1c9Sdrahn union 109*c074d1c9Sdrahn { 1102159047fSniklas char* n_name; 1112159047fSniklas struct nlist * n_next; 1122159047fSniklas long n_strx; /* Index into string table */ 1132159047fSniklas } n_un; 114*c074d1c9Sdrahn 1152159047fSniklas unsigned char n_type; /* See below */ 1162159047fSniklas char n_other; /* Used in i80960 support -- see below */ 1172159047fSniklas short n_desc; 1182159047fSniklas unsigned long n_value; 1192159047fSniklas }; 1202159047fSniklas 1212159047fSniklas 122*c074d1c9Sdrahn /* Legal values of n_type. */ 1232159047fSniklas #define N_UNDF 0 /* Undefined symbol */ 1242159047fSniklas #define N_ABS 2 /* Absolute symbol */ 1252159047fSniklas #define N_TEXT 4 /* Text symbol */ 1262159047fSniklas #define N_DATA 6 /* Data symbol */ 1272159047fSniklas #define N_BSS 8 /* BSS symbol */ 1282159047fSniklas #define N_FN 31 /* Filename symbol */ 1292159047fSniklas 1302159047fSniklas #define N_EXT 1 /* External symbol (OR'd in with one of above) */ 1312159047fSniklas #define N_TYPE 036 /* Mask for all the type bits */ 1322159047fSniklas #define N_STAB 0340 /* Mask for all bits used for SDB entries */ 1332159047fSniklas 1342159047fSniklas /* MEANING OF 'n_other' 135*c074d1c9Sdrahn 136*c074d1c9Sdrahn If non-zero, the 'n_other' fields indicates either a leaf procedure or 137*c074d1c9Sdrahn a system procedure, as follows: 138*c074d1c9Sdrahn 139*c074d1c9Sdrahn 1 <= n_other <= 32 : 140*c074d1c9Sdrahn The symbol is the entry point to a system procedure. 141*c074d1c9Sdrahn 'n_value' is the address of the entry, as for any other 142*c074d1c9Sdrahn procedure. The system procedure number (which can be used in 143*c074d1c9Sdrahn a 'calls' instruction) is (n_other-1). These entries come from 144*c074d1c9Sdrahn '.sysproc' directives. 145*c074d1c9Sdrahn 146*c074d1c9Sdrahn n_other == N_CALLNAME 147*c074d1c9Sdrahn the symbol is the 'call' entry point to a leaf procedure. 148*c074d1c9Sdrahn The *next* symbol in the symbol table must be the corresponding 149*c074d1c9Sdrahn 'bal' entry point to the procedure (see following). These 150*c074d1c9Sdrahn entries come from '.leafproc' directives in which two different 151*c074d1c9Sdrahn symbols are specified (the first one is represented here). 152*c074d1c9Sdrahn 153*c074d1c9Sdrahn 154*c074d1c9Sdrahn n_other == N_BALNAME 155*c074d1c9Sdrahn the symbol is the 'bal' entry point to a leaf procedure. 156*c074d1c9Sdrahn These entries result from '.leafproc' directives in which only 157*c074d1c9Sdrahn one symbol is specified, or in which the same symbol is 158*c074d1c9Sdrahn specified twice. 159*c074d1c9Sdrahn 160*c074d1c9Sdrahn Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry, 161*c074d1c9Sdrahn but not every N_BALNAME entry must have an N_CALLNAME entry. */ 1622159047fSniklas #define N_CALLNAME ((char)-1) 1632159047fSniklas #define N_BALNAME ((char)-2) 1642159047fSniklas #define IS_CALLNAME(x) (N_CALLNAME == (x)) 1652159047fSniklas #define IS_BALNAME(x) (N_BALNAME == (x)) 1662159047fSniklas #define IS_OTHER(x) ((x)>0 && (x) <=32) 1672159047fSniklas 1682159047fSniklas #define b_out_relocation_info relocation_info 169*c074d1c9Sdrahn struct relocation_info 170*c074d1c9Sdrahn { 171*c074d1c9Sdrahn int r_address; /* File address of item to be relocated. */ 1722159047fSniklas unsigned 1732159047fSniklas #define r_index r_symbolnum 1742159047fSniklas r_symbolnum:24, /* Index of symbol on which relocation is based, 175*c074d1c9Sdrahn if r_extern is set. Otherwise set to 176*c074d1c9Sdrahn either N_TEXT, N_DATA, or N_BSS to 177*c074d1c9Sdrahn indicate section on which relocation is 178*c074d1c9Sdrahn based. */ 1792159047fSniklas r_pcrel:1, /* 1 => relocate PC-relative; else absolute 180*c074d1c9Sdrahn On i960, pc-relative implies 24-bit 181*c074d1c9Sdrahn address, absolute implies 32-bit. */ 1822159047fSniklas r_length:2, /* Number of bytes to relocate: 183*c074d1c9Sdrahn 0 => 1 byte 184*c074d1c9Sdrahn 1 => 2 bytes -- used for 13 bit pcrel 185*c074d1c9Sdrahn 2 => 4 bytes. */ 1862159047fSniklas r_extern:1, 187*c074d1c9Sdrahn r_bsr:1, /* Something for the GNU NS32K assembler. */ 188*c074d1c9Sdrahn r_disp:1, /* Something for the GNU NS32K assembler. */ 189*c074d1c9Sdrahn r_callj:1, /* 1 if relocation target is an i960 'callj'. */ 190*c074d1c9Sdrahn r_relaxable:1; /* 1 if enough info is left to relax the data. */ 1912159047fSniklas }; 192