Blame include/bout.h

Packit bbfece
/* This file is a modified version of 'a.out.h'.  It is to be used in all
Packit bbfece
   GNU tools modified to support the i80960 (or tools that operate on
Packit bbfece
   object files created by such tools).
Packit bbfece
Packit bbfece
   Copyright (C) 2001-2018 Free Software Foundation, Inc.
Packit bbfece
Packit bbfece
   This program is free software; you can redistribute it and/or modify
Packit bbfece
   it under the terms of the GNU General Public License as published by
Packit bbfece
   the Free Software Foundation; either version 3 of the License, or
Packit bbfece
   (at your option) any later version.
Packit bbfece
Packit bbfece
   This program is distributed in the hope that it will be useful,
Packit bbfece
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit bbfece
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit bbfece
   GNU General Public License for more details.
Packit bbfece
Packit bbfece
   You should have received a copy of the GNU General Public License
Packit bbfece
   along with this program; if not, write to the Free Software
Packit bbfece
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
Packit bbfece
   MA 02110-1301, USA.  */
Packit bbfece
 
Packit bbfece
/* All i80960 development is done in a CROSS-DEVELOPMENT environment.  I.e.,
Packit bbfece
   object code is generated on, and executed under the direction of a symbolic
Packit bbfece
   debugger running on, a host system.  We do not want to be subject to the
Packit bbfece
   vagaries of which host it is or whether it supports COFF or a.out format,
Packit bbfece
   or anything else.  We DO want to:
Packit bbfece
  
Packit bbfece
  	o always generate the same format object files, regardless of host.
Packit bbfece
 
Packit bbfece
 	o have an 'a.out' header that we can modify for our own purposes
Packit bbfece
 	  (the 80960 is typically an embedded processor and may require
Packit bbfece
 	  enhanced linker support that the normal a.out.h header can't
Packit bbfece
 	  accommodate).
Packit bbfece
 
Packit bbfece
  As for byte-ordering, the following rules apply:
Packit bbfece
 
Packit bbfece
 	o Text and data that is actually downloaded to the target is always
Packit bbfece
 	  in i80960 (little-endian) order.
Packit bbfece
 
Packit bbfece
 	o All other numbers (in the header, symbols, relocation directives)
Packit bbfece
 	  are in host byte-order:  object files CANNOT be lifted from a
Packit bbfece
 	  little-end host and used on a big-endian (or vice versa) without
Packit bbfece
 	  modification.
Packit bbfece
  ==> THIS IS NO LONGER TRUE USING BFD.  WE CAN GENERATE ANY BYTE ORDER
Packit bbfece
      FOR THE HEADER, AND READ ANY BYTE ORDER.  PREFERENCE WOULD BE TO
Packit bbfece
      USE LITTLE-ENDIAN BYTE ORDER THROUGHOUT, REGARDLESS OF HOST.  <==
Packit bbfece
 
Packit bbfece
 	o The downloader ('comm960') takes care to generate a pseudo-header
Packit bbfece
 	  with correct (i80960) byte-ordering before shipping text and data
Packit bbfece
 	  off to the NINDY monitor in the target systems.  Symbols and
Packit bbfece
 	  relocation info are never sent to the target.  */
Packit bbfece
Packit bbfece
#define BMAGIC	0415
Packit bbfece
/* We don't accept the following (see N_BADMAG macro).
Packit bbfece
   They're just here so GNU code will compile.  */
Packit bbfece
#define	OMAGIC	0407		/* old impure format */
Packit bbfece
#define	NMAGIC	0410		/* read-only text */
Packit bbfece
#define	ZMAGIC	0413		/* demand load format */
Packit bbfece
Packit bbfece
/* FILE HEADER
Packit bbfece
  	All 'lengths' are given as a number of bytes.
Packit bbfece
  	All 'alignments' are for relinkable files only;  an alignment of
Packit bbfece
  		'n' indicates the corresponding segment must begin at an
Packit bbfece
  		address that is a multiple of (2**n).  */
