198b9484cSchristos /* This file is a modified version of 'a.out.h'. It is to be used in all 298b9484cSchristos GNU tools modified to support the i80960 (or tools that operate on 398b9484cSchristos object files created by such tools). 498b9484cSchristos 5*e663ba6eSchristos Copyright (C) 2001-2024 Free Software Foundation, Inc. 698b9484cSchristos 798b9484cSchristos This program is free software; you can redistribute it and/or modify 898b9484cSchristos it under the terms of the GNU General Public License as published by 998b9484cSchristos the Free Software Foundation; either version 3 of the License, or 1098b9484cSchristos (at your option) any later version. 1198b9484cSchristos 1298b9484cSchristos This program is distributed in the hope that it will be useful, 1398b9484cSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of 1498b9484cSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1598b9484cSchristos GNU General Public License for more details. 1698b9484cSchristos 1798b9484cSchristos You should have received a copy of the GNU General Public License 1898b9484cSchristos along with this program; if not, write to the Free Software 1998b9484cSchristos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 2098b9484cSchristos MA 02110-1301, USA. */ 2198b9484cSchristos 2298b9484cSchristos /* All i80960 development is done in a CROSS-DEVELOPMENT environment. I.e., 2398b9484cSchristos object code is generated on, and executed under the direction of a symbolic 2498b9484cSchristos debugger running on, a host system. We do not want to be subject to the 2598b9484cSchristos vagaries of which host it is or whether it supports COFF or a.out format, 2698b9484cSchristos or anything else. We DO want to: 2798b9484cSchristos 2898b9484cSchristos o always generate the same format object files, regardless of host. 2998b9484cSchristos 3098b9484cSchristos o have an 'a.out' header that we can modify for our own purposes 3198b9484cSchristos (the 80960 is typically an embedded processor and may require 3298b9484cSchristos enhanced linker support that the normal a.out.h header can't 3398b9484cSchristos accommodate). 3498b9484cSchristos 3598b9484cSchristos As for byte-ordering, the following rules apply: 3698b9484cSchristos 3798b9484cSchristos o Text and data that is actually downloaded to the target is always 3898b9484cSchristos in i80960 (little-endian) order. 3998b9484cSchristos 4098b9484cSchristos o All other numbers (in the header, symbols, relocation directives) 4198b9484cSchristos are in host byte-order: object files CANNOT be lifted from a 4298b9484cSchristos little-end host and used on a big-endian (or vice versa) without 4398b9484cSchristos modification. 4498b9484cSchristos ==> THIS IS NO LONGER TRUE USING BFD. WE CAN GENERATE ANY BYTE ORDER 4598b9484cSchristos FOR THE HEADER, AND READ ANY BYTE ORDER. PREFERENCE WOULD BE TO 4698b9484cSchristos USE LITTLE-ENDIAN BYTE ORDER THROUGHOUT, REGARDLESS OF HOST. <== 4798b9484cSchristos 4898b9484cSchristos o The downloader ('comm960') takes care to generate a pseudo-header 4998b9484cSchristos with correct (i80960) byte-ordering before shipping text and data 5098b9484cSchristos off to the NINDY monitor in the target systems. Symbols and 5198b9484cSchristos relocation info are never sent to the target. */ 5298b9484cSchristos 5398b9484cSchristos #define BMAGIC 0415 5498b9484cSchristos /* We don't accept the following (see N_BADMAG macro). 5598b9484cSchristos They're just here so GNU code will compile. */ 5698b9484cSchristos #define OMAGIC 0407 /* old impure format */ 5798b9484cSchristos #define NMAGIC 0410 /* read-only text */ 5898b9484cSchristos #define ZMAGIC 0413 /* demand load format */ 5998b9484cSchristos 6098b9484cSchristos /* FILE HEADER 6198b9484cSchristos All 'lengths' are given as a number of bytes. 6298b9484cSchristos All 'alignments' are for relinkable files only; an alignment of 6398b9484cSchristos 'n' indicates the corresponding segment must begin at an 6498b9484cSchristos address that is a multiple of (2**n). */ 6598b9484cSchristos struct external_exec 6698b9484cSchristos { 6798b9484cSchristos /* Standard stuff */ 6898b9484cSchristos unsigned char e_info[4]; /* Identifies this as a b.out file */ 6998b9484cSchristos unsigned char e_text[4]; /* Length of text */ 7098b9484cSchristos unsigned char e_data[4]; /* Length of data */ 7198b9484cSchristos unsigned char e_bss[4]; /* Length of uninitialized data area */ 7298b9484cSchristos unsigned char e_syms[4]; /* Length of symbol table */ 7398b9484cSchristos unsigned char e_entry[4]; /* Runtime start address */ 7498b9484cSchristos unsigned char e_trsize[4]; /* Length of text relocation info */ 7598b9484cSchristos unsigned char e_drsize[4]; /* Length of data relocation info */ 7698b9484cSchristos 7798b9484cSchristos /* Added for i960 */ 7898b9484cSchristos unsigned char e_tload[4]; /* Text runtime load address */ 7998b9484cSchristos unsigned char e_dload[4]; /* Data runtime load address */ 8098b9484cSchristos unsigned char e_talign[1]; /* Alignment of text segment */ 8198b9484cSchristos unsigned char e_dalign[1]; /* Alignment of data segment */ 8298b9484cSchristos unsigned char e_balign[1]; /* Alignment of bss segment */ 8398b9484cSchristos unsigned char e_relaxable[1];/* Assembled with enough info to allow linker to relax */ 8498b9484cSchristos }; 8598b9484cSchristos 8698b9484cSchristos #define EXEC_BYTES_SIZE (sizeof (struct external_exec)) 8798b9484cSchristos 8898b9484cSchristos /* These macros use the a_xxx field names, since they operate on the exec 8998b9484cSchristos structure after it's been byte-swapped and realigned on the host machine. */ 90ba340e45Schristos #define N_BADMAG(x) (((x)->a_info)!=BMAGIC) 9198b9484cSchristos #define N_TXTOFF(x) EXEC_BYTES_SIZE 92ba340e45Schristos #define N_DATOFF(x) ( N_TXTOFF(x) + (x)->a_text ) 93ba340e45Schristos #define N_TROFF(x) ( N_DATOFF(x) + (x)->a_data ) 9498b9484cSchristos #define N_TRELOFF N_TROFF 95ba340e45Schristos #define N_DROFF(x) ( N_TROFF(x) + (x)->a_trsize ) 9698b9484cSchristos #define N_DRELOFF N_DROFF 97ba340e45Schristos #define N_SYMOFF(x) ( N_DROFF(x) + (x)->a_drsize ) 98ba340e45Schristos #define N_STROFF(x) ( N_SYMOFF(x) + (x)->a_syms ) 99ba340e45Schristos #define N_DATADDR(x) ( (x)->a_dload ) 10098b9484cSchristos 10198b9484cSchristos /* Address of text segment in memory after it is loaded. */ 10298b9484cSchristos #if !defined (N_TXTADDR) 10398b9484cSchristos #define N_TXTADDR(x) 0 10498b9484cSchristos #endif 10598b9484cSchristos 10698b9484cSchristos /* A single entry in the symbol table. */ 10798b9484cSchristos struct nlist 10898b9484cSchristos { 10998b9484cSchristos union 11098b9484cSchristos { 11198b9484cSchristos char* n_name; 11298b9484cSchristos struct nlist * n_next; 11398b9484cSchristos long n_strx; /* Index into string table */ 11498b9484cSchristos } n_un; 11598b9484cSchristos 11698b9484cSchristos unsigned char n_type; /* See below */ 11798b9484cSchristos char n_other; /* Used in i80960 support -- see below */ 11898b9484cSchristos short n_desc; 11998b9484cSchristos unsigned long n_value; 12098b9484cSchristos }; 12198b9484cSchristos 12298b9484cSchristos 12398b9484cSchristos /* Legal values of n_type. */ 12498b9484cSchristos #define N_UNDF 0 /* Undefined symbol */ 12598b9484cSchristos #define N_ABS 2 /* Absolute symbol */ 12698b9484cSchristos #define N_TEXT 4 /* Text symbol */ 12798b9484cSchristos #define N_DATA 6 /* Data symbol */ 12898b9484cSchristos #define N_BSS 8 /* BSS symbol */ 12998b9484cSchristos #define N_FN 31 /* Filename symbol */ 13098b9484cSchristos 13198b9484cSchristos #define N_EXT 1 /* External symbol (OR'd in with one of above) */ 13298b9484cSchristos #define N_TYPE 036 /* Mask for all the type bits */ 13398b9484cSchristos #define N_STAB 0340 /* Mask for all bits used for SDB entries */ 13498b9484cSchristos 13598b9484cSchristos /* MEANING OF 'n_other' 13698b9484cSchristos 13798b9484cSchristos If non-zero, the 'n_other' fields indicates either a leaf procedure or 13898b9484cSchristos a system procedure, as follows: 13998b9484cSchristos 14098b9484cSchristos 1 <= n_other <= 32 : 14198b9484cSchristos The symbol is the entry point to a system procedure. 14298b9484cSchristos 'n_value' is the address of the entry, as for any other 14398b9484cSchristos procedure. The system procedure number (which can be used in 14498b9484cSchristos a 'calls' instruction) is (n_other-1). These entries come from 14598b9484cSchristos '.sysproc' directives. 14698b9484cSchristos 14798b9484cSchristos n_other == N_CALLNAME 14898b9484cSchristos the symbol is the 'call' entry point to a leaf procedure. 14998b9484cSchristos The *next* symbol in the symbol table must be the corresponding 15098b9484cSchristos 'bal' entry point to the procedure (see following). These 15198b9484cSchristos entries come from '.leafproc' directives in which two different 15298b9484cSchristos symbols are specified (the first one is represented here). 15398b9484cSchristos 15498b9484cSchristos 15598b9484cSchristos n_other == N_BALNAME 15698b9484cSchristos the symbol is the 'bal' entry point to a leaf procedure. 15798b9484cSchristos These entries result from '.leafproc' directives in which only 15898b9484cSchristos one symbol is specified, or in which the same symbol is 15998b9484cSchristos specified twice. 16098b9484cSchristos 16198b9484cSchristos Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry, 16298b9484cSchristos but not every N_BALNAME entry must have an N_CALLNAME entry. */ 16398b9484cSchristos #define N_CALLNAME ((char)-1) 16498b9484cSchristos #define N_BALNAME ((char)-2) 16598b9484cSchristos #define IS_CALLNAME(x) (N_CALLNAME == (x)) 16698b9484cSchristos #define IS_BALNAME(x) (N_BALNAME == (x)) 16798b9484cSchristos #define IS_OTHER(x) ((x)>0 && (x) <=32) 16898b9484cSchristos 16998b9484cSchristos #define b_out_relocation_info relocation_info 17098b9484cSchristos struct relocation_info 17198b9484cSchristos { 17298b9484cSchristos int r_address; /* File address of item to be relocated. */ 17398b9484cSchristos unsigned 17498b9484cSchristos #define r_index r_symbolnum 17598b9484cSchristos r_symbolnum:24, /* Index of symbol on which relocation is based, 17698b9484cSchristos if r_extern is set. Otherwise set to 17798b9484cSchristos either N_TEXT, N_DATA, or N_BSS to 17898b9484cSchristos indicate section on which relocation is 17998b9484cSchristos based. */ 18098b9484cSchristos r_pcrel:1, /* 1 => relocate PC-relative; else absolute 18198b9484cSchristos On i960, pc-relative implies 24-bit 18298b9484cSchristos address, absolute implies 32-bit. */ 18398b9484cSchristos r_length:2, /* Number of bytes to relocate: 18498b9484cSchristos 0 => 1 byte 18598b9484cSchristos 1 => 2 bytes -- used for 13 bit pcrel 18698b9484cSchristos 2 => 4 bytes. */ 18798b9484cSchristos r_extern:1, 18898b9484cSchristos r_bsr:1, /* Something for the GNU NS32K assembler. */ 18998b9484cSchristos r_disp:1, /* Something for the GNU NS32K assembler. */ 19098b9484cSchristos r_callj:1, /* 1 if relocation target is an i960 'callj'. */ 19198b9484cSchristos r_relaxable:1; /* 1 if enough info is left to relax the data. */ 19298b9484cSchristos }; 193