Packit bbfece
struct external_exec
Packit bbfece
  {
Packit bbfece
    /* Standard stuff */
Packit bbfece
    unsigned char e_info[4];	/* Identifies this as a b.out file */
Packit bbfece
    unsigned char e_text[4];	/* Length of text */
Packit bbfece
    unsigned char e_data[4];	/* Length of data */
Packit bbfece
    unsigned char e_bss[4];	/* Length of uninitialized data area */
Packit bbfece
    unsigned char e_syms[4];	/* Length of symbol table */
Packit bbfece
    unsigned char e_entry[4];	/* Runtime start address */
Packit bbfece
    unsigned char e_trsize[4];	/* Length of text relocation info */
Packit bbfece
    unsigned char e_drsize[4];	/* Length of data relocation info */
Packit bbfece
Packit bbfece
    /* Added for i960 */
Packit bbfece
    unsigned char e_tload[4];	/* Text runtime load address */
Packit bbfece
    unsigned char e_dload[4];	/* Data runtime load address */
Packit bbfece
    unsigned char e_talign[1];	/* Alignment of text segment */
Packit bbfece
    unsigned char e_dalign[1];	/* Alignment of data segment */
Packit bbfece
    unsigned char e_balign[1];	/* Alignment of bss segment */
Packit bbfece
    unsigned char e_relaxable[1];/* Assembled with enough info to allow linker to relax */
Packit bbfece
  };
Packit bbfece
Packit bbfece
#define	EXEC_BYTES_SIZE	(sizeof (struct external_exec))
Packit bbfece
Packit bbfece
/* These macros use the a_xxx field names, since they operate on the exec
Packit bbfece
   structure after it's been byte-swapped and realigned on the host machine.  */
Packit bbfece
#define N_BADMAG(x)	(((x)->a_info)!=BMAGIC)
Packit bbfece
#define N_TXTOFF(x)	EXEC_BYTES_SIZE
Packit bbfece
#define N_DATOFF(x)	( N_TXTOFF(x) + (x)->a_text )
Packit bbfece
#define N_TROFF(x)	( N_DATOFF(x) + (x)->a_data )
Packit bbfece
#define N_TRELOFF	N_TROFF
Packit bbfece
#define N_DROFF(x)	( N_TROFF(x) + (x)->a_trsize )
Packit bbfece
#define N_DRELOFF	N_DROFF
Packit bbfece
#define N_SYMOFF(x)	( N_DROFF(x) + (x)->a_drsize )
Packit bbfece
#define N_STROFF(x)	( N_SYMOFF(x) + (x)->a_syms )
Packit bbfece
#define N_DATADDR(x)	( (x)->a_dload )
Packit bbfece
Packit bbfece
/* Address of text segment in memory after it is loaded.  */
Packit bbfece
#if !defined (N_TXTADDR)
Packit bbfece
#define N_TXTADDR(x) 0
Packit bbfece
#endif
Packit bbfece
Packit bbfece
/* A single entry in the symbol table.  */
Packit bbfece
struct nlist
Packit bbfece
  {
Packit bbfece
    union
Packit bbfece
      {
Packit bbfece
	char*          n_name;
Packit bbfece
	struct nlist * n_next;
Packit bbfece
	long	       n_strx;	/* Index into string table	*/
Packit bbfece
      } n_un;
Packit bbfece
Packit bbfece
    unsigned char n_type;	/* See below				*/
Packit bbfece
    char	  n_other;	/* Used in i80960 support -- see below	*/
Packit bbfece
    short	  n_desc;
Packit bbfece
    unsigned long n_value;
Packit bbfece
  };
Packit bbfece
Packit bbfece
Packit bbfece
/* Legal values of n_type.  */
Packit bbfece
#define N_UNDF	0	/* Undefined symbol	*/
Packit bbfece
#define N_ABS	2	/* Absolute symbol	*/
Packit bbfece
#define N_TEXT	4	/* Text symbol		*/
Packit bbfece
#define N_DATA	6	/* Data symbol		*/
Packit bbfece
#define N_BSS	8	/* BSS symbol		*/
Packit bbfece
#define N_FN	31	/* Filename symbol	*/
Packit bbfece
Packit bbfece
#define N_EXT	1	/* External symbol (OR'd in with one of above)	*/
Packit bbfece
#define N_TYPE	036	/* Mask for all the type bits			*/
Packit bbfece
#define N_STAB	0340	/* Mask for all bits used for SDB entries 	*/
Packit bbfece
Packit bbfece
/* MEANING OF 'n_other'
Packit bbfece
 
Packit bbfece
  If non-zero, the 'n_other' fields indicates either a leaf procedure or
Packit bbfece
  a system procedure, as follows:
Packit bbfece
 
Packit bbfece
 	1 <= n_other <= 32 :
Packit bbfece
 		The symbol is the entry point to a system procedure.
Packit bbfece
 		'n_value' is the address of the entry, as for any other
Packit bbfece
 		procedure.  The system procedure number (which can be used in
Packit bbfece
 		a 'calls' instruction) is (n_other-1).  These entries come from
Packit bbfece
 		'.sysproc' directives.
Packit bbfece
 
Packit bbfece
 	n_other == N_CALLNAME
Packit bbfece
 		the symbol is the 'call' entry point to a leaf procedure.
Packit bbfece
 		The *next* symbol in the symbol table must be the corresponding
Packit bbfece
 		'bal' entry point to the procedure (see following).  These
Packit bbfece
 		entries come from '.leafproc' directives in which two different
Packit bbfece
 		symbols are specified (the first one is represented here).
Packit bbfece
 	
Packit bbfece
 
Packit bbfece
 	n_other == N_BALNAME
Packit bbfece
 		the symbol is the 'bal' entry point to a leaf procedure.
Packit bbfece
 		These entries result from '.leafproc' directives in which only
Packit bbfece
 		one symbol is specified, or in which the same symbol is
Packit bbfece
 		specified twice.
Packit bbfece
 
Packit bbfece
  Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry,
Packit bbfece
  but not every N_BALNAME entry must have an N_CALLNAME entry.  */
Packit bbfece
#define N_CALLNAME	((char)-1)
Packit bbfece
#define N_BALNAME	((char)-2)
Packit bbfece
#define IS_CALLNAME(x)	(N_CALLNAME == (x))
Packit bbfece
#define IS_BALNAME(x)	(N_BALNAME == (x))
Packit bbfece
#define IS_OTHER(x)	((x)>0 && (x) <=32)
Packit bbfece
Packit bbfece
#define b_out_relocation_info relocation_info
Packit bbfece
struct relocation_info
Packit bbfece
  {
Packit bbfece
    int	 r_address;	/* File address of item to be relocated.  */
Packit bbfece
    unsigned
Packit bbfece
#define r_index r_symbolnum
Packit bbfece
    r_symbolnum:24,	/* Index of symbol on which relocation is based,
Packit bbfece
			   if r_extern is set.  Otherwise set to
Packit bbfece
			   either N_TEXT, N_DATA, or N_BSS to
Packit bbfece
			   indicate section on which relocation is
Packit bbfece
			   based.  */
Packit bbfece
      r_pcrel:1,	/* 1 => relocate PC-relative; else absolute
Packit bbfece
			   On i960, pc-relative implies 24-bit
Packit bbfece
			   address, absolute implies 32-bit.  */
Packit bbfece
      r_length:2,	/* Number of bytes to relocate:
Packit bbfece
			   0 => 1 byte
Packit bbfece
			   1 => 2 bytes -- used for 13 bit pcrel
Packit bbfece
			   2 => 4 bytes.  */
Packit bbfece
      r_extern:1,
Packit bbfece
      r_bsr:1,		/* Something for the GNU NS32K assembler.  */
Packit bbfece
      r_disp:1,		/* Something for the GNU NS32K assembler.  */
Packit bbfece
      r_callj:1,	/* 1 if relocation target is an i960 'callj'.  */
Packit bbfece
      r_relaxable:1;	/* 1 if enough info is left to relax the data.  */
Packit bbfece
};