GNU gas 1.92.3 based assembler supporting PIC code (for i386 and sparc).

This commit is contained in:
pk 1993-10-02 20:58:21 +00:00
parent 14e337e2bf
commit fe9e2f3d60
90 changed files with 42329 additions and 817 deletions

View File

@ -1,5 +1,5 @@
# from: @(#)Makefile.hp300 6.1 (Berkeley) 3/3/91
# $Id: Makefile.hp300,v 1.2 1993/08/01 05:42:38 mycroft Exp $
# $Id: Makefile.hp300,v 1.3 1993/10/02 20:58:21 pk Exp $
CFLAGS+= -Dm68851
SRCS+= m68k.c atof-ieee.c
SRCS+= tc-m68k.c atof-ieee.c

View File

@ -1,5 +1,5 @@
# from: @(#)Makefile.i386 6.1 (Berkeley) 3/3/91
# $Id: Makefile.i386,v 1.2 1993/08/01 05:42:35 mycroft Exp $
# $Id: Makefile.i386,v 1.3 1993/10/02 20:58:21 pk Exp $
CFLAGS+= -DNON_BROKEN_WORDS
SRCS+= i386.c atof-ieee.c
SRCS+= tc-i386.c atof-ieee.c

View File

@ -0,0 +1,5 @@
# from: @(#)Makefile.i386 6.1 (Berkeley) 3/3/91
# $Id: Makefile.sparc,v 1.1 1993/10/02 20:58:22 pk Exp $
CFLAGS+= -DNON_BROKEN_WORDS
SRCS+= tc-sparc.c atof-ieee.c

View File

@ -1,4 +1,4 @@
# from: @(#)Makefile.vax 6.1 (Berkeley) 3/3/91
# $Id: Makefile.vax,v 1.2 1993/08/01 05:42:32 mycroft Exp $
# $Id: Makefile.vax,v 1.3 1993/10/02 20:58:23 pk Exp $
SRCS+= vax.c atof-vax.c
SRCS+= tc-vax.c atof-vax.c

View File

@ -0,0 +1,424 @@
/* This file is aout.h
Copyright (C) 1987-1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef __A_OUT_GNU_H__
#define __A_OUT_GNU_H__
enum reloc_type {
#ifdef TC_M88K
RELOC_LO16, /* lo16(sym) */
RELOC_HI16, /* hi16(sym) */
RELOC_PC16, /* bb0, bb1, bcnd */
RELOC_PC26, /* br, bsr */
RELOC_32, /* jump tables, etc */
RELOC_IW16, /* global access through linker regs 28 */
NO_RELOC,
#else /* not TC_M88K */
#ifdef TC_I860
/* NOTE: three bits max, see struct reloc_info_i860.r_type */
NO_RELOC = 0, BRADDR, LOW0, LOW1, LOW2, LOW3, LOW4, SPLIT0, SPLIT1, SPLIT2, RELOC_32,
#else /* not TC_I860 */
RELOC_8, RELOC_16, RELOC_32, /* simple relocations */
RELOC_DISP8, RELOC_DISP16, RELOC_DISP32, /* pc-rel displacement */
RELOC_WDISP30, RELOC_WDISP22,
RELOC_HI22, RELOC_22,
RELOC_13, RELOC_LO10,
RELOC_SFA_BASE, RELOC_SFA_OFF13,
RELOC_BASE10, RELOC_BASE13, RELOC_BASE22, /* P.I.C. (base-relative) */
RELOC_PC10, RELOC_PC22, /* for some sort of pc-rel P.I.C. (?) */
RELOC_JMP_TBL, /* P.I.C. jump table */
RELOC_SEGOFF16, /* reputedly for shared libraries somehow */
RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE,
#ifndef TC_SPARC
RELOC_11,
RELOC_WDISP2_14,
RELOC_WDISP19,
RELOC_HHI22,
RELOC_HLO10,
/* 29K relocation types */
RELOC_JUMPTARG, RELOC_CONST, RELOC_CONSTH,
RELOC_WDISP14, RELOC_WDISP21,
#endif /* not TC_SPARC */
NO_RELOC,
#endif /* not TC_I860 */
#endif /* not TC_M88K */
};
#ifdef TC_I860
/* NOTE: two bits max, see reloc_info_i860.r_type */
enum highlow_type {
NO_SPEC = 0, PAIR, HIGH, HIGHADJ,
};
#endif /* TC_I860 */
#define __GNU_EXEC_MACROS__
#ifndef __STRUCT_EXEC_OVERRIDE__
/* This is the layout on disk of a Unix V7, Berkeley, SunOS, Vax Ultrix
"struct exec". Don't assume that on this machine, the "struct exec"
will lay out the same sizes or alignments. */
struct exec_bytes {
unsigned char a_info[4];
unsigned char a_text[4];
unsigned char a_data[4];
unsigned char a_bss[4];
unsigned char a_syms[4];
unsigned char a_entry[4];
unsigned char a_trsize[4];
unsigned char a_drsize[4];
};
/* How big the "struct exec" is on disk */
#define EXEC_BYTES_SIZE (8 * 4)
/* This is the layout in memory of a "struct exec" while we process it. */
struct exec
{
unsigned long a_info; /* Use macros N_MAGIC, etc for access */
unsigned a_text; /* length of text, in bytes */
unsigned a_data; /* length of data, in bytes */
unsigned a_bss; /* length of uninitialized data area for file, in bytes */
unsigned a_syms; /* length of symbol table data in file, in bytes */
unsigned a_entry; /* start address */
unsigned a_trsize; /* length of relocation info for text, in bytes */
unsigned a_drsize; /* length of relocation info for data, in bytes */
};
#endif /* __STRUCT_EXEC_OVERRIDE__ */
/* these go in the N_MACHTYPE field */
/* These symbols could be defined by code from Suns...punt 'em */
#undef M_UNKNOWN
#undef M_68010
#undef M_68020
#undef M_SPARC
enum machine_type {
M_UNKNOWN = 0,
M_68010 = 1,
M_68020 = 2,
M_SPARC = 3,
/* skip a bunch so we don't run into any of sun's numbers */
M_386 = 100,
M_29K = 101,
M_RS6000 = 102, /* IBM RS/6000 */
/* HP/BSD formats */
M_HP200 = 200, /* hp200 (68010) BSD binary */
M_HP300 = 300, /* hp300 (68020+68881) BSD binary */
M_HPUX23 = 0x020C, /* hp200/300 HPUX binary */
};
#define N_MAGIC(exec) ((exec).a_info & 0xffff)
#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
#define N_SET_INFO(exec, magic, type, flags) \
((exec).a_info = ((magic) & 0xffff) \
| (((int)(type) & 0xff) << 16) \
| (((flags) & 0xff) << 24))
#define N_SET_MAGIC(exec, magic) \
((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
#define N_SET_MACHTYPE(exec, machtype) \
((exec).a_info = \
((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
#define N_SET_FLAGS(exec, flags) \
((exec).a_info = \
((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
/* Code indicating object file or impure executable. */
#define OMAGIC 0407
/* Code indicating pure executable. */
#define NMAGIC 0410
/* Code indicating demand-paged executable. */
#define ZMAGIC 0413
/* Virtual Address of text segment from the a.out file. For OMAGIC,
(almost always "unlinked .o's" these days), should be zero.
For linked files, should reflect reality if we know it. */
#ifndef N_TXTADDR
#define N_TXTADDR(x) (N_MAGIC(x) == OMAGIC? 0 : TEXT_START_ADDR)
#endif
#ifndef N_BADMAG
#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
&& N_MAGIC(x) != NMAGIC \
&& N_MAGIC(x) != ZMAGIC)
#endif
/* By default, segment size is constant. But on some machines, it can
be a function of the a.out header (e.g. machine type). */
#ifndef N_SEGSIZE
#define N_SEGSIZE(x) SEGMENT_SIZE
#endif
/* This complexity is for encapsulated COFF support */
#ifndef _N_HDROFF
#define _N_HDROFF(x) (N_SEGSIZE(x) - sizeof (struct exec))
#endif
#ifndef N_TXTOFF
#define N_TXTOFF(x) (N_MAGIC(x) == ZMAGIC ? \
_N_HDROFF((x)) + sizeof (struct exec) : \
sizeof (struct exec))
#endif
#ifndef N_DATOFF
#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
#endif
#ifndef N_TRELOFF
#define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data )
#endif
#ifndef N_DRELOFF
#define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize )
#endif
#ifndef N_SYMOFF
#define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize )
#endif
#ifndef N_STROFF
#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
#endif
/* Address of text segment in memory after it is loaded. */
#ifndef N_TXTADDR
#define N_TXTADDR(x) 0
#endif
#ifndef N_DATADDR
#define N_DATADDR(x) \
(N_MAGIC(x) == OMAGIC? (N_TXTADDR(x)+(x).a_text) \
: (N_SEGSIZE(x) + ((N_TXTADDR(x)+(x).a_text-1) & ~(N_SEGSIZE(x)-1))))
#endif
/* Address of bss segment in memory after it is loaded. */
#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
struct nlist {
union {
char *n_name;
struct nlist *n_next;
long n_strx;
} n_un;
unsigned char n_type;
char n_other;
short n_desc;
unsigned long n_value;
};
#define N_UNDF 0
#define N_ABS 2
#define N_TEXT 4
#define N_DATA 6
#define N_BSS 8
#define N_COMM 0x12 /* common (visible in shared lib commons) */
#define N_FN 0x1F /* File name of a .o file */
/* Note: N_EXT can only usefully be OR-ed with N_UNDF, N_ABS, N_TEXT,
N_DATA, or N_BSS. When the low-order bit of other types is set,
(e.g. N_WARNING versus N_FN), they are two different types. */
#define N_EXT 1
#define N_TYPE 036
#define N_STAB 0340
/* The following type indicates the definition of a symbol as being
an indirect reference to another symbol. The other symbol
appears as an undefined reference, immediately following this symbol.
Indirection is asymmetrical. The other symbol's value will be used
to satisfy requests for the indirect symbol, but not vice versa.
If the other symbol does not have a definition, libraries will
be searched to find a definition. */
#define N_INDR 0xa
/* The following type indicates the size of the symbol it refers to */
#define N_SIZE 0xc
/* The following symbols refer to set elements.
All the N_SET[ATDB] symbols with the same name form one set.
Space is allocated for the set in the text section, and each set
element's value is stored into one word of the space.
The first word of the space is the length of the set (number of elements).
The address of the set is made into an N_SETV symbol
whose name is the same as the name of the set.
This symbol acts like a N_DATA global symbol
in that it can satisfy undefined external references. */
/* These appear as input to LD, in a .o file. */
#define N_SETA 0x14 /* Absolute set element symbol */
#define N_SETT 0x16 /* Text set element symbol */
#define N_SETD 0x18 /* Data set element symbol */
#define N_SETB 0x1A /* Bss set element symbol */
/* This is output from LD. */
#define N_SETV 0x1C /* Pointer to set vector in data area. */
/* Warning symbol. The text gives a warning message, the next symbol
in the table will be undefined. When the symbol is referenced, the
message is printed. */
#define N_WARNING 0x1e
/* This structure describes a single relocation to be performed.
The text-relocation section of the file is a vector of these structures,
all of which apply to the text section.
Likewise, the data-relocation section applies to the data section. */
/* The following enum and struct were borrowed from SunOS's
/usr/include/sun4/a.out.h and extended to handle
other machines. It is currently used on SPARC and AMD 29000.
reloc_ext_bytes is how it looks on disk. reloc_info_extended is
how we might process it on a native host. */
struct reloc_ext_bytes {
unsigned char r_address[4];
unsigned char r_index[3];
unsigned char r_bits[1];
unsigned char r_addend[4];
};
struct reloc_info_i860
{
unsigned long r_address;
/*
* Using bit fields here is a bad idea because the order is not portable. :-(
*/
unsigned int r_symbolnum: 24;
unsigned int r_pcrel : 1;
unsigned int r_extern : 1;
/* combining the two field simplifies the argument passing in "new_fix()" */
/* and is compatible with the existing Sparc #ifdef's */
/* r_type: highlow_type - bits 5,4; reloc_type - bits 3-0 */
unsigned int r_type : 6;
long r_addend;
};
#define RELOC_EXT_BITS_EXTERN_BIG 0x80
#define RELOC_EXT_BITS_EXTERN_LITTLE 0x01
#define RELOC_EXT_BITS_TYPE_BIG 0x1F
#define RELOC_EXT_BITS_TYPE_SH_BIG 0
#define RELOC_EXT_BITS_TYPE_LITTLE 0xF8
#define RELOC_EXT_BITS_TYPE_SH_LITTLE 3
#define RELOC_EXT_SIZE 12 /* Bytes per relocation entry */
struct reloc_info_extended
{
unsigned long r_address;
unsigned int r_index:24;
# define r_symbolnum r_index
unsigned r_extern:1;
unsigned :2;
/* RS/6000 compiler does not support enum bitfield
enum reloc_type r_type:5; */
enum reloc_type r_type;
long int r_addend;
};
/* The standard, old-fashioned, Berkeley compatible relocation struct */
struct reloc_std_bytes {
unsigned char r_address[4];
unsigned char r_index[3];
unsigned char r_bits[1];
};
#define RELOC_STD_BITS_PCREL_BIG 0x80
#define RELOC_STD_BITS_PCREL_LITTLE 0x01
#define RELOC_STD_BITS_LENGTH_BIG 0x60
#define RELOC_STD_BITS_LENGTH_SH_BIG 5 /* To shift to units place */
#define RELOC_STD_BITS_LENGTH_LITTLE 0x06
#define RELOC_STD_BITS_LENGTH_SH_LITTLE 1
#define RELOC_STD_BITS_EXTERN_BIG 0x10
#define RELOC_STD_BITS_EXTERN_LITTLE 0x08
#define RELOC_STD_BITS_BASEREL_BIG 0x08
#define RELOC_STD_BITS_BASEREL_LITTLE 0x08
#define RELOC_STD_BITS_JMPTABLE_BIG 0x04
#define RELOC_STD_BITS_JMPTABLE_LITTLE 0x04
#define RELOC_STD_BITS_RELATIVE_BIG 0x02
#define RELOC_STD_BITS_RELATIVE_LITTLE 0x02
#define RELOC_STD_SIZE 8 /* Bytes per relocation entry */
#ifndef CUSTOM_RELOC_FORMAT
struct relocation_info {
/* Address (within segment) to be relocated. */
int r_address;
/* The meaning of r_symbolnum depends on r_extern. */
unsigned int r_symbolnum:24;
/* Nonzero means value is a pc-relative offset
and it should be relocated for changes in its own address
as well as for changes in the symbol or section specified. */
unsigned int r_pcrel:1;
/* Length (as exponent of 2) of the field to be relocated.
Thus, a value of 2 indicates 1<<2 bytes. */
unsigned int r_length:2;
/* 1 => relocate with value of symbol.
r_symbolnum is the index of the symbol
in file's the symbol table.
0 => relocate with the address of a segment.
r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
(the N_EXT bit may be set also, but signifies nothing). */
unsigned int r_extern:1;
/* The next three bits are for SunOS shared libraries, and seem to
be undocumented. */
unsigned int r_baserel:1; /* Linkage table relative */
unsigned int r_jmptable:1; /* pc-relative to jump table */
#ifdef TC_NS32K
#define r_bsr r_baserel
#define r_disp r_jmptable
#endif /* TC_NS32K */
unsigned int r_relative:1; /* "relative relocation" */
/* unused */
unsigned int r_pad:1; /* Padding -- set to zero */
};
#endif /* CUSTOM_RELOC_FORMAT */
#endif /* __A_OUT_GNU_H__ */
/* end of aout.h */

View File

@ -1,181 +1,188 @@
/* atof_ieee.c - turn a Flonum into an IEEE floating point number
Copyright (C) 1987 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
Copyright (C) 1987, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef lint
static char rcsid[] = "$Id: atof-ieee.c,v 1.2 1993/08/02 17:26:43 mycroft Exp $";
#endif /* not lint */
#include "flonum.h"
#ifdef USG
#define bzero(s,n) memset(s,0,n)
#define bcopy(from,to,n) memcpy((to),(from),(n))
static char rcsid[] = "$Id: atof-ieee.c,v 1.3 1993/10/02 20:58:25 pk Exp $";
#endif
#include "as.h"
extern FLONUM_TYPE generic_floating_point_number; /* Flonums returned here. */
#ifndef NULL
#define NULL (0)
#endif
extern char EXP_CHARS[];
/* Precision in LittleNums. */
/* Precision in LittleNums. */
#define MAX_PRECISION (6)
#define F_PRECISION (2)
#define D_PRECISION (4)
#define X_PRECISION (6)
#define P_PRECISION (6)
/* Length in LittleNums of guard bits. */
/* Length in LittleNums of guard bits. */
#define GUARD (2)
static unsigned long int mask [] = {
0x00000000,
0x00000001,
0x00000003,
0x00000007,
0x0000000f,
0x0000001f,
0x0000003f,
0x0000007f,
0x000000ff,
0x000001ff,
0x000003ff,
0x000007ff,
0x00000fff,
0x00001fff,
0x00003fff,
0x00007fff,
0x0000ffff,
0x0001ffff,
0x0003ffff,
0x0007ffff,
0x000fffff,
0x001fffff,
0x003fffff,
0x007fffff,
0x00ffffff,
0x01ffffff,
0x03ffffff,
0x07ffffff,
0x0fffffff,
0x1fffffff,
0x3fffffff,
0x7fffffff,
0xffffffff
};
static unsigned long mask[] = {
0x00000000,
0x00000001,
0x00000003,
0x00000007,
0x0000000f,
0x0000001f,
0x0000003f,
0x0000007f,
0x000000ff,
0x000001ff,
0x000003ff,
0x000007ff,
0x00000fff,
0x00001fff,
0x00003fff,
0x00007fff,
0x0000ffff,
0x0001ffff,
0x0003ffff,
0x0007ffff,
0x000fffff,
0x001fffff,
0x003fffff,
0x007fffff,
0x00ffffff,
0x01ffffff,
0x03ffffff,
0x07ffffff,
0x0fffffff,
0x1fffffff,
0x3fffffff,
0x7fffffff,
0xffffffff,
};
static int bits_left_in_littlenum;
static int littlenums_left;
static LITTLENUM_TYPE * littlenum_pointer;
static LITTLENUM_TYPE *littlenum_pointer;
static int
next_bits (number_of_bits)
int number_of_bits;
next_bits (number_of_bits)
int number_of_bits;
{
int return_value;
if(!littlenums_left)
return 0;
if (number_of_bits >= bits_left_in_littlenum)
{
return_value = mask [bits_left_in_littlenum] & *littlenum_pointer;
number_of_bits -= bits_left_in_littlenum;
return_value <<= number_of_bits;
if(--littlenums_left) {
bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits;
littlenum_pointer --;
return_value |= (*littlenum_pointer>>bits_left_in_littlenum) & mask[number_of_bits];
}
}
else
{
bits_left_in_littlenum -= number_of_bits;
return_value = mask [number_of_bits] & (*littlenum_pointer>>bits_left_in_littlenum);
}
return (return_value);
int return_value;
if (!littlenums_left)
return(0);
if (number_of_bits >= bits_left_in_littlenum) {
return_value = mask[bits_left_in_littlenum] & *littlenum_pointer;
number_of_bits -= bits_left_in_littlenum;
return_value <<= number_of_bits;
if (--littlenums_left) {
bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits;
--littlenum_pointer;
return_value |= (*littlenum_pointer >> bits_left_in_littlenum) & mask[number_of_bits];
}
} else {
bits_left_in_littlenum -= number_of_bits;
return_value = mask[number_of_bits] & (*littlenum_pointer >> bits_left_in_littlenum);
}
return(return_value);
}
/* Num had better be less than LITTLENUM_NUMBER_OF_BITS */
static int
unget_bits(num)
static void
unget_bits(num)
int num;
{
if(!littlenums_left) {
if (!littlenums_left) {
++littlenum_pointer;
++littlenums_left;
bits_left_in_littlenum=num;
} else if(bits_left_in_littlenum+num>LITTLENUM_NUMBER_OF_BITS) {
bits_left_in_littlenum= num-(LITTLENUM_NUMBER_OF_BITS-bits_left_in_littlenum);
bits_left_in_littlenum = num;
} else if (bits_left_in_littlenum + num > LITTLENUM_NUMBER_OF_BITS) {
bits_left_in_littlenum = num - (LITTLENUM_NUMBER_OF_BITS - bits_left_in_littlenum);
++littlenum_pointer;
++littlenums_left;
} else
bits_left_in_littlenum+=num;
bits_left_in_littlenum += num;
}
static void
make_invalid_floating_point_number (words)
LITTLENUM_TYPE * words;
make_invalid_floating_point_number(words)
LITTLENUM_TYPE *words;
{
as_warn("cannot create floating-point number");
words[0]= ((unsigned)-1)>>1; /* Zero the leftmost bit */
words[1]= -1;
words[2]= -1;
words[3]= -1;
words[4]= -1;
words[5]= -1;
as_bad("cannot create floating-point number");
words[0] = ((unsigned) -1) >> 1; /* Zero the leftmost bit */
words[1] = -1;
words[2] = -1;
words[3] = -1;
words[4] = -1;
words[5] = -1;
}
/***********************************************************************\
* Warning: this returns 16-bit LITTLENUMs. It is up to the caller *
* to figure out any alignment problems and to conspire for the *
* bytes/word to be emitted in the right order. Bigendians beware! *
* *
\***********************************************************************/
* Warning: this returns 16-bit LITTLENUMs. It is up to the caller *
* to figure out any alignment problems and to conspire for the *
* bytes/word to be emitted in the right order. Bigendians beware! *
* *
\***********************************************************************/
/* Note that atof-ieee always has X and P precisions enabled. it is up
to md_atof to filter them out if the target machine does not support
them. */
char * /* Return pointer past text consumed. */
atof_ieee (str, what_kind, words)
char * str; /* Text to convert to binary. */
char what_kind; /* 'd', 'f', 'g', 'h' */
LITTLENUM_TYPE * words; /* Build the binary here. */
atof_ieee(str, what_kind, words)
char *str; /* Text to convert to binary. */
char what_kind; /* 'd', 'f', 'g', 'h' */
LITTLENUM_TYPE *words; /* Build the binary here. */
{
static LITTLENUM_TYPE bits [MAX_PRECISION + MAX_PRECISION + GUARD];
/* Extra bits for zeroed low-order bits. */
/* The 1st MAX_PRECISION are zeroed, */
/* the last contain flonum bits. */
char * return_value;
int precision; /* Number of 16-bit words in the format. */
long int exponent_bits;
static LITTLENUM_TYPE bits[MAX_PRECISION + MAX_PRECISION + GUARD];
/* Extra bits for zeroed low-order bits. */
/* The 1st MAX_PRECISION are zeroed, */
/* the last contain flonum bits. */
char *return_value;
int precision; /* Number of 16-bit words in the format. */
long exponent_bits;
FLONUM_TYPE save_gen_flonum;
/* We have to save the generic_floating_point_number because it
contains storage allocation about the array of LITTLENUMs
where the value is actually stored. We will allocate our
own array of littlenums below, but have to restore the global
one on exit. */
save_gen_flonum = generic_floating_point_number;
return_value = str;
generic_floating_point_number.low = bits + MAX_PRECISION;
generic_floating_point_number.high = NULL;
generic_floating_point_number.leader = NULL;
generic_floating_point_number.exponent = NULL;
generic_floating_point_number.sign = '\0';
/* Use more LittleNums than seems */
/* necessary: the highest flonum may have */
/* 15 leading 0 bits, so could be useless. */
bzero (bits, sizeof(LITTLENUM_TYPE) * MAX_PRECISION);
switch(what_kind) {
/* Use more LittleNums than seems */
/* necessary: the highest flonum may have */
/* 15 leading 0 bits, so could be useless. */
memset(bits, '\0', sizeof(LITTLENUM_TYPE) * MAX_PRECISION);
switch (what_kind) {
case 'f':
case 'F':
case 's':
@ -183,7 +190,7 @@ atof_ieee (str, what_kind, words)
precision = F_PRECISION;
exponent_bits = 8;
break;
case 'd':
case 'D':
case 'r':
@ -191,7 +198,7 @@ atof_ieee (str, what_kind, words)
precision = D_PRECISION;
exponent_bits = 11;
break;
case 'x':
case 'X':
case 'e':
@ -199,111 +206,115 @@ atof_ieee (str, what_kind, words)
precision = X_PRECISION;
exponent_bits = 15;
break;
case 'p':
case 'P':
precision = P_PRECISION;
exponent_bits= -1;
exponent_bits = -1;
break;
default:
make_invalid_floating_point_number (words);
return NULL;
make_invalid_floating_point_number(words);
return(NULL);
}
generic_floating_point_number.high = generic_floating_point_number.low + precision - 1 + GUARD;
if (atof_generic (& return_value, ".", EXP_CHARS, & generic_floating_point_number)) {
/* as_warn("Error converting floating point number (Exponent overflow?)"); */
make_invalid_floating_point_number (words);
return NULL;
if (atof_generic(&return_value, ".", EXP_CHARS, &generic_floating_point_number)) {
/* as_bad("Error converting floating point number (Exponent overflow?)"); */
make_invalid_floating_point_number(words);
return(NULL);
}
gen_to_words(words, precision, exponent_bits);
return return_value;
/* Restore the generic_floating_point_number's storage alloc
(and everything else). */
generic_floating_point_number = save_gen_flonum;
return(return_value);
}
/* Turn generic_floating_point_number into a real float/double/extended */
gen_to_words(words,precision,exponent_bits)
int gen_to_words(words, precision, exponent_bits)
LITTLENUM_TYPE *words;
long int exponent_bits;
int precision;
long exponent_bits;
{
int return_value=0;
long int exponent_1;
long int exponent_2;
long int exponent_3;
long int exponent_4;
int exponent_skippage;
LITTLENUM_TYPE word1;
LITTLENUM_TYPE * lp;
int return_value = 0;
long exponent_1;
long exponent_2;
long exponent_3;
long exponent_4;
int exponent_skippage;
LITTLENUM_TYPE word1;
LITTLENUM_TYPE *lp;
if (generic_floating_point_number.low > generic_floating_point_number.leader) {
/* 0.0e0 seen. */
if(generic_floating_point_number.sign=='+')
words[0]=0x0000;
if (generic_floating_point_number.sign == '+')
words[0] = 0x0000;
else
words[0]=0x8000;
bzero (&words[1], sizeof(LITTLENUM_TYPE) * (precision-1));
return return_value;
words[0] = 0x8000;
memset(&words[1], '\0', sizeof(LITTLENUM_TYPE) * (precision - 1));
return(return_value);
}
/* NaN: Do the right thing */
if(generic_floating_point_number.sign==0) {
if(precision==F_PRECISION) {
words[0]=0x7fff;
words[1]=0xffff;
if (generic_floating_point_number.sign == 0) {
if (precision == F_PRECISION) {
words[0] = 0x7fff;
words[1] = 0xffff;
} else {
words[0]=0x7fff;
words[1]=0xffff;
words[2]=0xffff;
words[3]=0xffff;
words[0] = 0x7fff;
words[1] = 0xffff;
words[2] = 0xffff;
words[3] = 0xffff;
}
return return_value;
} else if(generic_floating_point_number.sign=='P') {
} else if (generic_floating_point_number.sign == 'P') {
/* +INF: Do the right thing */
if(precision==F_PRECISION) {
words[0]=0x7f80;
words[1]=0;
if (precision == F_PRECISION) {
words[0] = 0x7f80;
words[1] = 0;
} else {
words[0]=0x7ff0;
words[1]=0;
words[2]=0;
words[3]=0;
words[0] = 0x7ff0;
words[1] = 0;
words[2] = 0;
words[3] = 0;
}
return return_value;
} else if(generic_floating_point_number.sign=='N') {
return(return_value);
} else if (generic_floating_point_number.sign == 'N') {
/* Negative INF */
if(precision==F_PRECISION) {
words[0]=0xff80;
words[1]=0x0;
if (precision == F_PRECISION) {
words[0] = 0xff80;
words[1] = 0x0;
} else {
words[0]=0xfff0;
words[1]=0x0;
words[2]=0x0;
words[3]=0x0;
words[0] = 0xfff0;
words[1] = 0x0;
words[2] = 0x0;
words[3] = 0x0;
}
return return_value;
return(return_value);
}
/*
* The floating point formats we support have:
* Bit 15 is sign bit.
* Bits 14:n are excess-whatever exponent.
* Bits n-1:0 (if any) are most significant bits of fraction.
* Bits 15:0 of the next word(s) are the next most significant bits.
*
* So we need: number of bits of exponent, number of bits of
* mantissa.
*/
/*
* The floating point formats we support have:
* Bit 15 is sign bit.
* Bits 14:n are excess-whatever exponent.
* Bits n-1:0 (if any) are most significant bits of fraction.
* Bits 15:0 of the next word(s) are the next most significant bits.
*
* So we need: number of bits of exponent, number of bits of
* mantissa.
*/
bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
littlenum_pointer = generic_floating_point_number.leader;
littlenums_left = 1+generic_floating_point_number.leader - generic_floating_point_number.low;
littlenums_left = 1 + generic_floating_point_number.leader - generic_floating_point_number.low;
/* Seek (and forget) 1st significant bit */
for (exponent_skippage = 0;! next_bits(1); exponent_skippage ++)
;
exponent_1 = generic_floating_point_number.exponent + generic_floating_point_number.leader + 1 -
generic_floating_point_number.low;
for (exponent_skippage = 0; !next_bits(1); ++exponent_skippage) ;;
exponent_1 = generic_floating_point_number.exponent + generic_floating_point_number.leader
+ 1 - generic_floating_point_number.low;
/* Radix LITTLENUM_RADIX, point just higher than generic_floating_point_number.leader. */
exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
/* Radix 2. */
@ -311,152 +322,151 @@ int precision;
/* Forget leading zeros, forget 1st bit. */
exponent_4 = exponent_3 + ((1 << (exponent_bits - 1)) - 2);
/* Offset exponent. */
lp = words;
/* Word 1. Sign, exponent and perhaps high bits. */
word1 = (generic_floating_point_number.sign == '+') ? 0 : (1<<(LITTLENUM_NUMBER_OF_BITS-1));
word1 = (generic_floating_point_number.sign == '+') ? 0 : (1 << (LITTLENUM_NUMBER_OF_BITS - 1));
/* Assume 2's complement integers. */
if(exponent_4<1 && exponent_4>=-62) {
if (exponent_4 < 1 && exponent_4 >= -62) {
int prec_bits;
int num_bits;
unget_bits(1);
num_bits= -exponent_4;
prec_bits=LITTLENUM_NUMBER_OF_BITS*precision-(exponent_bits+1+num_bits);
if(precision==X_PRECISION && exponent_bits==15)
prec_bits-=LITTLENUM_NUMBER_OF_BITS+1;
if(num_bits>=LITTLENUM_NUMBER_OF_BITS-exponent_bits) {
num_bits = -exponent_4;
prec_bits = LITTLENUM_NUMBER_OF_BITS * precision - (exponent_bits + 1 + num_bits);
if (precision == X_PRECISION && exponent_bits == 15)
prec_bits -= LITTLENUM_NUMBER_OF_BITS + 1;
if (num_bits >= LITTLENUM_NUMBER_OF_BITS - exponent_bits) {
/* Bigger than one littlenum */
num_bits-=(LITTLENUM_NUMBER_OF_BITS-1)-exponent_bits;
*lp++=word1;
if(num_bits+exponent_bits+1>=precision*LITTLENUM_NUMBER_OF_BITS) {
num_bits -= (LITTLENUM_NUMBER_OF_BITS - 1) - exponent_bits;
*lp++ = word1;
if (num_bits + exponent_bits + 1 >= precision * LITTLENUM_NUMBER_OF_BITS) {
/* Exponent overflow */
make_invalid_floating_point_number(words);
return return_value;
return(return_value);
}
if(precision==X_PRECISION && exponent_bits==15) {
*lp++=0;
*lp++=0;
num_bits-=LITTLENUM_NUMBER_OF_BITS-1;
if (precision == X_PRECISION && exponent_bits == 15) {
*lp++ = 0;
*lp++ = 0;
num_bits -= LITTLENUM_NUMBER_OF_BITS - 1;
}
while(num_bits>=LITTLENUM_NUMBER_OF_BITS) {
num_bits-=LITTLENUM_NUMBER_OF_BITS;
*lp++=0;
while (num_bits >= LITTLENUM_NUMBER_OF_BITS) {
num_bits -= LITTLENUM_NUMBER_OF_BITS;
*lp++ = 0;
}
if(num_bits)
*lp++=next_bits(LITTLENUM_NUMBER_OF_BITS-(num_bits));
if (num_bits)
*lp++ = next_bits(LITTLENUM_NUMBER_OF_BITS - (num_bits));
} else {
if(precision==X_PRECISION && exponent_bits==15) {
*lp++=word1;
*lp++=0;
if(num_bits==LITTLENUM_NUMBER_OF_BITS) {
*lp++=0;
*lp++=next_bits(LITTLENUM_NUMBER_OF_BITS-1);
} else if(num_bits==LITTLENUM_NUMBER_OF_BITS-1)
*lp++=0;
if (precision == X_PRECISION && exponent_bits == 15) {
*lp++ = word1;
*lp++ = 0;
if (num_bits == LITTLENUM_NUMBER_OF_BITS) {
*lp++ = 0;
*lp++ = next_bits(LITTLENUM_NUMBER_OF_BITS - 1);
} else if (num_bits == LITTLENUM_NUMBER_OF_BITS - 1)
*lp++ = 0;
else
*lp++=next_bits(LITTLENUM_NUMBER_OF_BITS-1-num_bits);
num_bits=0;
*lp++ = next_bits(LITTLENUM_NUMBER_OF_BITS - 1 - num_bits);
num_bits = 0;
} else {
word1|= next_bits ((LITTLENUM_NUMBER_OF_BITS-1) - (exponent_bits+num_bits));
*lp++=word1;
word1 |= next_bits((LITTLENUM_NUMBER_OF_BITS - 1) - (exponent_bits + num_bits));
*lp++ = word1;
}
}
while(lp<words+precision)
*lp++=next_bits(LITTLENUM_NUMBER_OF_BITS);
while (lp < words + precision)
*lp++ = next_bits(LITTLENUM_NUMBER_OF_BITS);
/* Round the mantissa up, but don't change the number */
if(next_bits(1)) {
if (next_bits(1)) {
--lp;
if(prec_bits>LITTLENUM_NUMBER_OF_BITS) {
if (prec_bits > LITTLENUM_NUMBER_OF_BITS) {
int n = 0;
int tmp_bits;
n=0;
tmp_bits=prec_bits;
while(tmp_bits>LITTLENUM_NUMBER_OF_BITS) {
if(lp[n]!=(LITTLENUM_TYPE)-1)
break;
n = 0;
tmp_bits = prec_bits;
while (tmp_bits > LITTLENUM_NUMBER_OF_BITS) {
if (lp[n] != (LITTLENUM_TYPE) - 1)
break;
--n;
tmp_bits-=LITTLENUM_NUMBER_OF_BITS;
tmp_bits -= LITTLENUM_NUMBER_OF_BITS;
}
if(tmp_bits>LITTLENUM_NUMBER_OF_BITS || (lp[n]&mask[tmp_bits])!=mask[tmp_bits]) {
unsigned long int carry;
if (tmp_bits > LITTLENUM_NUMBER_OF_BITS || (lp[n] & mask[tmp_bits]) != mask[tmp_bits]) {
unsigned long carry;
for (carry = 1; carry && (lp >= words); lp --) {
carry = * lp + carry;
* lp = carry;
carry = *lp + carry;
*lp = carry;
carry >>= LITTLENUM_NUMBER_OF_BITS;
}
}
} else if((*lp&mask[prec_bits])!=mask[prec_bits])
lp++;
} else if ((*lp & mask[prec_bits]) != mask[prec_bits])
lp++;
}
return return_value;
} else if (exponent_4 & ~ mask [exponent_bits]) {
/*
* Exponent overflow. Lose immediately.
*/
/*
* We leave return_value alone: admit we read the
* number, but return a floating exception
* because we can't encode the number.
*/
} else if (exponent_4 & ~ mask[exponent_bits]) {
/*
* Exponent overflow. Lose immediately.
*/
/*
* We leave return_value alone: admit we read the
* number, but return a floating exception
* because we can't encode the number.
*/
make_invalid_floating_point_number (words);
return return_value;
} else {
word1 |= (exponent_4 << ((LITTLENUM_NUMBER_OF_BITS-1) - exponent_bits))
| next_bits ((LITTLENUM_NUMBER_OF_BITS-1) - exponent_bits);
word1 |= (exponent_4 << ((LITTLENUM_NUMBER_OF_BITS - 1) - exponent_bits))
| next_bits ((LITTLENUM_NUMBER_OF_BITS - 1) - exponent_bits);
}
* lp ++ = word1;
*lp++ = word1;
/* X_PRECISION is special: it has 16 bits of zero in the middle,
followed by a 1 bit. */
if(exponent_bits==15 && precision==X_PRECISION) {
*lp++=0;
*lp++= 1<<(LITTLENUM_NUMBER_OF_BITS)|next_bits(LITTLENUM_NUMBER_OF_BITS-1);
if (exponent_bits == 15 && precision == X_PRECISION) {
*lp++ = 0;
*lp++ = 1 << (LITTLENUM_NUMBER_OF_BITS) | next_bits(LITTLENUM_NUMBER_OF_BITS - 1);
}
/* The rest of the words are just mantissa bits. */
while(lp < words + precision)
*lp++ = next_bits (LITTLENUM_NUMBER_OF_BITS);
if (next_bits (1)) {
unsigned long int carry;
/*
* Since the NEXT bit is a 1, round UP the mantissa.
* The cunning design of these hidden-1 floats permits
* us to let the mantissa overflow into the exponent, and
* it 'does the right thing'. However, we lose if the
* highest-order bit of the lowest-order word flips.
* Is that clear?
*/
/* #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
Please allow at least 1 more bit in carry than is in a LITTLENUM.
We need that extra bit to hold a carry during a LITTLENUM carry
propagation. Another extra bit (kept 0) will assure us that we
don't get a sticky sign bit after shifting right, and that
permits us to propagate the carry without any masking of bits.
#endif */
for (carry = 1, lp --; carry && (lp >= words); lp --) {
carry = * lp + carry;
* lp = carry;
while (lp < words + precision)
*lp++ = next_bits(LITTLENUM_NUMBER_OF_BITS);
if (next_bits(1)) {
unsigned long carry;
/*
* Since the NEXT bit is a 1, round UP the mantissa.
* The cunning design of these hidden-1 floats permits
* us to let the mantissa overflow into the exponent, and
* it 'does the right thing'. However, we lose if the
* highest-order bit of the lowest-order word flips.
* Is that clear?
*/
/* #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
Please allow at least 1 more bit in carry than is in a LITTLENUM.
We need that extra bit to hold a carry during a LITTLENUM carry
propagation. Another extra bit (kept 0) will assure us that we
don't get a sticky sign bit after shifting right, and that
permits us to propagate the carry without any masking of bits.
#endif */
for (carry = 1, lp--; carry && (lp >= words); lp--) {
carry = *lp + carry;
*lp = carry;
carry >>= LITTLENUM_NUMBER_OF_BITS;
}
if ( (word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)) ) {
if ((word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1))) {
/* We leave return_value alone: admit we read the
* number, but return a floating exception
* because we can't encode the number.
*/
*words&= ~ (1 << (LITTLENUM_NUMBER_OF_BITS - 1));
*words &= ~(1 << (LITTLENUM_NUMBER_OF_BITS - 1));
/* make_invalid_floating_point_number (words); */
/* return return_value; */
}
@ -467,23 +477,23 @@ int precision;
/* This routine is a real kludge. Someone really should do it better, but
I'm too lazy, and I don't understand this stuff all too well anyway
(JF)
*/
*/
void
int_to_gen(x)
int_to_gen(x)
long x;
{
char buf[20];
char *bufp;
sprintf(buf,"%ld",x);
bufp= &buf[0];
if(atof_generic(&bufp,".", EXP_CHARS, &generic_floating_point_number))
as_warn("Error converting number to floating point (Exponent overflow?)");
bufp = &buf[0];
if (atof_generic(&bufp, ".", EXP_CHARS, &generic_floating_point_number))
as_bad("Error converting number to floating point (Exponent overflow?)");
}
#ifdef TEST
char *
print_gen(gen)
print_gen(gen)
FLONUM_TYPE *gen;
{
FLONUM_TYPE f;
@ -491,19 +501,24 @@ FLONUM_TYPE *gen;
double dv;
float fv;
static char sbuf[40];
if(gen) {
f=generic_floating_point_number;
generic_floating_point_number= *gen;
if (gen) {
f = generic_floating_point_number;
generic_floating_point_number = *gen;
}
gen_to_words(&arr[0],4,11);
bcopy(&arr[0],&dv,sizeof(double));
sprintf(sbuf,"%x %x %x %x %.14G ",arr[0],arr[1],arr[2],arr[3],dv);
gen_to_words(&arr[0],2,8);
bcopy(&arr[0],&fv,sizeof(float));
sprintf(sbuf+strlen(sbuf),"%x %x %.12g\n",arr[0],arr[1],fv);
if(gen)
generic_floating_point_number=f;
return sbuf;
gen_to_words(&arr[0], 4, 11);
memcpy(&dv, &arr[0], sizeof(double));
sprintf(sbuf, "%x %x %x %x %.14G ", arr[0], arr[1], arr[2], arr[3], dv);
gen_to_words(&arr[0], 2, 8);
memcpy(&fv, &arr[0], sizeof(float));
sprintf(sbuf + strlen(sbuf), "%x %x %.12g\n", arr[0], arr[1], fv);
if (gen) {
generic_floating_point_number = f;
}
return(sbuf);
}
#endif
/* end of atof-ieee.c */

View File

@ -0,0 +1,436 @@
/* atof_ns32k.c - turn a Flonum into a ns32k floating point number
Copyright (C) 1987 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* this is atof-m68k.c hacked for ns32k */
#include "as.h"
extern FLONUM_TYPE generic_floating_point_number; /* Flonums returned here. */
extern char EXP_CHARS[];
/* Precision in LittleNums. */
#define MAX_PRECISION (4)
#define F_PRECISION (2)
#define D_PRECISION (4)
/* Length in LittleNums of guard bits. */
#define GUARD (2)
int /* Number of chars in flonum type 'letter'. */
atof_sizeof (letter)
char letter;
{
int return_value;
/*
* Permitting uppercase letters is probably a bad idea.
* Please use only lower-cased letters in case the upper-cased
* ones become unsupported!
*/
switch (letter)
{
case 'f':
return_value = F_PRECISION;
break;
case 'd':
return_value = D_PRECISION;
break;
default:
return_value = 0;
break;
}
return (return_value);
}
static unsigned long int mask[] = {
0x00000000,
0x00000001,
0x00000003,
0x00000007,
0x0000000f,
0x0000001f,
0x0000003f,
0x0000007f,
0x000000ff,
0x000001ff,
0x000003ff,
0x000007ff,
0x00000fff,
0x00001fff,
0x00003fff,
0x00007fff,
0x0000ffff,
0x0001ffff,
0x0003ffff,
0x0007ffff,
0x000fffff,
0x001fffff,
0x003fffff,
0x007fffff,
0x00ffffff,
0x01ffffff,
0x03ffffff,
0x07ffffff,
0x0fffffff,
0x1fffffff,
0x3fffffff,
0x7fffffff,
0xffffffff
};
static int bits_left_in_littlenum;
static int littlenums_left;
static LITTLENUM_TYPE * littlenum_pointer;
static int
next_bits (number_of_bits)
int number_of_bits;
{
int return_value;
if (!littlenums_left)
return 0;
if (number_of_bits >= bits_left_in_littlenum)
{
return_value = mask[bits_left_in_littlenum] & *littlenum_pointer;
number_of_bits -= bits_left_in_littlenum;
return_value <<= number_of_bits;
if (littlenums_left) {
bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits;
littlenum_pointer --;
--littlenums_left;
return_value |= (*littlenum_pointer>>bits_left_in_littlenum) & mask[number_of_bits];
}
}
else
{
bits_left_in_littlenum -= number_of_bits;
return_value = mask[number_of_bits] & (*littlenum_pointer>>bits_left_in_littlenum);
}
return (return_value);
}
static void
make_invalid_floating_point_number (words)
LITTLENUM_TYPE * words;
{
words[0]= ((unsigned)-1)>>1; /* Zero the leftmost bit */
words[1]= -1;
words[2]= -1;
words[3]= -1;
}
/***********************************************************************\
* *
* Warning: this returns 16-bit LITTLENUMs, because that is *
* what the VAX thinks in. It is up to the caller to figure *
* out any alignment problems and to conspire for the bytes/word *
* to be emitted in the right order. Bigendians beware! *
* *
\***********************************************************************/
char * /* Return pointer past text consumed. */
atof_ns32k (str, what_kind, words)
char * str; /* Text to convert to binary. */
char what_kind; /* 'd', 'f', 'g', 'h' */
LITTLENUM_TYPE * words; /* Build the binary here. */
{
FLONUM_TYPE f;
LITTLENUM_TYPE bits[MAX_PRECISION + MAX_PRECISION + GUARD];
/* Extra bits for zeroed low-order bits. */
/* The 1st MAX_PRECISION are zeroed, */
/* the last contain flonum bits. */
char * return_value;
int precision; /* Number of 16-bit words in the format. */
long int exponent_bits;
long int exponent_1;
long int exponent_2;
long int exponent_3;
long int exponent_4;
int exponent_skippage;
LITTLENUM_TYPE word1;
LITTLENUM_TYPE * lp;
return_value = str;
f.low = bits + MAX_PRECISION;
f.high = NULL;
f.leader = NULL;
f.exponent = NULL;
f.sign = '\0';
/* Use more LittleNums than seems */
/* necessary: the highest flonum may have */
/* 15 leading 0 bits, so could be useless. */
bzero (bits, sizeof(LITTLENUM_TYPE) * MAX_PRECISION);
switch (what_kind) {
case 'f':
precision = F_PRECISION;
exponent_bits = 8;
break;
case 'd':
precision = D_PRECISION;
exponent_bits = 11;
break;
default:
make_invalid_floating_point_number (words);
return NULL;
}
f.high = f.low + precision - 1 + GUARD;
if (atof_generic (& return_value, ".", EXP_CHARS, & f)) {
as_warn("Error converting floating point number (Exponent overflow?)");
make_invalid_floating_point_number (words);
return NULL;
}
if (f.low > f.leader) {
/* 0.0e0 seen. */
bzero (words, sizeof(LITTLENUM_TYPE) * precision);
return return_value;
}
if (f.sign != '+' && f.sign != '-') {
make_invalid_floating_point_number(words);
return NULL;
}
/*
* All vaxen floating_point formats (so far) have:
* Bit 15 is sign bit.
* Bits 14:n are excess-whatever exponent.
* Bits n-1:0 (if any) are most significant bits of fraction.
* Bits 15:0 of the next word are the next most significant bits.
* And so on for each other word.
*
* So we need: number of bits of exponent, number of bits of
* mantissa.
*/
bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
littlenum_pointer = f.leader;
littlenums_left = 1 + f.leader-f.low;
/* Seek (and forget) 1st significant bit */
for (exponent_skippage = 0;! next_bits(1); exponent_skippage ++)
;
exponent_1 = f.exponent + f.leader + 1 - f.low;
/* Radix LITTLENUM_RADIX, point just higher than f.leader. */
exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
/* Radix 2. */
exponent_3 = exponent_2 - exponent_skippage;
/* Forget leading zeros, forget 1st bit. */
exponent_4 = exponent_3 + ((1 << (exponent_bits - 1)) - 2);
/* Offset exponent. */
if (exponent_4 & ~ mask[exponent_bits]) {
/*
* Exponent overflow. Lose immediately.
*/
/*
* We leave return_value alone: admit we read the
* number, but return a floating exception
* because we can't encode the number.
*/
as_warn("Exponent overflow in floating-point number");
make_invalid_floating_point_number (words);
return return_value;
}
lp = words;
/* Word 1. Sign, exponent and perhaps high bits. */
/* Assume 2's complement integers. */
word1 = ((exponent_4 & mask[exponent_bits]) << (15 - exponent_bits)) |
((f.sign == '+') ? 0 : 0x8000) | next_bits (15 - exponent_bits);
* lp ++ = word1;
/* The rest of the words are just mantissa bits. */
for (; lp < words + precision; lp++)
* lp = next_bits (LITTLENUM_NUMBER_OF_BITS);
if (next_bits (1)) {
unsigned long int carry;
/*
* Since the NEXT bit is a 1, round UP the mantissa.
* The cunning design of these hidden-1 floats permits
* us to let the mantissa overflow into the exponent, and
* it 'does the right thing'. However, we lose if the
* highest-order bit of the lowest-order word flips.
* Is that clear?
*/
/* #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
Please allow at least 1 more bit in carry than is in a LITTLENUM.
We need that extra bit to hold a carry during a LITTLENUM carry
propagation. Another extra bit (kept 0) will assure us that we
don't get a sticky sign bit after shifting right, and that
permits us to propagate the carry without any masking of bits.
#endif */
for (carry = 1, lp --; carry && (lp >= words); lp --) {
carry = * lp + carry;
* lp = carry;
carry >>= LITTLENUM_NUMBER_OF_BITS;
}
if ( (word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)) ) {
/* We leave return_value alone: admit we read the
* number, but return a floating exception
* because we can't encode the number.
*/
make_invalid_floating_point_number (words);
return return_value;
}
}
return (return_value);
}
/* This is really identical to atof_ns32k except for some details */
gen_to_words(words,precision,exponent_bits)
LITTLENUM_TYPE *words;
long int exponent_bits;
{
int return_value=0;
long int exponent_1;
long int exponent_2;
long int exponent_3;
long int exponent_4;
int exponent_skippage;
LITTLENUM_TYPE word1;
LITTLENUM_TYPE * lp;
if (generic_floating_point_number.low > generic_floating_point_number.leader) {
/* 0.0e0 seen. */
bzero (words, sizeof(LITTLENUM_TYPE) * precision);
return return_value;
}
/*
* All vaxen floating_point formats (so far) have:
* Bit 15 is sign bit.
* Bits 14:n are excess-whatever exponent.
* Bits n-1:0 (if any) are most significant bits of fraction.
* Bits 15:0 of the next word are the next most significant bits.
* And so on for each other word.
*
* So we need: number of bits of exponent, number of bits of
* mantissa.
*/
bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
littlenum_pointer = generic_floating_point_number.leader;
littlenums_left = 1+generic_floating_point_number.leader - generic_floating_point_number.low;
/* Seek (and forget) 1st significant bit */
for (exponent_skippage = 0;! next_bits(1); exponent_skippage ++)
;
exponent_1 = generic_floating_point_number.exponent + generic_floating_point_number.leader + 1 -
generic_floating_point_number.low;
/* Radix LITTLENUM_RADIX, point just higher than generic_floating_point_number.leader. */
exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
/* Radix 2. */
exponent_3 = exponent_2 - exponent_skippage;
/* Forget leading zeros, forget 1st bit. */
exponent_4 = exponent_3 + ((1 << (exponent_bits - 1)) - 2);
/* Offset exponent. */
if (exponent_4 & ~ mask[exponent_bits]) {
/*
* Exponent overflow. Lose immediately.
*/
/*
* We leave return_value alone: admit we read the
* number, but return a floating exception
* because we can't encode the number.
*/
make_invalid_floating_point_number (words);
return return_value;
}
lp = words;
/* Word 1. Sign, exponent and perhaps high bits. */
/* Assume 2's complement integers. */
word1 = ((exponent_4 & mask[exponent_bits]) << (15 - exponent_bits)) |
((generic_floating_point_number.sign == '+') ? 0 : 0x8000) | next_bits (15 - exponent_bits);
* lp ++ = word1;
/* The rest of the words are just mantissa bits. */
for (; lp < words + precision; lp++)
* lp = next_bits (LITTLENUM_NUMBER_OF_BITS);
if (next_bits (1)) {
unsigned long int carry;
/*
* Since the NEXT bit is a 1, round UP the mantissa.
* The cunning design of these hidden-1 floats permits
* us to let the mantissa overflow into the exponent, and
* it 'does the right thing'. However, we lose if the
* highest-order bit of the lowest-order word flips.
* Is that clear?
*/
/* #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
Please allow at least 1 more bit in carry than is in a LITTLENUM.
We need that extra bit to hold a carry during a LITTLENUM carry
propagation. Another extra bit (kept 0) will assure us that we
don't get a sticky sign bit after shifting right, and that
permits us to propagate the carry without any masking of bits.
#endif */
for (carry = 1, lp --; carry && (lp >= words); lp --) {
carry = * lp + carry;
* lp = carry;
carry >>= LITTLENUM_NUMBER_OF_BITS;
}
if ( (word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)) ) {
/* We leave return_value alone: admit we read the
* number, but return a floating exception
* because we can't encode the number.
*/
make_invalid_floating_point_number (words);
return return_value;
}
}
return (return_value);
}
/* This routine is a real kludge. Someone really should do it better, but
I'm too lazy, and I don't understand this stuff all too well anyway
(JF)
*/
void int_to_gen(x)
long x;
{
char buf[20];
char *bufp;
sprintf(buf,"%ld",x);
bufp= &buf[0];
if (atof_generic(&bufp,".", EXP_CHARS, &generic_floating_point_number))
as_warn("Error converting number to floating point (Exponent overflow?)");
}

View File

@ -0,0 +1,428 @@
/* atof_tahoe.c - turn a string into a Tahoe floating point number
Copyright (C) 1987 Free Software Foundation, Inc.
*/
/* This is really a simplified version of atof_vax.c. I glommed it wholesale
and then shaved it down. I don't even know how it works. (Don't you find
my honesty refreshing? bowen@cs.Buffalo.EDU (Devon E Bowen)
I don't allow uppercase letters in the precision descrpitors. Ie 'f' and
'd' are allowed but 'F' and 'D' aren't */
#include "as.h"
/* Precision in LittleNums. */
#define MAX_PRECISION (4)
#define D_PRECISION (4)
#define F_PRECISION (2)
/* Precision in chars. */
#define D_PRECISION_CHARS (8)
#define F_PRECISION_CHARS (4)
/* Length in LittleNums of guard bits. */
#define GUARD (2)
static const long int mask [] = {
0x00000000,
0x00000001,
0x00000003,
0x00000007,
0x0000000f,
0x0000001f,
0x0000003f,
0x0000007f,
0x000000ff,
0x000001ff,
0x000003ff,
0x000007ff,
0x00000fff,
0x00001fff,
0x00003fff,
0x00007fff,
0x0000ffff,
0x0001ffff,
0x0003ffff,
0x0007ffff,
0x000fffff,
0x001fffff,
0x003fffff,
0x007fffff,
0x00ffffff,
0x01ffffff,
0x03ffffff,
0x07ffffff,
0x0fffffff,
0x1fffffff,
0x3fffffff,
0x7fffffff,
0xffffffff
};
/* Shared between flonum_gen2tahoe and next_bits */
static int bits_left_in_littlenum;
static LITTLENUM_TYPE * littlenum_pointer;
static LITTLENUM_TYPE * littlenum_end;
#if __STDC__ == 1
int flonum_gen2tahoe(int format_letter, FLONUM_TYPE *f, LITTLENUM_TYPE *words);
#else /* not __STDC__ */
int flonum_gen2tahoe();
#endif /* not __STDC__ */
static int
next_bits (number_of_bits)
int number_of_bits;
{
int return_value;
if(littlenum_pointer<littlenum_end)
return 0;
if (number_of_bits >= bits_left_in_littlenum)
{
return_value = mask [bits_left_in_littlenum] & * littlenum_pointer;
number_of_bits -= bits_left_in_littlenum;
return_value <<= number_of_bits;
bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits;
littlenum_pointer --;
if(littlenum_pointer>=littlenum_end)
return_value |= ((*littlenum_pointer) >> (bits_left_in_littlenum)) &
mask [number_of_bits];
}
else
{
bits_left_in_littlenum -= number_of_bits;
return_value = mask [number_of_bits] &
((*littlenum_pointer) >> bits_left_in_littlenum);
}
return (return_value);
}
static void
make_invalid_floating_point_number (words)
LITTLENUM_TYPE * words;
{
*words = 0x8000; /* Floating Reserved Operand Code */
}
static int /* 0 means letter is OK. */
what_kind_of_float (letter, precisionP, exponent_bitsP)
char letter; /* In: lowercase please. What kind of float? */
int * precisionP; /* Number of 16-bit words in the float. */
long int * exponent_bitsP; /* Number of exponent bits. */
{
int retval; /* 0: OK. */
retval = 0;
switch (letter)
{
case 'f':
* precisionP = F_PRECISION;
* exponent_bitsP = 8;
break;
case 'd':
* precisionP = D_PRECISION;
* exponent_bitsP = 8;
break;
default:
retval = 69;
break;
}
return (retval);
}
/***********************************************************************\
* *
* Warning: this returns 16-bit LITTLENUMs, because that is *
* what the VAX thinks in. It is up to the caller to figure *
* out any alignment problems and to conspire for the bytes/word *
* to be emitted in the right order. Bigendians beware! *
* *
\***********************************************************************/
char * /* Return pointer past text consumed. */
atof_tahoe (str, what_kind, words)
char * str; /* Text to convert to binary. */
char what_kind; /* 'd', 'f', 'g', 'h' */
LITTLENUM_TYPE * words; /* Build the binary here. */
{
FLONUM_TYPE f;
LITTLENUM_TYPE bits [MAX_PRECISION + MAX_PRECISION + GUARD];
/* Extra bits for zeroed low-order bits. */
/* The 1st MAX_PRECISION are zeroed, */
/* the last contain flonum bits. */
char * return_value;
int precision; /* Number of 16-bit words in the format. */
long int exponent_bits;
return_value = str;
f . low = bits + MAX_PRECISION;
f . high = NULL;
f . leader = NULL;
f . exponent = NULL;
f . sign = '\0';
if (what_kind_of_float (what_kind, & precision, & exponent_bits))
{
return_value = NULL; /* We lost. */
make_invalid_floating_point_number (words);
}
if (return_value)
{
memset(bits, '\0', sizeof(LITTLENUM_TYPE) * MAX_PRECISION);
/* Use more LittleNums than seems */
/* necessary: the highest flonum may have */
/* 15 leading 0 bits, so could be useless. */
f . high = f . low + precision - 1 + GUARD;
if (atof_generic (& return_value, ".", "eE", & f))
{
make_invalid_floating_point_number (words);
return_value = NULL; /* we lost */
}
else
{
if (flonum_gen2tahoe (what_kind, & f, words))
{
return_value = NULL;
}
}
}
return (return_value);
}
/*
* In: a flonum, a Tahoe floating point format.
* Out: a Tahoe floating-point bit pattern.
*/
int /* 0: OK. */
flonum_gen2tahoe (format_letter, f, words)
char format_letter; /* One of 'd' 'f'. */
FLONUM_TYPE * f;
LITTLENUM_TYPE * words; /* Deliver answer here. */
{
LITTLENUM_TYPE * lp;
int precision;
long int exponent_bits;
int return_value; /* 0 == OK. */
return_value = what_kind_of_float(format_letter,&precision,&exponent_bits);
if (return_value != 0)
{
make_invalid_floating_point_number (words);
}
else
{
if (f -> low > f -> leader)
{
/* 0.0e0 seen. */
memset(words, '\0', sizeof(LITTLENUM_TYPE) * precision);
}
else
{
long int exponent_1;
long int exponent_2;
long int exponent_3;
long int exponent_4;
int exponent_skippage;
LITTLENUM_TYPE word1;
/* JF: Deal with new Nan, +Inf and -Inf codes */
if(f->sign!='-' && f->sign!='+') {
make_invalid_floating_point_number(words);
return return_value;
}
/*
* All tahoe floating_point formats have:
* Bit 15 is sign bit.
* Bits 14:n are excess-whatever exponent.
* Bits n-1:0 (if any) are most significant bits of fraction.
* Bits 15:0 of the next word are the next most significant bits.
* And so on for each other word.
*
* So we need: number of bits of exponent, number of bits of
* mantissa.
*/
bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
littlenum_pointer = f -> leader;
littlenum_end = f->low;
/* Seek (and forget) 1st significant bit */
for (exponent_skippage = 0;
! next_bits(1);
exponent_skippage ++)
{
}
exponent_1 = f -> exponent + f -> leader + 1 - f -> low;
/* Radix LITTLENUM_RADIX, point just higher than f -> leader. */
exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
/* Radix 2. */
exponent_3 = exponent_2 - exponent_skippage;
/* Forget leading zeros, forget 1st bit. */
exponent_4 = exponent_3 + (1 << (exponent_bits - 1));
/* Offset exponent. */
if (exponent_4 & ~ mask [exponent_bits])
{
/*
* Exponent overflow. Lose immediately.
*/
make_invalid_floating_point_number (words);
/*
* We leave return_value alone: admit we read the
* number, but return a floating exception
* because we can't encode the number.
*/
}
else
{
lp = words;
/* Word 1. Sign, exponent and perhaps high bits. */
/* Assume 2's complement integers. */
word1 = ((exponent_4 & mask [exponent_bits]) << (15 - exponent_bits))
| ((f -> sign == '+') ? 0 : 0x8000)
| next_bits (15 - exponent_bits);
* lp ++ = word1;
/* The rest of the words are just mantissa bits. */
for (; lp < words + precision; lp++)
{
* lp = next_bits (LITTLENUM_NUMBER_OF_BITS);
}
if (next_bits (1))
{
/*
* Since the NEXT bit is a 1, round UP the mantissa.
* The cunning design of these hidden-1 floats permits
* us to let the mantissa overflow into the exponent, and
* it 'does the right thing'. However, we lose if the
* highest-order bit of the lowest-order word flips.
* Is that clear?
*/
unsigned long int carry;
/*
#if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
Please allow at least 1 more bit in carry than is in a LITTLENUM.
We need that extra bit to hold a carry during a LITTLENUM carry
propagation. Another extra bit (kept 0) will assure us that we
don't get a sticky sign bit after shifting right, and that
permits us to propagate the carry without any masking of bits.
#endif
*/
for (carry = 1, lp --;
carry && (lp >= words);
lp --)
{
carry = * lp + carry;
* lp = carry;
carry >>= LITTLENUM_NUMBER_OF_BITS;
}
if ( (word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)) )
{
make_invalid_floating_point_number (words);
/*
* We leave return_value alone: admit we read the
* number, but return a floating exception
* because we can't encode the number.
*/
}
} /* if (we needed to round up) */
} /* if (exponent overflow) */
} /* if (0.0e0) */
} /* if (float_type was OK) */
return (return_value);
}
/*
* md_atof()
*
* In: input_line_pointer -> the 1st character of a floating-point
* number.
* 1 letter denoting the type of statement that wants a
* binary floating point number returned.
* Address of where to build floating point literal.
* Assumed to be 'big enough'.
* Address of where to return size of literal (in chars).
*
* Out: Input_line_pointer -> of next char after floating number.
* Error message, or "".
* Floating point literal.
* Number of chars we used for the literal.
*/
char *
md_atof (what_statement_type, literalP, sizeP)
char what_statement_type;
char * literalP;
int * sizeP;
{
LITTLENUM_TYPE words [MAX_PRECISION];
register char kind_of_float;
register int number_of_chars;
register LITTLENUM_TYPE * littlenum_pointer;
switch (what_statement_type)
{
case 'f': /* .ffloat */
case 'd': /* .dfloat */
kind_of_float = what_statement_type;
break;
default:
kind_of_float = 0;
break;
};
if (kind_of_float)
{
register LITTLENUM_TYPE * limit;
input_line_pointer = atof_tahoe (input_line_pointer,
kind_of_float,
words);
/*
* The atof_tahoe() builds up 16-bit numbers.
* Since the assembler may not be running on
* a different-endian machine, be very careful about
* converting words to chars.
*/
number_of_chars = (kind_of_float == 'f' ? F_PRECISION_CHARS :
(kind_of_float == 'd' ? D_PRECISION_CHARS : 0));
know(number_of_chars<=MAX_PRECISION*sizeof(LITTLENUM_TYPE));
limit = words + (number_of_chars / sizeof(LITTLENUM_TYPE));
for (littlenum_pointer = words;
littlenum_pointer < limit;
littlenum_pointer ++)
{
md_number_to_chars(literalP,*littlenum_pointer,
sizeof(LITTLENUM_TYPE));
literalP += sizeof(LITTLENUM_TYPE);
};
}
else
{
number_of_chars = 0;
};
* sizeP = number_of_chars;
return (kind_of_float ? "" : "Bad call to md_atof()");
} /* md_atof() */
/* atof_tahoe.c */

View File

@ -1,115 +1,117 @@
/* atof_vax.c - turn a Flonum into a VAX floating point number
Copyright (C) 1987 Free Software Foundation, Inc.
Copyright (C) 1987, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef lint
static char rcsid[] = "$Id: atof-vax.c,v 1.2 1993/08/02 17:26:46 mycroft Exp $";
#endif /* not lint */
/* JF added these two for md_atof() */
/* JF added these two for md_atof() */
#include "as.h"
#include "read.h"
#include "flonum.h"
/* Precision in LittleNums. */
/* Precision in LittleNums. */
#define MAX_PRECISION (8)
#define H_PRECISION (8)
#define G_PRECISION (4)
#define D_PRECISION (4)
#define F_PRECISION (2)
/* Length in LittleNums of guard bits. */
/* Length in LittleNums of guard bits. */
#define GUARD (2)
#if __STDC__ == 1
int flonum_gen2vax(int format_letter, FLONUM_TYPE *f, LITTLENUM_TYPE *words);
#else /* not __STDC__ */
int flonum_gen2vax();
#endif /* not __STDC__ */
int /* Number of chars in flonum type 'letter'. */
atof_vax_sizeof (letter)
char letter;
atof_vax_sizeof (letter)
char letter;
{
int return_value;
int return_value;
/*
* Permitting uppercase letters is probably a bad idea.
* Please use only lower-cased letters in case the upper-cased
* ones become unsupported!
*/
switch (letter)
{
case 'f':
case 'F':
return_value = 4;
break;
case 'd':
case 'D':
case 'g':
case 'G':
return_value = 8;
break;
case 'h':
case 'H':
return_value = 16;
break;
default:
return_value = 0;
break;
}
return (return_value);
} /* atof_vax_sizeof */
/*
* Permitting uppercase letters is probably a bad idea.
* Please use only lower-cased letters in case the upper-cased
* ones become unsupported!
*/
switch (letter)
{
case 'f':
case 'F':
return_value = 4;
break;
case 'd':
case 'D':
case 'g':
case 'G':
return_value = 8;
break;
case 'h':
case 'H':
return_value = 16;
break;
default:
return_value = 0;
break;
}
return (return_value);
} /* atof_vax_sizeof */
static const long int mask [] = {
0x00000000,
0x00000001,
0x00000003,
0x00000007,
0x0000000f,
0x0000001f,
0x0000003f,
0x0000007f,
0x000000ff,
0x000001ff,
0x000003ff,
0x000007ff,
0x00000fff,
0x00001fff,
0x00003fff,
0x00007fff,
0x0000ffff,
0x0001ffff,
0x0003ffff,
0x0007ffff,
0x000fffff,
0x001fffff,
0x003fffff,
0x007fffff,
0x00ffffff,
0x01ffffff,
0x03ffffff,
0x07ffffff,
0x0fffffff,
0x1fffffff,
0x3fffffff,
0x7fffffff,
0xffffffff
};
static const long mask[] = {
0x00000000,
0x00000001,
0x00000003,
0x00000007,
0x0000000f,
0x0000001f,
0x0000003f,
0x0000007f,
0x000000ff,
0x000001ff,
0x000003ff,
0x000007ff,
0x00000fff,
0x00001fff,
0x00003fff,
0x00007fff,
0x0000ffff,
0x0001ffff,
0x0003ffff,
0x0007ffff,
0x000fffff,
0x001fffff,
0x003fffff,
0x007fffff,
0x00ffffff,
0x01ffffff,
0x03ffffff,
0x07ffffff,
0x0fffffff,
0x1fffffff,
0x3fffffff,
0x7fffffff,
0xffffffff
};
/* Shared between flonum_gen2vax and next_bits */
@ -118,136 +120,131 @@ static LITTLENUM_TYPE * littlenum_pointer;
static LITTLENUM_TYPE * littlenum_end;
static int
next_bits (number_of_bits)
int number_of_bits;
next_bits (number_of_bits)
int number_of_bits;
{
int return_value;
if(littlenum_pointer<littlenum_end)
return 0;
if (number_of_bits >= bits_left_in_littlenum)
{
return_value = mask [bits_left_in_littlenum] & * littlenum_pointer;
number_of_bits -= bits_left_in_littlenum;
return_value <<= number_of_bits;
bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits;
littlenum_pointer --;
if(littlenum_pointer>=littlenum_end)
return_value |= ( (* littlenum_pointer) >> (bits_left_in_littlenum) ) & mask [number_of_bits];
}
else
{
bits_left_in_littlenum -= number_of_bits;
return_value = mask [number_of_bits] & ( (* littlenum_pointer) >> bits_left_in_littlenum);
}
return (return_value);
int return_value;
if (littlenum_pointer<littlenum_end)
return 0;
if (number_of_bits >= bits_left_in_littlenum)
{
return_value = mask[bits_left_in_littlenum] & * littlenum_pointer;
number_of_bits -= bits_left_in_littlenum;
return_value <<= number_of_bits;
bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits;
littlenum_pointer --;
if (littlenum_pointer >= littlenum_end)
return_value |= ( (* littlenum_pointer) >> (bits_left_in_littlenum) ) & mask[number_of_bits];
}
else
{
bits_left_in_littlenum -= number_of_bits;
return_value = mask[number_of_bits] & ( (* littlenum_pointer) >> bits_left_in_littlenum);
}
return (return_value);
}
static void
make_invalid_floating_point_number (words)
LITTLENUM_TYPE * words;
make_invalid_floating_point_number (words)
LITTLENUM_TYPE * words;
{
* words = 0x8000; /* Floating Reserved Operand Code */
* words = 0x8000; /* Floating Reserved Operand Code */
}
static int /* 0 means letter is OK. */
what_kind_of_float (letter, precisionP, exponent_bitsP)
char letter; /* In: lowercase please. What kind of float? */
int * precisionP; /* Number of 16-bit words in the float. */
long int * exponent_bitsP; /* Number of exponent bits. */
what_kind_of_float (letter, precisionP, exponent_bitsP)
char letter; /* In: lowercase please. What kind of float? */
int * precisionP; /* Number of 16-bit words in the float. */
long * exponent_bitsP; /* Number of exponent bits. */
{
int retval; /* 0: OK. */
retval = 0;
switch (letter)
{
case 'f':
* precisionP = F_PRECISION;
* exponent_bitsP = 8;
break;
case 'd':
* precisionP = D_PRECISION;
* exponent_bitsP = 8;
break;
case 'g':
* precisionP = G_PRECISION;
* exponent_bitsP = 11;
break;
case 'h':
* precisionP = H_PRECISION;
* exponent_bitsP = 15;
break;
default:
retval = 69;
break;
}
return (retval);
int retval; /* 0: OK. */
retval = 0;
switch (letter)
{
case 'f':
* precisionP = F_PRECISION;
* exponent_bitsP = 8;
break;
case 'd':
* precisionP = D_PRECISION;
* exponent_bitsP = 8;
break;
case 'g':
* precisionP = G_PRECISION;
* exponent_bitsP = 11;
break;
case 'h':
* precisionP = H_PRECISION;
* exponent_bitsP = 15;
break;
default:
retval = 69;
break;
}
return (retval);
}
/***********************************************************************\
* *
* Warning: this returns 16-bit LITTLENUMs, because that is *
* what the VAX thinks in. It is up to the caller to figure *
* out any alignment problems and to conspire for the bytes/word *
* to be emitted in the right order. Bigendians beware! *
* *
\***********************************************************************/
* *
* Warning: this returns 16-bit LITTLENUMs, because that is *
* what the VAX thinks in. It is up to the caller to figure *
* out any alignment problems and to conspire for the bytes/word *
* to be emitted in the right order. Bigendians beware! *
* *
\***********************************************************************/
char * /* Return pointer past text consumed. */
atof_vax (str, what_kind, words)
char * str; /* Text to convert to binary. */
char what_kind; /* 'd', 'f', 'g', 'h' */
LITTLENUM_TYPE * words; /* Build the binary here. */
char * /* Return pointer past text consumed. */
atof_vax(str, what_kind, words)
char *str; /* Text to convert to binary. */
char what_kind; /* 'd', 'f', 'g', 'h' */
LITTLENUM_TYPE *words; /* Build the binary here. */
{
FLONUM_TYPE f;
LITTLENUM_TYPE bits [MAX_PRECISION + MAX_PRECISION + GUARD];
/* Extra bits for zeroed low-order bits. */
/* The 1st MAX_PRECISION are zeroed, */
/* the last contain flonum bits. */
char * return_value;
int precision; /* Number of 16-bit words in the format. */
long int exponent_bits;
return_value = str;
f . low = bits + MAX_PRECISION;
f . high = NULL;
f . leader = NULL;
f . exponent = NULL;
f . sign = '\0';
if (what_kind_of_float (what_kind, & precision, & exponent_bits))
{
return_value = NULL; /* We lost. */
make_invalid_floating_point_number (words);
}
if (return_value)
{
bzero (bits, sizeof(LITTLENUM_TYPE) * MAX_PRECISION);
/* Use more LittleNums than seems */
/* necessary: the highest flonum may have */
/* 15 leading 0 bits, so could be useless. */
f . high = f . low + precision - 1 + GUARD;
if (atof_generic (& return_value, ".", "eE", & f))
{
make_invalid_floating_point_number (words);
return_value = NULL; /* we lost */
FLONUM_TYPE f;
LITTLENUM_TYPE bits[MAX_PRECISION + MAX_PRECISION + GUARD];
/* Extra bits for zeroed low-order bits. */
/* The 1st MAX_PRECISION are zeroed, */
/* the last contain flonum bits. */
char *return_value;
int precision; /* Number of 16-bit words in the format. */
long exponent_bits;
return_value = str;
f.low = bits + MAX_PRECISION;
f.high = NULL;
f.leader = NULL;
f.exponent = NULL;
f.sign = '\0';
if (what_kind_of_float (what_kind, & precision, & exponent_bits)) {
return_value = NULL; /* We lost. */
make_invalid_floating_point_number (words);
}
else
{
if (flonum_gen2vax (what_kind, & f, words))
{
return_value = NULL;
}
if (return_value) {
memset(bits, '\0', sizeof(LITTLENUM_TYPE) * MAX_PRECISION);
/* Use more LittleNums than seems */
/* necessary: the highest flonum may have */
/* 15 leading 0 bits, so could be useless. */
f.high = f.low + precision - 1 + GUARD;
if (atof_generic (& return_value, ".", "eE", & f)) {
make_invalid_floating_point_number (words);
return_value = NULL; /* we lost */
} else {
if (flonum_gen2vax(what_kind, & f, words)) {
return_value = NULL;
}
}
}
}
return (return_value);
}
return(return_value);
} /* atof_vax() */
/*
* In: a flonum, a vax floating point format.
@ -255,170 +252,156 @@ atof_vax (str, what_kind, words)
*/
int /* 0: OK. */
flonum_gen2vax (format_letter, f, words)
char format_letter; /* One of 'd' 'f' 'g' 'h'. */
FLONUM_TYPE * f;
LITTLENUM_TYPE * words; /* Deliver answer here. */
flonum_gen2vax (format_letter, f, words)
char format_letter; /* One of 'd' 'f' 'g' 'h'. */
FLONUM_TYPE *f;
LITTLENUM_TYPE *words; /* Deliver answer here. */
{
LITTLENUM_TYPE * lp;
int precision;
long int exponent_bits;
int return_value; /* 0 == OK. */
return_value = what_kind_of_float (format_letter, & precision, & exponent_bits);
if (return_value != 0)
{
make_invalid_floating_point_number (words);
}
else
{
if (f -> low > f -> leader)
{
/* 0.0e0 seen. */
bzero (words, sizeof(LITTLENUM_TYPE) * precision);
}
else
{
long int exponent_1;
long int exponent_2;
long int exponent_3;
long int exponent_4;
int exponent_skippage;
LITTLENUM_TYPE word1;
/* JF: Deal with new Nan, +Inf and -Inf codes */
if(f->sign!='-' && f->sign!='+') {
make_invalid_floating_point_number(words);
return return_value;
}
/*
* All vaxen floating_point formats (so far) have:
* Bit 15 is sign bit.
* Bits 14:n are excess-whatever exponent.
* Bits n-1:0 (if any) are most significant bits of fraction.
* Bits 15:0 of the next word are the next most significant bits.
* And so on for each other word.
*
* All this to be compatible with a KF11?? (Which is still faster
* than lots of vaxen I can think of, but it also has higher
* maintenance costs ... sigh).
*
* So we need: number of bits of exponent, number of bits of
* mantissa.
*/
LITTLENUM_TYPE *lp;
int precision;
long exponent_bits;
int return_value; /* 0 == OK. */
return_value = what_kind_of_float(format_letter, &precision, &exponent_bits);
if (return_value != 0) {
make_invalid_floating_point_number (words);
} else {
if (f->low > f->leader) {
/* 0.0e0 seen. */
memset(words, '\0', sizeof(LITTLENUM_TYPE) * precision);
} else {
long exponent_1;
long exponent_2;
long exponent_3;
long exponent_4;
int exponent_skippage;
LITTLENUM_TYPE word1;
/* JF: Deal with new Nan, +Inf and -Inf codes */
if (f->sign != '-' && f->sign != '+') {
make_invalid_floating_point_number(words);
return return_value;
}
/*
* All vaxen floating_point formats (so far) have:
* Bit 15 is sign bit.
* Bits 14:n are excess-whatever exponent.
* Bits n-1:0 (if any) are most significant bits of fraction.
* Bits 15:0 of the next word are the next most significant bits.
* And so on for each other word.
*
* All this to be compatible with a KF11?? (Which is still faster
* than lots of vaxen I can think of, but it also has higher
* maintenance costs ... sigh).
*
* So we need: number of bits of exponent, number of bits of
* mantissa.
*/
#ifdef NEVER /******* This zeroing seems redundant - Dean 3may86 **********/
/*
* No matter how few bits we got back from the atof()
* routine, add enough zero littlenums so the rest of the
* code won't run out of "significant" bits in the mantissa.
*/
{
LITTLENUM_TYPE * ltp;
for (ltp = f -> leader + 1;
ltp <= f -> low + precision;
ltp ++)
{
* ltp = 0;
}
}
/*
* No matter how few bits we got back from the atof()
* routine, add enough zero littlenums so the rest of the
* code won't run out of "significant" bits in the mantissa.
*/
{
LITTLENUM_TYPE *ltp;
for (ltp = f->leader + 1;
ltp <= f->low + precision;
ltp++) {
*ltp = 0;
}
}
#endif
bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
littlenum_pointer = f -> leader;
littlenum_end = f->low;
/* Seek (and forget) 1st significant bit */
for (exponent_skippage = 0;
! next_bits(1);
exponent_skippage ++)
{
}
exponent_1 = f -> exponent + f -> leader + 1 - f -> low;
/* Radix LITTLENUM_RADIX, point just higher than f -> leader. */
exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
/* Radix 2. */
exponent_3 = exponent_2 - exponent_skippage;
/* Forget leading zeros, forget 1st bit. */
exponent_4 = exponent_3 + (1 << (exponent_bits - 1));
/* Offset exponent. */
if (exponent_4 & ~ mask [exponent_bits])
{
/*
* Exponent overflow. Lose immediately.
*/
make_invalid_floating_point_number (words);
/*
* We leave return_value alone: admit we read the
* number, but return a floating exception
* because we can't encode the number.
*/
}
else
{
lp = words;
/* Word 1. Sign, exponent and perhaps high bits. */
/* Assume 2's complement integers. */
word1 = ((exponent_4 & mask [exponent_bits]) << (15 - exponent_bits))
| ((f -> sign == '+') ? 0 : 0x8000)
| next_bits (15 - exponent_bits);
* lp ++ = word1;
/* The rest of the words are just mantissa bits. */
for (; lp < words + precision; lp++)
{
* lp = next_bits (LITTLENUM_NUMBER_OF_BITS);
}
if (next_bits (1))
{
/*
* Since the NEXT bit is a 1, round UP the mantissa.
* The cunning design of these hidden-1 floats permits
* us to let the mantissa overflow into the exponent, and
* it 'does the right thing'. However, we lose if the
* highest-order bit of the lowest-order word flips.
* Is that clear?
*/
unsigned long int carry;
/*
#if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
Please allow at least 1 more bit in carry than is in a LITTLENUM.
We need that extra bit to hold a carry during a LITTLENUM carry
propagation. Another extra bit (kept 0) will assure us that we
don't get a sticky sign bit after shifting right, and that
permits us to propagate the carry without any masking of bits.
#endif
*/
for (carry = 1, lp --;
carry && (lp >= words);
lp --)
{
carry = * lp + carry;
* lp = carry;
carry >>= LITTLENUM_NUMBER_OF_BITS;
}
if ( (word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)) )
{
make_invalid_floating_point_number (words);
/*
* We leave return_value alone: admit we read the
* number, but return a floating exception
* because we can't encode the number.
*/
}
} /* if (we needed to round up) */
} /* if (exponent overflow) */
} /* if (0.0e0) */
} /* if (float_type was OK) */
return (return_value);
}
bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
littlenum_pointer = f->leader;
littlenum_end = f->low;
/* Seek (and forget) 1st significant bit */
for (exponent_skippage = 0;
! next_bits(1);
exponent_skippage ++) ;;
exponent_1 = f->exponent + f->leader + 1 - f->low;
/* Radix LITTLENUM_RADIX, point just higher than f->leader. */
exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
/* Radix 2. */
exponent_3 = exponent_2 - exponent_skippage;
/* Forget leading zeros, forget 1st bit. */
exponent_4 = exponent_3 + (1 << (exponent_bits - 1));
/* Offset exponent. */
if (exponent_4 & ~mask[exponent_bits]) {
/*
* Exponent overflow. Lose immediately.
*/
make_invalid_floating_point_number (words);
/*
* We leave return_value alone: admit we read the
* number, but return a floating exception
* because we can't encode the number.
*/
} else {
lp = words;
/* Word 1. Sign, exponent and perhaps high bits. */
/* Assume 2's complement integers. */
word1 = (((exponent_4 &mask[exponent_bits]) << (15 - exponent_bits))
| ((f->sign == '+') ? 0 : 0x8000)
| next_bits(15 - exponent_bits));
*lp++ = word1;
/* The rest of the words are just mantissa bits. */
for (; lp < words + precision; lp++) {
*lp = next_bits(LITTLENUM_NUMBER_OF_BITS);
}
if (next_bits (1)) {
/*
* Since the NEXT bit is a 1, round UP the mantissa.
* The cunning design of these hidden-1 floats permits
* us to let the mantissa overflow into the exponent, and
* it 'does the right thing'. However, we lose if the
* highest-order bit of the lowest-order word flips.
* Is that clear?
*/
unsigned long carry;
/*
#if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
Please allow at least 1 more bit in carry than is in a LITTLENUM.
We need that extra bit to hold a carry during a LITTLENUM carry
propagation. Another extra bit (kept 0) will assure us that we
don't get a sticky sign bit after shifting right, and that
permits us to propagate the carry without any masking of bits.
#endif
*/
for (carry = 1, lp--;
carry && (lp >= words);
lp--) {
carry = *lp + carry;
*lp = carry;
carry >>= LITTLENUM_NUMBER_OF_BITS;
}
if ((word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1))) {
make_invalid_floating_point_number(words);
/*
* We leave return_value alone: admit we read the
* number, but return a floating exception
* because we can't encode the number.
*/
}
} /* if (we needed to round up) */
} /* if (exponent overflow) */
} /* if (0.0e0) */
} /* if (float_type was OK) */
return(return_value);
} /* flonum_gen2vax() */
/* JF this used to be in vax.c but this looks like a better place for it */
@ -426,7 +409,7 @@ flonum_gen2vax (format_letter, f, words)
/*
* md_atof()
*
* In: input_line_pointer -> the 1st character of a floating-point
* In: input_line_pointer->the 1st character of a floating-point
* number.
* 1 letter denoting the type of statement that wants a
* binary floating point number returned.
@ -434,84 +417,81 @@ flonum_gen2vax (format_letter, f, words)
* Assumed to be 'big enough'.
* Address of where to return size of literal (in chars).
*
* Out: Input_line_pointer -> of next char after floating number.
* Out: Input_line_pointer->of next char after floating number.
* Error message, or "".
* Floating point literal.
* Number of chars we used for the literal.
*/
int atof_vax_sizeof();
#define MAXIMUM_NUMBER_OF_LITTLENUMS (8) /* For .hfloats. */
char *
md_atof (what_statement_type, literalP, sizeP)
char what_statement_type;
char * literalP;
int * sizeP;
md_atof (what_statement_type, literalP, sizeP)
char what_statement_type;
char * literalP;
int * sizeP;
{
LITTLENUM_TYPE words [MAXIMUM_NUMBER_OF_LITTLENUMS];
register char kind_of_float;
register int number_of_chars;
register LITTLENUM_TYPE * littlenum_pointer;
switch (what_statement_type)
{
case 'F': /* .float */
case 'f': /* .ffloat */
kind_of_float = 'f';
break;
case 'D': /* .double */
case 'd': /* .dfloat */
kind_of_float = 'd';
break;
case 'g': /* .gfloat */
kind_of_float = 'g';
break;
case 'h': /* .hfloat */
kind_of_float = 'h';
break;
default:
kind_of_float = 0;
break;
};
if (kind_of_float)
{
register LITTLENUM_TYPE * limit;
char * atof_vax();
input_line_pointer = atof_vax (input_line_pointer,
kind_of_float,
words);
/*
* The atof_vax() builds up 16-bit numbers.
* Since the assembler may not be running on
* a little-endian machine, be very careful about
* converting words to chars.
*/
number_of_chars = atof_vax_sizeof (kind_of_float);
know( number_of_chars <= MAXIMUM_NUMBER_OF_LITTLENUMS * sizeof(LITTLENUM_TYPE) );
limit = words + (number_of_chars / sizeof(LITTLENUM_TYPE));
for (littlenum_pointer = words;
littlenum_pointer < limit;
littlenum_pointer ++)
{
md_number_to_chars (literalP, * littlenum_pointer, sizeof(LITTLENUM_TYPE));
literalP += sizeof(LITTLENUM_TYPE);
};
}
else
{
number_of_chars = 0;
};
* sizeP = number_of_chars;
return (kind_of_float ? "" : "Bad call to md_atof()");
LITTLENUM_TYPE words[MAXIMUM_NUMBER_OF_LITTLENUMS];
register char kind_of_float;
register int number_of_chars;
register LITTLENUM_TYPE * littlenum_pointer;
switch (what_statement_type)
{
case 'F': /* .float */
case 'f': /* .ffloat */
kind_of_float = 'f';
break;
case 'D': /* .double */
case 'd': /* .dfloat */
kind_of_float = 'd';
break;
case 'g': /* .gfloat */
kind_of_float = 'g';
break;
case 'h': /* .hfloat */
kind_of_float = 'h';
break;
default:
kind_of_float = 0;
break;
};
if (kind_of_float)
{
register LITTLENUM_TYPE * limit;
input_line_pointer = atof_vax (input_line_pointer,
kind_of_float,
words);
/*
* The atof_vax() builds up 16-bit numbers.
* Since the assembler may not be running on
* a little-endian machine, be very careful about
* converting words to chars.
*/
number_of_chars = atof_vax_sizeof (kind_of_float);
know( number_of_chars <= MAXIMUM_NUMBER_OF_LITTLENUMS * sizeof(LITTLENUM_TYPE) );
limit = words + (number_of_chars / sizeof(LITTLENUM_TYPE));
for (littlenum_pointer = words;
littlenum_pointer < limit;
littlenum_pointer ++)
{
md_number_to_chars (literalP, * littlenum_pointer, sizeof(LITTLENUM_TYPE));
literalP += sizeof(LITTLENUM_TYPE);
};
}
else
{
number_of_chars = 0;
};
* sizeP = number_of_chars;
return (kind_of_float ? "" : "Bad call to md_atof()");
} /* md_atof() */
/* atof_vax.c */
/* end of atof-vax.c */

View File

@ -0,0 +1,783 @@
/* coff.h
Copyright (C) 1987, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* At this point I'm sure this file is right for i960 and I'm pretty sure it's
* right for a29k, although it hasn't been tested rigorously. Please feel free
* to add your own machine's description here. Without that info, it isn't
* possible to build cross development tools from elsewhere nor is it easy to
* continue to support your machines format.
*
* The TC_foo ifdef's are mine. They are what gas uses. The other ifdef's
* remain for documentation from other scavenged files. xoxorich.
*/
/********************** FILE HEADER **********************/
struct filehdr {
unsigned short f_magic; /* magic number */
unsigned short f_nscns; /* number of sections */
long f_timdat; /* time & date stamp */
long f_symptr; /* file pointer to symtab */
long f_nsyms; /* number of symtab entries */
unsigned short f_opthdr; /* sizeof(optional hdr) */
unsigned short f_flags; /* flags */
};
/* Bits for f_flags:
* F_RELFLG relocation info stripped from file
* F_EXEC file is executable (no unresolved externel references)
* F_LNNO line nunbers stripped from file
* F_LSYMS local symbols stripped from file
* F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax)
*/
#define F_RELFLG (0x0001)
#define F_EXEC (0x0002)
#define F_LNNO (0x0004)
#define F_LSYMS (0x0008)
#ifdef TC_I960
#define F_AR32WR (0x0010) /* File has 32 bits per word, least
significant byte first. */
#else /* TC_I960 */
#define F_AR32WR (0x0100)
#endif /* TC_I960 */
#define F_MINMAL (0x0010) /* ??? */
#define F_UPDATE (0x0020) /* ??? */
#define F_SWABD (0x0040) /* ??? */
#define F_AR16WR (0x0080) /* File has the byte ordering used by
the PDP*-11/70 processor. */
#define F_AR32W (0x0200) /* File has 32 bits per word, most
significant byte first. */
/*
* Intel 80960 (I960) processor flags.
* F_I960TYPE == mask for processor type field.
*/
#define F_I960TYPE (0xf000)
#define F_I960CORE (0x1000)
#define F_I960KB (0x2000)
#define F_I960SB (0x2000)
#define F_I960MC (0x3000)
#define F_I960XA (0x4000)
#define F_I960CA (0x5000)
#define F_I960KA (0x6000)
#define F_I960SA (0x6000)
/*
* i80960 Magic Numbers
*/
#define I960ROMAGIC (0x160) /* read-only text segments */
#define I960RWMAGIC (0x161) /* read-write text segments */
#define I960BADMAG(x) (((x).f_magic != I960ROMAGIC) && ((x).f_magic != I960RWMAGIC))
#define SIPFBOMAGIC (0x17a) /* Am29000 (Byte 0 is MSB - Big Endian) */
#define SIPRBOMAGIC (0x17b) /* Am29000 (Byte 0 is LSB - Little Endian) */
#define A29KBADMAG(x) (((x).f_magic != SIPFBOMAGIC) && ((x).f_magic != SIPRBOMAGIC))
#ifdef TE_I386AIX
# define I386MAGIC (0x175) /* Danbury AIX C compiler */
# define I386SVMAGIC (0x14c) /* System V C Compiler */
# define I386BADMAG(x) (((x).f_magic != I386MAGIC) && \
((x).f_magic != I386SVMAGIC))
#else /* not TE_I386AIX */
# define I386MAGIC 0x14c
# define I386BADMAG(x) (((x).f_magic != I386MAGIC))
#endif /* not TE_I386AIX */
#define FILHDR struct filehdr
#define FILHSZ sizeof(FILHDR)
/********************** AOUT "OPTIONAL HEADER" **********************/
typedef struct {
unsigned long phys_addr;
unsigned long bitarray;
} TAGBITS;
/* These appear to be used only by exec(2). I don't know who cares
about them in a cross development environment. In any case, this
is my collection after researching the issue for a few hours.
Apparently, most have these have remained essentially unchanged
since v7 days, although a few new ones have been added. xoxorich. */
#define BAD0MAGIC (0401) /* (?) "lpd (UNIX/RT)" */
#define BAD1MAGIC (0405) /* (?) overlay */
#define OMAGIC (0407) /* old impure format. data immediately
follows text. both sections are rw. */
#define NMAGIC (0410) /* split i&d, read-only text */
#define A_MAGIC3 (0411) /* (?) "separated I&D" */
#define ZMAGIC (0413) /* like NMAGIC, but demand loaded */
#define PAGEMAGIC2 (0414) /* (?) like ZMAGIC, but address zero
explicitly unmapped. */
#define REGMAGIC (0414) /* (?) a PAGEMAGIC2 alias? */
#define PAGEMAGIC3 (0415) /* (?) like ZMAGIC, but address zero mapped. */
#define A_MAGIC5 (0437) /* (?) "system overlay, separated I&D" */
/* intended for non-unix cross development */
#define SASMAGIC (010000) /* Single Address Space */
#define MASMAGIC (020000) /* (?) "Multiple (separate I & D) Address Spaces" */
typedef struct aouthdr {
short magic; /* type of file */
short vstamp; /* version stamp */
unsigned long tsize; /* text size in bytes, padded to FW bdry*/
unsigned long dsize; /* initialized data " " */
unsigned long bsize; /* uninitialized data " " */
#if U3B
unsigned long dum1;
unsigned long dum2; /* pad to entry point */
#endif
unsigned long entry; /* entry pt. */
unsigned long text_start; /* base of text used for this file */
unsigned long data_start; /* base of data used for this file */
/* CAREFUL: some formats omit the tagentries member. */
unsigned long tagentries; /* number of tag entries to
follow (always zero for i960) */
} AOUTHDR;
/* return a pointer to the tag bits array */
#define TAGPTR(aout) ((TAGBITS *) (&(aout.tagentries)+1))
/* compute size of a header */
/*#define AOUTSZ(aout) (sizeof(AOUTHDR)+(aout.tagentries*sizeof(TAGBITS)))*/
#define AOUTSZ (sizeof(AOUTHDR))
/********************** STORAGE CLASSES **********************/
#define C_EFCN -1 /* physical end of function */
#define C_NULL 0
#define C_AUTO 1 /* automatic variable */
#define C_EXT 2 /* external symbol */
#define C_STAT 3 /* static */
#define C_REG 4 /* register variable */
#define C_EXTDEF 5 /* external definition */
#define C_LABEL 6 /* label */
#define C_ULABEL 7 /* undefined label */
#define C_MOS 8 /* member of structure */
#define C_ARG 9 /* function argument */
#define C_STRTAG 10 /* structure tag */
#define C_MOU 11 /* member of union */
#define C_UNTAG 12 /* union tag */
#define C_TPDEF 13 /* type definition */
#define C_USTATIC 14 /* undefined static */
#define C_ENTAG 15 /* enumeration tag */
#define C_MOE 16 /* member of enumeration */
#define C_REGPARM 17 /* register parameter */
#define C_FIELD 18 /* bit field */
#ifdef TC_I960
#define C_AUTOARG 19 /* auto argument */
#define C_LASTENT 20 /* dummy entry (end of block) */
#endif /* TC_I960 */
#ifdef TC_A29K
#define C_GLBLREG 19 /* global register */
#define C_EXTREG 20 /* external global register */
#define C_DEFREG 21 /* ext. def. of global register */
#define C_STARTOF 22 /* as29 $SIZEOF and $STARTOF symbols */
#endif /* TC_A29K */
#define C_BLOCK 100 /* ".bb" or ".eb" */
#define C_FCN 101 /* ".bf" or ".ef" */
#define C_EOS 102 /* end of structure */
#define C_FILE 103 /* file name */
#define C_LINE 104 /* line # reformatted as symbol table entry */
#define C_ALIAS 105 /* duplicate tag */
#define C_HIDDEN 106 /* ext symbol in dmert public lib. like static,
used to avoid name conflicts. */
#ifdef TC_I960
/* New storage classes for 80960 */
#define C_SCALL 107 /* Procedure reachable via system call */
/* C_LEAFPROC is obsolete. Use C_LEAFEXT or C_LEAFSTAT */
#define C_LEAFPROC 108 /* Leaf procedure, "call" via BAL */
#define C_LEAFEXT 108
#define C_OPTVAR 109 /* Optimized variable */
#define C_DEFINE 110 /* Preprocessor #define */
#define C_PRAGMA 111 /* Advice to compiler or linker */
#define C_SEGMENT 112 /* 80960 segment name */
#define C_LEAFSTAT 113 /* Static leaf */
#endif /* TC_I960 */
#ifdef TC_A29K
#define C_SHADOW 107 /* shadow symbol */
#endif /* TC_A29K */
/********************** SECTION HEADER **********************/
struct scnhdr {
char s_name[8]; /* section name */
long s_paddr; /* physical address, aliased s_nlib */
long s_vaddr; /* virtual address */
long s_size; /* section size */
long s_scnptr; /* file ptr to raw data for section */
long s_relptr; /* file ptr to relocation */
long s_lnnoptr; /* file ptr to line numbers */
unsigned short s_nreloc; /* number of relocation entries */
unsigned short s_nlnno; /* number of line number entries */
long s_flags; /* flags */
#ifdef TC_I960
unsigned long s_align; /* section alignment */
#endif /* TC_I960 */
};
#define SCNHDR struct scnhdr
#define SCNHSZ sizeof(SCNHDR)
/*
* names of "special" sections
*/
#define _TEXT ".text" /* executable code section */
#define _DATA ".data" /* initialized data */
#define _BSS ".bss" /* un-initialized data */
#define _DEBUG ".debug" /* special section used by dbx */
#define _COMMENT ".comment" /* version info */
#define _LIB ".lib" /* shared lib info section */
#define _TV ".tv"
/*
* s_flags "type"
*/
/*
* In instances where it is necessary for a linker to
* produce an output file which contains text or data not
* based at virtual address 0, e.g. for a ROM, then the
* linker should accept address base information as command
* input and use PAD sections to skip over unused addresses.
* (at least for a29k. Maybe others.)
*/
#define STYP_REG (0x0000) /* "regular" section: allocated, relocated, loaded */
#define STYP_DSECT (0x0001) /* "dummy" section: not allocated, relocated, not loaded */
#define STYP_NOLOAD (0x0002) /* "noload" section: allocated, relocated, not loaded */
#define STYP_GROUP (0x0004) /* "grouped" section: formed of input sections */
#define STYP_PAD (0x0008) /* "padding" section: not allocated, not relocated, loaded */
#define STYP_COPY (0x0010) /* "copy" section: for decision function used by field update; not allocated, not relocated,
loaded; reloc & lineno entries processed normally */
#define STYP_TEXT (0x0020) /* section contains text only */
#define S_SHRSEG (0x0020) /* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile
will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will
update all process invocations. */
#define STYP_DATA (0x0040) /* section contains data only */
#define STYP_BSS (0x0080) /* section contains bss only */
#define S_NEWFCN (0x0100) /* In a minimal file or an update file, a new function (as compared with a replaced function) */
#define STYP_INFO (0x0200) /* comment section : not allocated not relocated, not loaded */
#define STYP_OVER (0x0400) /* overlay section : relocated not allocated or loaded */
#define STYP_LIB (0x0800) /* for .lib section : same as INFO */
#define STYP_MERGE (0x2000) /* merge section -- combines with text, data or bss sections only */
#define STYP_REVERSE_PAD (0x4000) /* section will be padded with no-op instructions wherever padding is necessary and there is a
word of contiguous bytes beginning on a word boundary. */
#ifdef TC_A29K
/* NOTE: The use of STYP_BSSREG for relocation is not yet defined. */
#define STYP_BSSREG 0x1200 /* Global register area (like STYP_INFO) */
#define STYP_ENVIR 0x2200 /* Environment (like STYP_INFO) */
#define STYP_ABS 0x4000 /* Absolute (allocated, not reloc, loaded) */
#define STYP_LIT 0x8020 /* Literal data (like STYP_TEXT) */
#endif /* TC_A29K */
/********************** LINE NUMBERS **********************/
/* 1 line number entry for every "breakpointable" source line in a section.
* Line numbers are grouped on a per function basis; first entry in a function
* grouping will have l_lnno = 0 and in place of physical address will be the
* symbol table index of the function name.
*/
struct lineno {
union {
long l_symndx; /* symbol index of function name, iff l_lnno == 0*/
long l_paddr; /* (physical) address of line number */
} l_addr;
unsigned short l_lnno; /* line number */
#ifdef TC_I960
/* not used on a29k */
char padding[2]; /* force alignment */
#endif /* TC_I960 */
};
#define LINENO struct lineno
#define LINESZ sizeof(LINENO)
/********************** SYMBOLS **********************/
#define SYMNMLEN 8 /* # characters in a symbol name */
#define FILNMLEN 14 /* # characters in a file name */
#define DIMNUM 4 /* # array dimensions in auxiliary entry */
struct syment {
union {
char _n_name[SYMNMLEN]; /* old COFF version */
struct {
long _n_zeroes; /* new == 0 */
long _n_offset; /* offset into string table */
} _n_n;
char *_n_nptr[2]; /* allows for overlaying */
} _n;
long n_value; /* value of symbol */
short n_scnum; /* section number */
#ifdef TC_I960
/* This isn't yet used on the i960. In some formats this
is two bytes of padding. In others, it is missing entirely. */
unsigned short n_flags; /* copy of flags from filhdr */
#endif /* TC_I960 */
#ifdef TC_A29K
unsigned short n_type; /* type and derived type */
#else /* TC_A29K */
/* at least i960 uses long */
unsigned long n_type; /* type and derived type */
#endif /* TC_A29K */
char n_sclass; /* storage class */
char n_numaux; /* number of aux. entries */
#ifndef TC_A29K
char pad2[2]; /* force alignment */
#endif /* TC_A29K */
};
#define SYMENT struct syment
#define SYMESZ sizeof(SYMENT) /* This had better also be sizeof(AUXENT) */
#define n_name _n._n_name
#define n_ptr _n._n_nptr[1]
#define n_zeroes _n._n_n._n_zeroes
#define n_offset _n._n_n._n_offset
/*
* Relocatable symbols have number of the section in which they are defined,
* or one of the following:
*/
#define N_SCNUM ((short) 1-65535) /* section num where symbol defined */
#define N_UNDEF ((short)0) /* undefined symbol */
#define N_ABS ((short)-1) /* value of symbol is absolute */
#define N_DEBUG ((short)-2) /* debugging symbol -- symbol value is meaningless */
#define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */
#define P_TV ((short)-4) /* indicates symbol needs transfer vector (postload) */
/*
* Type of a symbol, in low 4 bits of the word
*/
#define T_NULL 0 /* type not assigned */
#define T_VOID 1 /* function argument (only used by compiler) (but now real void). */
#define T_CHAR 2 /* character */
#define T_SHORT 3 /* short integer */
#define T_INT 4 /* integer */
#define T_LONG 5 /* long integer */
#define T_FLOAT 6 /* floating point */
#define T_DOUBLE 7 /* double word */
#define T_STRUCT 8 /* structure */
#define T_UNION 9 /* union */
#define T_ENUM 10 /* enumeration */
#define T_MOE 11 /* member of enumeration */
#define T_UCHAR 12 /* unsigned character */
#define T_USHORT 13 /* unsigned short */
#define T_UINT 14 /* unsigned integer */
#define T_ULONG 15 /* unsigned long */
#ifdef TC_I960
#define T_LNGDBL 16 /* long double */
#endif /* TC_I960 */
/*
* derived types, in n_type
*/
#define DT_NON (0) /* no derived type */
#define DT_PTR (1) /* pointer */
#define DT_FCN (2) /* function */
#define DT_ARY (3) /* array */
#ifndef TC_I960
#define N_BTMASK (0x0f)
#define N_TMASK (0x30)
#define N_BTSHFT (4)
#define N_TSHIFT (2)
#else /* TC_I960 */
#define N_BTMASK (0x1f)
#define N_TMASK (0x60)
#define N_BTSHFT (5)
#define N_TSHIFT (2)
#endif /* TC_I960 */
#define BTYPE(x) ((x) & N_BTMASK)
#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT))
#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT))
#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
union auxent {
struct {
long x_tagndx; /* str, un, or enum tag indx */
union {
struct {
unsigned short x_lnno; /* declaration line number */
unsigned short x_size; /* str/union/array size */
} x_lnsz;
long x_fsize; /* size of function */
} x_misc;
union {
struct { /* if ISFCN, tag, or .bb */
long x_lnnoptr; /* ptr to fcn line # */
long x_endndx; /* entry ndx past block end */
} x_fcn;
struct { /* if ISARY, up to 4 dimen. */
unsigned short x_dimen[DIMNUM];
} x_ary;
} x_fcnary;
unsigned short x_tvndx; /* tv index */
} x_sym;
/* This was just a struct x_file with x_fname only in a29k. xoxorich. */
union {
char x_fname[FILNMLEN];
struct {
long x_zeroes;
long x_offset;
} x_n;
} x_file;
struct {
long x_scnlen; /* section length */
unsigned short x_nreloc; /* # relocation entries */
unsigned short x_nlinno; /* # line numbers */
} x_scn;
struct {
long x_tvfill; /* tv fill value */
unsigned short x_tvlen; /* length of .tv */
/* This field was typo'd x_tvrna on a29k. xoxorich. */
unsigned short x_tvran[2]; /* tv range */
} x_tv; /* info about .tv section (in auxent of symbol .tv)) */
#ifdef TC_I960
/******************************************
* I960-specific *2nd* aux. entry formats
******************************************/
struct {
/* This is a very old typo that keeps getting propogated. */
#define x_stdindx x_stindx
long x_stindx; /* sys. table entry */
} x_sc; /* system call entry */
struct {
unsigned long x_balntry; /* BAL entry point */
} x_bal; /* BAL-callable function */
struct {
unsigned long x_timestamp; /* time stamp */
char x_idstring[20]; /* producer identity string */
} x_ident; /* Producer ident info */
char a[sizeof(struct syment)]; /* force auxent/syment sizes to match */
#endif /* TC_I960 */
};
#define AUXENT union auxent
#define AUXESZ sizeof(AUXENT) /* This had better also be sizeof(SYMENT) */
#if VAX || I960
# define _ETEXT "_etext"
#else
# define _ETEXT "etext"
#endif
/********************** RELOCATION DIRECTIVES **********************/
struct reloc {
long r_vaddr; /* Virtual address of reference */
long r_symndx; /* Index into symbol table */
unsigned short r_type; /* Relocation type */
#ifdef TC_I960
/* not used for a29k */
char pad[2]; /* Unused */
#endif /* TC_I960 */
};
#define RELOC struct reloc
#define RELSZ sizeof(RELOC)
#define R_ABS (0x00) /* reference is absolute */
#ifdef TC_I960
#define R_RELLONG (0x11) /* Direct 32-bit relocation */
#define R_IPRSHORT (0x18)
#define R_IPRMED (0x19) /* 24-bit ip-relative relocation */
#define R_IPRLONG (0x1a)
#define R_OPTCALL (0x1b) /* 32-bit optimizable call (leafproc/sysproc) */
#define R_OPTCALLX (0x1c) /* 64-bit optimizable call (leafproc/sysproc) */
#define R_GETSEG (0x1d)
#define R_GETPA (0x1e)
#define R_TAGWORD (0x1f)
#endif /* TC_I960 */
#ifdef TC_A29K
/*
* NOTE: All the "I" forms refer to Am29000 instruction
* formats. The linker is expected to know how the numeric
* information is split and/or aligned within the
* instruction word(s). R_BYTE works for instructions, too.
*
* If the parameter to a CONSTH instruction is a relocatable
* type, two relocation records are written. The first has
* an r_type of R_IHIHALF (33 octal) and a normal r_vaddr
* and r_symndx. The second relocation record has an r_type
* of R_IHCONST (34 octal), a normal r_vaddr (which is
* redundant), and an r_symndx containing the 32-bit
* constant offset to the relocation instead of the actual
* symbol table index. This second record is always
* written, even if the constant offset is zero. The
* constant fields of the instruction are set to zero.
*/
#define R_IREL (0x18) /* instruction relative (jmp/call) */
#define R_IABS (0x19) /* instruction absolute (jmp/call) */
#define R_ILOHALF (0x1a) /* instruction low half (const) */
#define R_IHIHALF (0x1b) /* instruction high half (consth) part 1 */
#define R_IHCONST (0x1c) /* instruction high half (consth) part 2
constant offset of R_IHIHALF relocation */
#define R_BYTE (0x1d) /* relocatable byte value */
#define R_HWORD (0x1e) /* relocatable halfword value */
#define R_WORD (0x1f) /* relocatable word value */
#define R_IGLBLRC (0x20) /* instruction global register RC */
#define R_IGLBLRA (0x21) /* instruction global register RA */
#define R_IGLBLRB (0x22) /* instruction global register RB */
#endif /* TC_A29K */
#define DEFAULT_DATA_SECTION_ALIGNMENT 4
#define DEFAULT_BSS_SECTION_ALIGNMENT 4
#define DEFAULT_TEXT_SECTION_ALIGNMENT 16
/* For new sections we haven't heard of before */
#define DEFAULT_SECTION_ALIGNMENT 4
#if defined(TC_I386)
/*
* X86 generic
* 8-bit offset reference in 8-bits
* 8-bit offset reference in 16-bits
* 12-bit segment reference
* auxiliary relocation entry
*/
#define R_OFF8 07
#define R_OFF16 010
#define R_SEG12 011
#define R_AUX 013
/*
* B16 and X86 generics
* 16-bit direct reference
* 16-bit "relative" reference
* 16-bit "indirect" (TV) reference
*/
#define R_DIR16 01
#define R_REL16 02
#define R_IND16 03
/*
* 3B generic
* 24-bit direct reference
* 24-bit "relative" reference
* 16-bit optimized "indirect" TV reference
* 24-bit "indirect" TV reference
* 32-bit "indirect" TV reference
*/
#define R_DIR24 04
#define R_REL24 05
#define R_OPT16 014
#define R_IND24 015
#define R_IND32 016
/*
* XL generics
* 10-bit direct reference
* 10-bit "relative" reference
* 32-bit "relative" reference
*/
#define R_DIR10 025
#define R_REL10 026
#define R_REL32 027
/*
* 3B and M32 generics
* 32-bit direct reference
*/
#define R_DIR32 06
/*
* M32 generic
* 32-bit direct reference with bytes swapped
*/
#define R_DIR32S 012
#endif /* TC_I386 */
#if defined(TE_I386AIX)
#define UINFOSIZ 64 /* size of user info buffer */
typedef char uinfo_t[UINFOSIZ];
struct env387 {
unsigned short control;
unsigned short r0;
unsigned short status;
unsigned short r1;
unsigned short tag;
unsigned short r2;
unsigned long eip;
unsigned short code_seg;
unsigned short opcode;
unsigned long operand;
unsigned short operand_seg;
unsigned short r3;
unsigned char regs[8][10];
};
#define CD_NAMELEN 16 /* length of most names in this header */
#define CORHDRSIZ 2048 /* size to which header is padded out */
#define MAX_CORE_SEGS 32 /* maximum segments in a core dump */
#define NUM_FREGS 1 /* # of saved FP regs */
/*
* These are defined such that 286 and 386 kernels can produce
* compatible dumps.
*/
#define CD_AX 0
#define CD_BX 1
#define CD_CX 2
#define CD_DX 3
#define CD_SI 4
#define CD_DI 5
#define CD_BP 6
#define CD_SP 7
#define CD_FL 8
#define CD_IP 9
#define CD_CS 10
#define CD_DS 11
#define CD_ES 12
#define CD_FS 13
#define CD_GS 14
#define CD_SS 15
#define NUM_REGS 16
#ifndef SPATHLEN
# define SPATHLEN 16 /* sys/param.h */
#endif
#ifndef NSIG
# define NSIG 63 /* sys/signal.h */
# define SIGSETSZ ((NSIG+31)/32)
typedef struct ksigmask {
unsigned long sigs[SIGSETSZ];
} ksigmask_t;
#endif
struct corehdr {
char cd_magic[4]; /* COR_MAGIC = "core" */
/* general information about the dump itself */
struct dumpseg { /* table of contents for dump */
long cs_type; /* seg. type; see below */
long cs_len; /* length (in bytes) of segment */
long cs_offset; /* offset (in dump) of segment */
long cs_address; /* address segment had in mem */
} cd_segs[MAX_CORE_SEGS];
/* general information about the process */
char cd_comm[CD_NAMELEN]; /* command being run */
char cd_mach[CD_NAMELEN]; /* type of machine it ran on */
char cd_site[CD_NAMELEN]; /* name of site it ran on */
long cd_ldtype; /* type of load module running */
char cd_intsize; /* sizeof(int) */
char cd_dptrsize; /* sizeof(char *) */
char cd_tptrsize; /* sizeof(int (*)()) */
char cd_unused;
/* user-mode program state */
long cd_regs[NUM_REGS]; /* user-mode general registers */
struct env387 cd_fpregs; /* user-mode floating-point state */
/* kernel-mode program state */
int (*cd_sig[NSIG])(); /* disposition of signals */
ksigmask_t cd_sigmask; /* signals to be blocked */
ksigmask_t cd_sigpend; /* signals currently pending */
long cd_cursig; /* signal that caused the dump */
long cd_pid; /* process ID of the corpse */
long cd_ppid; /* parent process ID of corpse */
short cd_uid; /* process effective user ID */
short cd_ruid; /* process real user ID */
short cd_gid; /* process effective group ID */
short cd_rgid; /* process real group ID */
uinfo_t cd_uinfo; /* buffer of user information */
char cd_locname[32]; /* name of /local */
char cd_uvers[CD_NAMELEN]; /* user version string */
unsigned short cd_spath[SPATHLEN]; /* sitepath */
};
#ifndef NOCHECKS
/* this will generate an error if sizeof(struct corehdr) > CORHDRSIZ */
struct { char xxcdxx[CORHDRSIZ+1-sizeof(struct corehdr)]; };
#endif /* ! NOCHECKS */
/*
* segment types (in cs_type)
* each segment in the address space appears here, whether or not it
* is actually dumped. Read/only segments will not actually be dumped.
* A segment that is not in the dump will have a cs_offset of zero.
*/
#define COR_TYPE_CODE 'x' /* process code - NOT IN DUMP */
#define COR_TYPE_DATA 'd' /* process data segment */
#define COR_TYPE_STACK 's' /* process stack segment */
#define COR_TYPE_LIBCODE 'X' /* shared lib code - NOT IN DUMP*/
#define COR_TYPE_LIBDATA 'D' /* shared lib data */
#define COR_TYPE_READ 'r' /* other read/only - NOT IN DUMP*/
#define COR_TYPE_WRITE 'w' /* other writeable */
#define COR_TYPE_MSC '?' /* other, mapped in segment */
#endif /* TE_I386AIX */
/*
* Local Variables:
* comment-column: 0
* End:
*/
/* end of coff.h */

View File

@ -0,0 +1,927 @@
/* Demangler for GNU C++
Copyright (C) 1989, 1992 Free Software Foundation, Inc.
written by James Clark (jjc@jclark.uucp)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* This is for g++ 1.36.1 (November 6 version). It will probably
require changes for any other version. */
/* This file exports one function
char *cplus_demangle (const char *name)
If `name' is a mangled function name produced by g++, then
a pointer to a malloced string giving a C++ representation
of the name will be returned; otherwise NULL will be returned.
It is the caller's responsibility to free the string which
is returned.
For example,
cplus_demangle ("_foo__1Ai")
returns
"A::foo(int)"
This file imports xmalloc and xrealloc, which are like malloc and
realloc except that they generate a fatal error if there is no
available memory. */
/* #define nounderscore 1 /* define this is names don't start with _ */
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#if !defined(sequent) && !defined(NeXT)
#include <memory.h>
#else
#define memcpy(s1, s2, n) strncpy(s1, s2, n)
#define memcmp(s1, s2, n) strncmp(s1, s2, n)
#define strchr(s, c) index(s, c)
#endif
#if __STDC__ != 1
#define const
#endif
#if __STDC__ == 1
extern char *cplus_demangle (const char *type);
#else
extern char *cplus_demangle ();
#endif
#if __STDC__ == 1
extern char *xmalloc (int);
extern char *xrealloc (char *, int);
#else
extern char *xmalloc ();
extern char *xrealloc ();
#endif
static char **typevec = 0;
static int ntypes = 0;
static int typevec_size = 0;
static struct {
const char *in;
const char *out;
} optable[] = {
"new", " new",
"delete", " delete",
"ne", "!=",
"eq", "==",
"ge", ">=",
"gt", ">",
"le", "<=",
"lt", "<",
"plus", "+",
"minus", "-",
"mult", "*",
"negate", "-",
"trunc_mod", "%",
"trunc_div", "/",
"truth_andif", "&&",
"truth_orif", "||",
"postincrement", "++",
"postdecrement", "--",
"bit_ior", "|",
"bit_xor", "^",
"bit_and", "&",
"bit_not", "~",
"call", "()",
"cond", "?:",
"alshift", "<<",
"arshift", ">>",
"component", "->",
"nop", "", /* for operator= */
};
/* Beware: these aren't '\0' terminated. */
typedef struct {
char *b; /* pointer to start of string */
char *p; /* pointer after last character */
char *e; /* pointer after end of allocated space */
} string;
#if __STDC__ == 1
static void string_need (string *s, int n);
static void string_delete (string *s);
static void string_init (string *s);
static void string_clear (string *s);
static int string_empty (string *s);
static void string_append (string *p, const char *s);
static void string_appends (string *p, string *s);
static void string_appendn (string *p, const char *s, int n);
static void string_prepend (string *p, const char *s);
#if 0
static void string_prepends (string *p, string *s);
#endif
static void string_prependn (string *p, const char *s, int n);
static int get_count (const char **type, int *count);
static int do_args (const char **type, string *decl);
static int do_type (const char **type, string *result);
static int do_arg (const char **type, string *result);
static int do_args (const char **type, string *decl);
static void munge_function_name (string *name);
#else
static void string_need ();
static void string_delete ();
static void string_init ();
static void string_clear ();
static int string_empty ();
static void string_append ();
static void string_appends ();
static void string_appendn ();
static void string_prepend ();
static void string_prepends ();
static void string_prependn ();
static int get_count ();
static int do_args ();
static int do_type ();
static int do_arg ();
static int do_args ();
static void munge_function_name ();
#endif
char *
cplus_demangle (type)
const char *type;
{
string decl;
int n;
int success = 0;
int constructor = 0;
int const_flag = 0;
int i;
const char *p;
if (type == NULL || *type == '\0')
return NULL;
#ifndef nounderscore
if (*type++ != '_')
return NULL;
#endif
p = type;
while (*p != '\0' && !(*p == '_' && p[1] == '_'))
p++;
if (*p == '\0')
{
/* destructor */
if (type[0] == '_' && type[1] == '$' && type[2] == '_')
{
int n = (strlen (type) - 3)*2 + 3 + 2 + 1;
char *tem = (char *) xmalloc (n);
strcpy (tem, type + 3);
strcat (tem, "::~");
strcat (tem, type + 3);
strcat (tem, "()");
return tem;
}
/* static data member */
if (*type != '_' && (p = strchr (type, '$')) != '\0')
{
int n = strlen (type) + 2;
char *tem = (char *) xmalloc (n);
memcpy (tem, type, p - type);
strcpy (tem + (p - type), "::");
strcpy (tem + (p - type) + 2, p + 1);
return tem;
}
return NULL;
}
string_init (&decl);
if (p == type)
{
if (!isdigit (p[2]))
{
string_delete (&decl);
return NULL;
}
constructor = 1;
}
else
{
string_appendn (&decl, type, p - type);
munge_function_name (&decl);
}
p += 2;
switch (*p)
{
case 'C':
/* a const member function */
if (!isdigit (p[1]))
{
string_delete (&decl);
return NULL;
}
p += 1;
const_flag = 1;
/* fall through */
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
n = 0;
do
{
n *= 10;
n += *p - '0';
p += 1;
}
while (isdigit (*p));
if (strlen (p) < n)
{
string_delete (&decl);
return NULL;
}
if (constructor)
{
string_appendn (&decl, p, n);
string_append (&decl, "::");
string_appendn (&decl, p, n);
}
else
{
string_prepend (&decl, "::");
string_prependn (&decl, p, n);
}
p += n;
success = do_args (&p, &decl);
if (const_flag)
string_append (&decl, " const");
break;
case 'F':
p += 1;
success = do_args (&p, &decl);
break;
}
for (i = 0; i < ntypes; i++)
if (typevec[i] != NULL)
free (typevec[i]);
ntypes = 0;
if (typevec != NULL)
{
free ((char *)typevec);
typevec = NULL;
typevec_size = 0;
}
if (success)
{
string_appendn (&decl, "", 1);
return decl.b;
}
else
{
string_delete (&decl);
return NULL;
}
}
static int
get_count (type, count)
const char **type;
int *count;
{
if (!isdigit (**type))
return 0;
*count = **type - '0';
*type += 1;
/* see flush_repeats in cplus-method.c */
if (isdigit (**type))
{
const char *p = *type;
int n = *count;
do
{
n *= 10;
n += *p - '0';
p += 1;
}
while (isdigit (*p));
if (*p == '_')
{
*type = p + 1;
*count = n;
}
}
return 1;
}
/* result will be initialised here; it will be freed on failure */
static int
do_type (type, result)
const char **type;
string *result;
{
int n;
int done;
int non_empty;
int success;
string decl;
const char *remembered_type;
string_init (&decl);
string_init (result);
done = 0;
success = 1;
while (success && !done)
{
int member;
switch (**type)
{
case 'P':
*type += 1;
string_prepend (&decl, "*");
break;
case 'R':
*type += 1;
string_prepend (&decl, "&");
break;
case 'T':
*type += 1;
if (!get_count (type, &n) || n >= ntypes)
success = 0;
else
{
remembered_type = typevec[n];
type = &remembered_type;
}
break;
case 'F':
*type += 1;
if (!string_empty (&decl) && decl.b[0] == '*')
{
string_prepend (&decl, "(");
string_append (&decl, ")");
}
if (!do_args (type, &decl) || **type != '_')
success = 0;
else
*type += 1;
break;
case 'M':
case 'O':
{
int constp = 0;
int volatilep = 0;
member = **type == 'M';
*type += 1;
if (!isdigit (**type))
{
success = 0;
break;
}
n = 0;
do
{
n *= 10;
n += **type - '0';
*type += 1;
}
while (isdigit (**type));
if (strlen (*type) < n)
{
success = 0;
break;
}
string_append (&decl, ")");
string_prepend (&decl, "::");
string_prependn (&decl, *type, n);
string_prepend (&decl, "(");
*type += n;
if (member)
{
if (**type == 'C')
{
*type += 1;
constp = 1;
}
if (**type == 'V')
{
*type += 1;
volatilep = 1;
}
if (*(*type)++ != 'F')
{
success = 0;
break;
}
}
if ((member && !do_args (type, &decl)) || **type != '_')
{
success = 0;
break;
}
*type += 1;
if (constp)
{
if (non_empty)
string_append (&decl, " ");
else
non_empty = 1;
string_append (&decl, "const");
}
if (volatilep)
{
if (non_empty)
string_append (&decl, " ");
else
non_empty = 1;
string_append (&decl, "volatilep");
}
break;
}
case 'C':
if ((*type)[1] == 'P')
{
*type += 1;
if (!string_empty (&decl))
string_prepend (&decl, " ");
string_prepend (&decl, "const");
break;
}
/* fall through */
default:
done = 1;
break;
}
}
done = 0;
non_empty = 0;
while (success && !done)
{
switch (**type)
{
case 'C':
*type += 1;
if (non_empty)
string_append (result, " ");
else
non_empty = 1;
string_append (result, "const");
break;
case 'U':
*type += 1;
if (non_empty)
string_append (result, " ");
else
non_empty = 1;
string_append (result, "unsigned");
break;
case 'V':
*type += 1;
if (non_empty)
string_append (result, " ");
else
non_empty = 1;
string_append (result, "volatile");
break;
default:
done = 1;
break;
}
}
if (success)
switch (**type)
{
case '\0':
case '_':
break;
case 'v':
*type += 1;
if (non_empty)
string_append (result, " ");
string_append (result, "void");
break;
case 'l':
*type += 1;
if (non_empty)
string_append (result, " ");
string_append (result, "long");
break;
case 'i':
*type += 1;
if (non_empty)
string_append (result, " ");
string_append (result, "int");
break;
case 's':
*type += 1;
if (non_empty)
string_append (result, " ");
string_append (result, "short");
break;
case 'c':
*type += 1;
if (non_empty)
string_append (result, " ");
string_append (result, "char");
break;
case 'r':
*type += 1;
if (non_empty)
string_append (result, " ");
string_append (result, "long double");
break;
case 'd':
*type += 1;
if (non_empty)
string_append (result, " ");
string_append (result, "double");
break;
case 'f':
*type += 1;
if (non_empty)
string_append (result, " ");
string_append (result, "float");
break;
case 'G':
*type += 1;
if (!isdigit (**type))
{
success = 0;
break;
}
/* fall through */
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
n = 0;
do
{
n *= 10;
n += **type - '0';
*type += 1;
}
while (isdigit (**type));
if (strlen (*type) < n)
{
success = 0;
break;
}
if (non_empty)
string_append (result, " ");
string_appendn (result, *type, n);
*type += n;
break;
default:
success = 0;
break;
}
if (success)
{
if (!string_empty (&decl))
{
string_append (result, " ");
string_appends (result, &decl);
}
string_delete (&decl);
return 1;
}
else
{
string_delete (&decl);
string_delete (result);
return 0;
}
}
/* `result' will be initialised in do_type; it will be freed on failure */
static int
do_arg (type, result)
const char **type;
string *result;
{
char *tem;
int len;
const char *start;
const char *end;
start = *type;
if (!do_type (type, result))
return 0;
end = *type;
if (ntypes >= typevec_size)
{
if (typevec_size == 0)
{
typevec_size = 3;
typevec = (char **) xmalloc (sizeof (char*)*typevec_size);
}
else
{
typevec_size *= 2;
typevec = (char **) xrealloc ((char *)typevec, sizeof (char*)*typevec_size);
}
}
len = end - start;
tem = (char *) xmalloc (len + 1);
memcpy (tem, start, len);
tem[len] = '\0';
typevec[ntypes++] = tem;
return 1;
}
/* `decl' must be already initialised, usually non-empty;
it won't be freed on failure */
static int
do_args (type, decl)
const char **type;
string *decl;
{
string arg;
int need_comma = 0;
string_append (decl, "(");
while (**type != '_' && **type != '\0' && **type != 'e' && **type != 'v')
{
if (**type == 'N')
{
int r;
int t;
*type += 1;
if (!get_count (type, &r) || !get_count (type, &t) || t >= ntypes)
return 0;
while (--r >= 0)
{
const char *tem = typevec[t];
if (need_comma)
string_append (decl, ", ");
if (!do_arg (&tem, &arg))
return 0;
string_appends (decl, &arg);
string_delete (&arg);
need_comma = 1;
}
}
else
{
if (need_comma)
string_append (decl, ", ");
if (!do_arg (type, &arg))
return 0;
string_appends (decl, &arg);
string_delete (&arg);
need_comma = 1;
}
}
if (**type == 'v')
*type += 1;
else if (**type == 'e')
{
*type += 1;
if (need_comma)
string_append (decl, ",");
string_append (decl, "...");
}
string_append (decl, ")");
return 1;
}
static void
munge_function_name (name)
string *name;
{
if (!string_empty (name) && name->p - name->b >= 3
&& name->b[0] == 'o' && name->b[1] == 'p' && name->b[2] == '$')
{
int i;
/* see if it's an assignment expression */
if (name->p - name->b >= 10 /* op$assign_ */
&& memcmp (name->b + 3, "assign_", 7) == 0)
{
for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++)
{
int len = name->p - name->b - 10;
if (strlen (optable[i].in) == len
&& memcmp (optable[i].in, name->b + 10, len) == 0)
{
string_clear (name);
string_append (name, "operator");
string_append (name, optable[i].out);
string_append (name, "=");
return;
}
}
}
else
{
for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++)
{
int len = name->p - name->b - 3;
if (strlen (optable[i].in) == len
&& memcmp (optable[i].in, name->b + 3, len) == 0)
{
string_clear (name);
string_append (name, "operator");
string_append (name, optable[i].out);
return;
}
}
}
return;
}
else if (!string_empty (name) && name->p - name->b >= 5
&& memcmp (name->b, "type$", 5) == 0)
{
/* type conversion operator */
string type;
const char *tem = name->b + 5;
if (do_type (&tem, &type))
{
string_clear (name);
string_append (name, "operator ");
string_appends (name, &type);
string_delete (&type);
return;
}
}
}
/* a mini string-handling package */
static void
string_need (s, n)
string *s;
int n;
{
if (s->b == NULL)
{
if (n < 32)
n = 32;
s->p = s->b = (char *) xmalloc (n);
s->e = s->b + n;
}
else if (s->e - s->p < n)
{
int tem = s->p - s->b;
n += tem;
n *= 2;
s->b = (char *) xrealloc (s->b, n);
s->p = s->b + tem;
s->e = s->b + n;
}
}
static void
string_delete (s)
string *s;
{
if (s->b != NULL)
{
free (s->b);
s->b = s->e = s->p = NULL;
}
}
static void
string_init (s)
string *s;
{
s->b = s->p = s->e = NULL;
}
static void
string_clear (s)
string *s;
{
s->p = s->b;
}
static int
string_empty (s)
string *s;
{
return s->b == s->p;
}
static void
string_append (p, s)
string *p;
const char *s;
{
int n;
if (s == NULL || *s == '\0')
return;
n = strlen (s);
string_need (p, n);
memcpy (p->p, s, n);
p->p += n;
}
static void
string_appends (p, s)
string *p, *s;
{
int n;
if (s->b == s->p)
return;
n = s->p - s->b;
string_need (p, n);
memcpy (p->p, s->b, n);
p->p += n;
}
static void
string_appendn (p, s, n)
string *p;
const char *s;
int n;
{
if (n == 0)
return;
string_need (p, n);
memcpy (p->p, s, n);
p->p += n;
}
static void
string_prepend (p, s)
string *p;
const char *s;
{
if (s == NULL || *s == '\0')
return;
string_prependn (p, s, strlen (s));
}
#if 0
static void
string_prepends (p, s)
string *p, *s;
{
if (s->b == s->p)
return;
string_prependn (p, s->b, s->p - s->b);
}
#endif
static void
string_prependn (p, s, n)
string *p;
const char *s;
int n;
{
char *q;
if (n == 0)
return;
string_need (p, n);
for (q = p->p - 1; q >= p->b; q--)
q[n] = q[0];
memcpy (p->b, s, n);
p->p += n;
}
/* end of cplus-dem.c */

View File

@ -0,0 +1,29 @@
/* ho-ansi.h Host-specific header file for generic ansi environments.
Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define M_ANSI 1
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#define sys_nerr _sys_nerr
#define sys_errlist _sys_errlist
/* end of ho-ansi.h */

View File

@ -0,0 +1,29 @@
/* ho-pmax.h Host-specific header file for decstation 3100.
Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <string.h>
extern char *malloc();
extern int free();
#if !defined(__GNUC__)
#define know(x)
#endif /* not gcc */
/* end of ho-decstation.h */

View File

@ -0,0 +1,30 @@
/* ho-generic.h Generic host-specific header file.
Copyright 1987, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* It is my intent that this become a file capable of config'ing and
compiling for nearly any host as aid for testing and porting.
xoxorich. */
#define M_GENERIC 1
#define HAVE_STRERROR
extern int free();
/* end of ho-generic.h */

View File

@ -0,0 +1,34 @@
/* ho-hpux.h -- Header to compile the assembler under HP-UX
Copyright (C) 1988, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ho-sysv.h"
/* This header file contains the #defines specific
to HPUX changes sent me by cph@zurich.ai.mit.edu */
#ifndef hpux
#define hpux
#endif
#ifdef setbuffer
#undef setbuffer
#endif /* setbuffer */
#define setbuffer(stream, buf, size)
/* end of ho-hpux.h */

View File

@ -0,0 +1,30 @@
/* ho-i386.h i386 specific header file.
Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* $Id: ho-i386.h,v 1.1 1993/10/02 20:58:36 pk Exp $
*/
#define HO_I386 1
#define NO_STDARG
#include "ho-sysv.h"
/* end of ho-i386.h */

View File

@ -0,0 +1,24 @@
/* ho-386aix.h AIX PS/2 i386 specific header file.
Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HO_I386 1
#include "ho-sysv.h"
/* end of ho-i386aix.h */

View File

@ -0,0 +1,22 @@
/* ho-rs6000.h Rs6000 host-specific header file.
Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define M_RS6000 1
/* end of ho-rs6000.h */

View File

@ -0,0 +1,3 @@
#include <ho-sunos.h>
/* end of ho-sun3.h */

View File

@ -0,0 +1,5 @@
#include <ho-sunos.h>
extern int sprintf();
/* end of ho-sun386.h */

View File

@ -0,0 +1,3 @@
#include <ho-sunos.h>
/* end of ho-sun4.h */

View File

@ -0,0 +1,81 @@
/* This file is ho-sunos.h
Copyright (C) 1987-1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#if __STDC__ != 1
#define NO_STDARG
#endif /* not __STDC__ */
#if !defined(__GNUC__) && (__STDC__ != 1)
#include <memory.h>
#else
extern int memset();
#endif
/* #include <sys/stdtypes.h> before <stddef.h> when compiling by GCC. */
#include <sys/stdtypes.h>
#include <stddef.h>
#include <ctype.h>
#include <string.h>
/* externs for system libraries. */
/*extern int abort();*/
/*extern int exit();*/
extern char *malloc();
extern char *realloc();
extern char *strchr();
extern char *strrchr();
extern int _filbuf();
extern int _flsbuf();
extern int fclose();
extern int fgetc();
extern int fprintf();
extern int fread();
extern int free();
extern int perror();
extern int printf();
extern int rewind();
extern int setvbuf();
extern int sscanf();
extern int strcmp();
extern int strlen();
extern int strncmp();
extern int time();
extern int ungetc();
extern int vfprintf();
extern int vprintf();
extern int vsprintf();
extern long atol();
#ifndef tolower
extern int tolower();
#endif /* tolower */
#ifndef toupper
extern int toupper();
#endif /* toupper */
/*
* Local Variables:
* fill-column: 80
* comment-column: 0
* End:
*/
/* end of ho-sunos.h */

View File

@ -0,0 +1,27 @@
/* ho-sysv.h System V specific header file.
Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HO_USG
#define setbuffer(stream, buf, size) setvbuf((stream), (buf), _IOLBF, (size))
extern int free();
extern char *malloc();
/* end of ho-sysv.h */

View File

@ -0,0 +1,27 @@
/* ho-vax.h Intended for vax ultrix
Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#if __STDC__ != 1
#define NO_STDARG
#endif /* not ansi */
extern char *malloc();
extern int free();
/* end of ho-vax.h */

View File

@ -0,0 +1,30 @@
/* ho-vax.h Intended for vax vms
Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HO_VAX 1
#include "ho-vax.h"
/* We get better performance if we use the macros rather than the functions.*/
#include <ctype.h>
/* We need this to make sure that sys_nerr has the right Psect hack. */
#include <perror.h>
/* end of ho-vms.h */

View File

@ -0,0 +1 @@
ALLOCA=alloca.o

View File

@ -0,0 +1,5 @@
# Define SYSV as -DSYSV if you are using a System V operating system.
SYSV = -DSYSV
RANLIB = /bin/true
CC = gcc
MINUS_G = -O

View File

@ -0,0 +1 @@
HLIBS=-lucb

View File

@ -0,0 +1,6 @@
TARG_CPU_DEPENDENTS=
LOCAL_LOADLIBES=../bfd$(subdir)/libbfd.a
TDEFINES=-DBFD_HEADERS -DMANY_SEGMENTS -DBFD

View File

@ -0,0 +1,5 @@
TARG_CPU_DEPENDENTS=$(srcdir)/../include/opcode/h8300.h
LOCAL_LOADLIBES=$(srcdir)/../bfd/$(srcdir)/libbfd.a
TDEFINES=-DBFD_HEADERS -DMANY_SEGMENTS -DBFD
CC=gcc

View File

@ -0,0 +1,4 @@
TARG_CPU_DEPENDENTS=$(srcdir)/../include/h8300-opcode.h
LOCAL_LOADLIBES=$(srcdir)/../bfd/$(srcdir)/libbfd.a
TDEFINES=-DBFD -DMANY_SEGMENTS

View File

@ -0,0 +1,3 @@
# TDEFINES = -DBFD_HEADERS
CC = gcc
MINUS_G = -O

View File

@ -0,0 +1 @@
ALL=fake-as

View File

@ -0,0 +1 @@
ALL=fake-as

View File

@ -0,0 +1,600 @@
/* a.out object file format
Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2,
or (at your option) any later version.
GAS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with GAS; see the file COPYING. If not, write
to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "as.h"
#include "obstack.h"
#ifndef NO_LISTING
#include "aout/stab_gnu.h"
#endif /* NO_LISTING */
/* in: segT out: N_TYPE bits */
const short seg_N_TYPE[] = {
N_ABS,
N_TEXT,
N_DATA,
N_BSS,
N_UNDF, /* unknown */
N_UNDF, /* absent */
N_UNDF, /* pass1 */
N_UNDF, /* error */
N_UNDF, /* bignum/flonum */
N_UNDF, /* difference */
N_UNDF, /* debug */
N_UNDF, /* ntv */
N_UNDF, /* ptv */
N_REGISTER, /* register */
};
const segT N_TYPE_seg[N_TYPE+2] = { /* N_TYPE == 0x1E = 32-2 */
SEG_UNKNOWN, /* N_UNDF == 0 */
SEG_GOOF,
SEG_ABSOLUTE, /* N_ABS == 2 */
SEG_GOOF,
SEG_TEXT, /* N_TEXT == 4 */
SEG_GOOF,
SEG_DATA, /* N_DATA == 6 */
SEG_GOOF,
SEG_BSS, /* N_BSS == 8 */
SEG_GOOF,
SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
SEG_REGISTER, /* dummy N_REGISTER for regs = 30 */
SEG_GOOF,
};
#if __STDC__ == 1
static void obj_aout_stab(int what);
static void obj_aout_line(void);
static void obj_aout_desc(void);
#else /* not __STDC__ */
static void obj_aout_desc();
static void obj_aout_stab();
static void obj_aout_line();
#endif /* not __STDC__ */
const pseudo_typeS obj_pseudo_table[] = {
#ifndef IGNORE_DEBUG
/* stabs debug info */
{ "line", obj_aout_line, 0 }, /* source code line number */
{ "ln", obj_aout_line, 0 }, /* coff line number that we use anyway */
{ "desc", obj_aout_desc, 0 }, /* desc */
{ "stabd", obj_aout_stab, 'd' }, /* stabs */
{ "stabn", obj_aout_stab, 'n' }, /* stabs */
{ "stabs", obj_aout_stab, 's' }, /* stabs */
#else /* IGNORE_DEBUG */
{ "line", obj_aout_line, 0 }, /* source code line number */
{ "ln", obj_aout_line, 0 }, /* coff line number that we use anyway */
{ "desc", obj_aout_desc, 0 }, /* desc */
{ "stabd", obj_aout_stab, 'd' }, /* stabs */
{ "stabn", obj_aout_stab, 'n' }, /* stabs */
{ "stabs", obj_aout_stab, 's' }, /* stabs */
#endif /* IGNORE_DEBUG */
/* coff debug pseudos (ignored) */
{ "def", s_ignore, 0 },
{ "dim", s_ignore, 0 },
{ "endef", s_ignore, 0 },
{ "ident", s_ignore, 0 },
{ "line", s_ignore, 0 },
{ "ln", s_ignore, 0 },
{ "scl", s_ignore, 0 },
{ "size", s_size, 0 },
{ "tag", s_ignore, 0 },
{ "type", s_ignore, 0 },
{ "val", s_ignore, 0 },
{ "version", s_ignore, 0 },
/* stabs-in-coff (?) debug pseudos (ignored) */
{ "optim", s_ignore, 0 }, /* For sun386i cc (?) */
/* other stuff */
{ "ABORT", s_abort, 0 },
{ NULL} /* end sentinel */
}; /* obj_pseudo_table */
/* Relocation. */
/*
* emit_relocations()
*
* Crawl along a fixS chain. Emit the segment's relocations.
*/
void obj_emit_relocations(where, fixP, segment_address_in_file)
char **where;
fixS *fixP; /* Fixup chain for this segment. */
relax_addressT segment_address_in_file;
{
for (; fixP; fixP = fixP->fx_next) {
if (fixP->fx_addsy != NULL) {
tc_aout_fix_to_chars(*where, fixP, segment_address_in_file);
*where += md_reloc_size;
} /* if there is an add symbol */
} /* for each fix */
return;
} /* obj_emit_relocations() */
/* Aout file generation & utilities */
void obj_header_append(where, headers)
char **where;
object_headers *headers;
{
tc_headers_hook(headers);
#if defined(OLD_GAS) && defined(TC_I386)
/* I think that this old behaviour was wrong, but this lets me compare to the
previous gas. xoxorich. */
md_number_to_chars(*where, headers->header.a_info, 2);
*where += 2;
md_number_to_chars(*where, 0, 2);
*where += 2;
#else /* not (TC_I386 && OLD_GAS) */
md_number_to_chars(*where, headers->header.a_info, sizeof(headers->header.a_info));
*where += sizeof(headers->header.a_info);
#endif /* not (TC_I386 && OLD_GAS) */
#ifdef TE_HPUX
md_number_to_chars(*where, 0, 4); *where += 4; /* a_spare1 */
md_number_to_chars(*where, 0, 4); *where += 4; /* a_spare2 */
#endif /* TE_HPUX */
md_number_to_chars(*where, headers->header.a_text, 4); *where += 4;
md_number_to_chars(*where, headers->header.a_data, 4); *where += 4;
md_number_to_chars(*where, headers->header.a_bss, 4); *where += 4;
#ifndef TE_HPUX
md_number_to_chars(*where, headers->header.a_syms, 4); *where += 4;
md_number_to_chars(*where, headers->header.a_entry, 4); *where += 4;
#endif /* not TE_HPUX */
md_number_to_chars(*where, headers->header.a_trsize, 4); *where += 4;
md_number_to_chars(*where, headers->header.a_drsize, 4); *where += 4;
#ifdef TE_SEQUENT
memset(*where, '\0', 3 * 2 * 4); *where += 3 * 2 * 4; /* global descriptor table? */
md_number_to_chars(*where, 0, 4); *where += 4; /* shdata - length of initialized shared data */
md_number_to_chars(*where, 0, 4); *where += 4; /* shbss - length of uninitialized shared data */
md_number_to_chars(*where, 0, 4); *where += 4; /* shdrsize - length of shared data relocation */
memset(*where, '\0', 11 * 4); *where += 11 * 4; /* boostrap for standalone */
memset(*where, '\0', 3 * 4); *where += 3 * 4; /* reserved */
md_number_to_chars(*where, 0, 4); *where += 4; /* version */
#endif /* TE_SEQUENT */
#ifdef TE_HPUX
md_number_to_chars(*where, 0, 4); *where += 4; /* a_spare3 - HP = pascal interface size */
md_number_to_chars(*where, 0, 4); *where += 4; /* a_spare4 - HP = symbol table size */
md_number_to_chars(*where, 0, 4); *where += 4; /* a_spare5 - HP = debug name table size */
md_number_to_chars(*where, headers->header.a_entry, 4); *where += 4;
md_number_to_chars(*where, 0, 4); *where += 4; /* a_spare6 - HP = source line table size */
md_number_to_chars(*where, 0, 4); *where += 4; /* a_spare7 - HP = value table size */
md_number_to_chars(*where, headers->header.a_syms, 4); *where += 4;
md_number_to_chars(*where, 0, 4); *where += 4; /* a_spare8 */
#endif /* TE_HPUX */
return;
} /* obj_append_header() */
void obj_symbol_to_chars(where, symbolP)
char **where;
symbolS *symbolP;
{
md_number_to_chars((char *)&(S_GET_OFFSET(symbolP)), S_GET_OFFSET(symbolP), sizeof(S_GET_OFFSET(symbolP)));
md_number_to_chars((char *)&(S_GET_DESC(symbolP)), S_GET_DESC(symbolP), sizeof(S_GET_DESC(symbolP)));
md_number_to_chars((char *)&(S_GET_VALUE(symbolP)), S_GET_VALUE(symbolP), sizeof(S_GET_VALUE(symbolP)));
append(where, (char *)&symbolP->sy_symbol, sizeof(obj_symbol_type));
} /* obj_symbol_to_chars() */
void obj_emit_symbols(where, symbol_rootP)
char **where;
symbolS *symbol_rootP;
{
symbolS * symbolP;
/*
* Emit all symbols left in the symbol chain.
*/
for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
/* Used to save the offset of the name. It is used to point
to the string in memory but must be a file offset. */
register char *temp;
temp = S_GET_NAME(symbolP);
S_SET_OFFSET(symbolP, symbolP->sy_name_offset);
/* Any symbol still undefined and is not a dbg symbol is made N_EXT. */
if (!S_IS_DEBUG(symbolP) && !S_IS_DEFINED(symbolP)) S_SET_EXTERNAL(symbolP);
obj_symbol_to_chars(where, symbolP);
S_SET_NAME(symbolP,temp);
}
} /* emit_symbols() */
#if comment
/* uneeded if symbol is born zeroed. */
void obj_symbol_new_hook(symbolP)
symbolS *symbolP;
{
S_SET_OTHER(symbolP, 0);
S_SET_DESC(symbolP, 0);
return;
} /* obj_symbol_new_hook() */
#endif /* comment */
static void obj_aout_line() {
/* Assume delimiter is part of expression. */
/* BSD4.2 as fails with delightful bug, so we */
/* are not being incompatible here. */
new_logical_line((char *)NULL, (int)(get_absolute_expression()));
demand_empty_rest_of_line();
} /* obj_aout_line() */
/*
* stab()
*
* Handle .stabX directives, which used to be open-coded.
* So much creeping featurism overloaded the semantics that we decided
* to put all .stabX thinking in one place. Here.
*
* We try to make any .stabX directive legal. Other people's AS will often
* do assembly-time consistency checks: eg assigning meaning to n_type bits
* and "protecting" you from setting them to certain values. (They also zero
* certain bits before emitting symbols. Tut tut.)
*
* If an expression is not absolute we either gripe or use the relocation
* information. Other people's assemblers silently forget information they
* don't need and invent information they need that you didn't supply.
*
* .stabX directives always make a symbol table entry. It may be junk if
* the rest of your .stabX directive is malformed.
*/
static void obj_aout_stab(what)
int what;
{
#ifndef NO_LISTING
extern int listing;
#endif /* NO_LISTING */
register symbolS *symbolP = 0;
register char *string;
int saved_type = 0;
int length;
int goof; /* TRUE if we have aborted. */
long longint;
/*
* Enter with input_line_pointer pointing past .stabX and any following
* whitespace.
*/
goof = 0; /* JF who forgot this?? */
if (what == 's') {
string = demand_copy_C_string(& length);
SKIP_WHITESPACE();
if (* input_line_pointer == ',')
input_line_pointer ++;
else {
as_bad("I need a comma after symbol's name");
goof = 1;
}
} else
string = "";
/*
* Input_line_pointer->after ','. String->symbol name.
*/
if (! goof) {
symbolP = symbol_new(string,
SEG_UNKNOWN,
0,
(struct frag *)0);
switch (what) {
case 'd':
S_SET_NAME(symbolP, NULL); /* .stabd feature. */
S_SET_VALUE(symbolP, obstack_next_free(&frags) - frag_now->fr_literal);
symbolP->sy_frag = frag_now;
break;
case 'n':
symbolP->sy_frag = &zero_address_frag;
break;
case 's':
symbolP->sy_frag = & zero_address_frag;
break;
default:
BAD_CASE(what);
break;
}
if (get_absolute_expression_and_terminator(&longint) == ',')
symbolP->sy_symbol.n_type = saved_type = longint;
else {
as_bad("I want a comma after the n_type expression");
goof = 1;
input_line_pointer --; /* Backup over a non-',' char. */
}
}
if (!goof) {
if (get_absolute_expression_and_terminator(&longint) == ',')
S_SET_OTHER(symbolP, longint);
else {
as_bad("I want a comma after the n_other expression");
goof = 1;
input_line_pointer--; /* Backup over a non-',' char. */
}
}
if (!goof) {
S_SET_DESC(symbolP, get_absolute_expression());
if (what == 's' || what == 'n') {
if (*input_line_pointer != ',') {
as_bad("I want a comma after the n_desc expression");
goof = 1;
} else {
input_line_pointer++;
}
}
}
if ((!goof) && (what == 's' || what == 'n')) {
pseudo_set(symbolP);
symbolP->sy_symbol.n_type = saved_type;
}
#ifndef NO_LISTING
if (listing && !goof)
{
if (symbolP->sy_symbol.n_type == N_SLINE)
{
listing_source_line(symbolP->sy_symbol.n_desc);
}
else if (symbolP->sy_symbol.n_type == N_SO
|| symbolP->sy_symbol.n_type == N_SOL)
{
listing_source_file(string);
}
}
#endif
if (goof)
ignore_rest_of_line();
else
demand_empty_rest_of_line ();
} /* obj_aout_stab() */
static void obj_aout_desc() {
register char *name;
register char c;
register char *p;
register symbolS *symbolP;
register int temp;
/*
* Frob invented at RMS' request. Set the n_desc of a symbol.
*/
name = input_line_pointer;
c = get_symbol_end();
p = input_line_pointer;
* p = c;
SKIP_WHITESPACE();
if (*input_line_pointer != ',') {
*p = 0;
as_bad("Expected comma after name \"%s\"", name);
*p = c;
ignore_rest_of_line();
} else {
input_line_pointer ++;
temp = get_absolute_expression();
*p = 0;
symbolP = symbol_find_or_make(name);
*p = c;
S_SET_DESC(symbolP,temp);
}
demand_empty_rest_of_line();
} /* obj_aout_desc() */
void obj_read_begin_hook() {
return;
} /* obj_read_begin_hook() */
void obj_crawl_symbol_chain(headers)
object_headers *headers;
{
symbolS *symbolP;
symbolS **symbolPP;
int symbol_number = 0;
/* JF deal with forward references first... */
for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
if (symbolP->sy_forward) {
S_SET_VALUE(symbolP, S_GET_VALUE(symbolP)
+ S_GET_VALUE(symbolP->sy_forward)
+ symbolP->sy_forward->sy_frag->fr_address);
symbolP->sy_forward=0;
} /* if it has a forward reference */
} /* walk the symbol chain */
tc_crawl_symbol_chain(headers);
symbolPP = &symbol_rootP; /*->last symbol chain link. */
while ((symbolP = *symbolPP) != NULL) {
if (flagseen['R'] && (S_GET_SEGMENT(symbolP) == SEG_DATA)) {
S_SET_SEGMENT(symbolP, SEG_TEXT);
} /* if pusing data into text */
S_SET_VALUE(symbolP, S_GET_VALUE(symbolP) + symbolP->sy_frag->fr_address);
/* OK, here is how we decide which symbols go out into the
brave new symtab. Symbols that do are:
* symbols with no name (stabd's?)
* symbols with debug info in their N_TYPE
Symbols that don't are:
* symbols that are registers
* symbols with \1 as their 3rd character (numeric labels)
* "local labels" as defined by S_LOCAL_NAME(name)
if the -L switch was passed to gas.
All other symbols are output. We complain if a deleted
symbol was marked external. */
if (!S_IS_REGISTER(symbolP)
&& (!S_GET_NAME(symbolP)
|| S_IS_DEBUG(symbolP)
#ifdef TC_I960
/* FIXME-SOON this ifdef seems highly dubious to me. xoxorich. */
|| !S_IS_DEFINED(symbolP)
|| S_IS_EXTERNAL(symbolP)
#endif /* TC_I960 */
|| (S_GET_NAME(symbolP)[0] != '\001' &&
(flagseen['L'] || ! S_LOCAL_NAME(symbolP)
#ifdef PIC
|| flagseen['k'] && symbolP->sy_forceout
#endif
)
)
)
#ifdef PIC
&& (!flagseen['k'] ||
symbolP != GOT_symbol || got_referenced != 0
)
#endif
) {
symbolP->sy_number = symbol_number++;
/* The + 1 after strlen account for the \0 at the
end of each string */
if (!S_IS_STABD(symbolP)) {
/* Ordinary case. */
symbolP->sy_name_offset = string_byte_count;
string_byte_count += strlen(S_GET_NAME(symbolP)) + 1;
}
else /* .Stabd case. */
symbolP->sy_name_offset = 0;
/*
* If symbol has a known size, output an extra symbol
* of type N_SIZE and with the same name.
*/
if (0/*DISABLED*/ && symbolP->sy_size && flagseen['k']) {
symbolS *addme;
/*XXX*/ char buf[BUFSIZ];
/*
* Changed my mind, make name: "=symbol"
*/
buf[0] = '=';
strncpy(buf+1, S_GET_NAME(symbolP), BUFSIZ-2);
addme = symbol_make(buf);
#if 0
S_SET_SEGMENT(addme, SEG_SIZE);
#endif
addme->sy_symbol.n_type = N_SIZE;
S_SET_VALUE(addme, symbolP->sy_size);
/* Set external if symbolP is ? */
#if 1
if (S_IS_EXTERN(symbolP))
S_SET_EXTERNAL(addme);
#endif
}
symbolPP = &(symbol_next(symbolP));
} else {
if ((S_IS_EXTERNAL(symbolP) || !S_IS_DEFINED(symbolP))
#ifdef PIC
&& (!flagseen['k'] ||
symbolP != GOT_symbol || got_referenced != 0
)
#endif
) {
as_bad("Local symbol %s never defined.", decode_local_label_name(S_GET_NAME(symbolP)));
} /* oops. */
/* Unhook it from the chain */
*symbolPP = symbol_next(symbolP);
} /* if this symbol should be in the output */
} /* for each symbol */
H_SET_SYMBOL_TABLE_SIZE(headers, symbol_number);
return;
} /* obj_crawl_symbol_chain() */
/*
* Find strings by crawling along symbol table chain.
*/
void obj_emit_strings(where)
char **where;
{
symbolS *symbolP;
#ifdef CROSS_COMPILE
/* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */
md_number_to_chars(*where, string_byte_count, sizeof(string_byte_count));
*where += sizeof(string_byte_count);
#else /* CROSS_COMPILE */
append (where, (char *)&string_byte_count, (unsigned long)sizeof(string_byte_count));
#endif /* CROSS_COMPILE */
for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
if (S_GET_NAME(symbolP))
append(&next_object_file_charP, S_GET_NAME(symbolP),
(unsigned long)(strlen (S_GET_NAME(symbolP)) + 1));
} /* walk symbol chain */
return;
} /* obj_emit_strings() */
void obj_pre_write_hook(headers)
object_headers *headers;
{
H_SET_DYNAMIC(headers, 0);
H_SET_VERSION(headers, 0);
H_SET_MACHTYPE(headers, AOUT_MACHTYPE);
H_SET_MAGIC_NUMBER(headers, DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE);
H_SET_ENTRY_POINT(headers, 0);
tc_aout_pre_write_hook(headers);
return;
} /* obj_pre_write_hook() */
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of obj-aout.c */

View File

@ -0,0 +1,207 @@
/* obj-aout.h, a.out object file format for gas, the assembler.
Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2,
or (at your option) any later version.
GAS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with GAS; see the file COPYING. If not, write
to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* $Id: obj-aout.h,v 1.1 1993/10/02 20:58:55 pk Exp $
*/
/* Tag to validate a.out object file format processing */
#define OBJ_AOUT 1
#include "targ-cpu.h"
#include "aout.h" /* Needed to define struct nlist. Sigh. */
#ifndef AOUT_MACHTYPE
#define AOUT_MACHTYPE 0
#endif /* AOUT_MACHTYPE */
extern const short seg_N_TYPE[];
extern const segT N_TYPE_seg[];
#ifndef DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE
#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (OMAGIC)
#endif /* DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE */
/* SYMBOL TABLE */
/* Symbol table entry data type */
typedef struct nlist obj_symbol_type; /* Symbol table entry */
/* Symbol table macros and constants */
/*
* Macros to extract information from a symbol table entry.
* This syntaxic indirection allows independence regarding a.out or coff.
* The argument (s) of all these macros is a pointer to a symbol table entry.
*/
/* True if the symbol is external */
#define S_IS_EXTERNAL(s) ((s)->sy_symbol.n_type & N_EXT)
/* True if symbol has been defined, ie is in N_{TEXT,DATA,BSS,ABS} or N_EXT */
#define S_IS_DEFINED(s) ((S_GET_TYPE(s) != N_UNDF) || (S_GET_OTHER(s) != 0) || (S_GET_DESC(s) != 0))
#define S_IS_REGISTER(s) ((s)->sy_symbol.n_type == N_REGISTER)
/* True if a debug special symbol entry */
#define S_IS_DEBUG(s) ((s)->sy_symbol.n_type & N_STAB)
/* True if a symbol is local symbol name */
/* A symbol name whose name begin with ^A is a gas internal pseudo symbol
nameless symbols come from .stab directives. */
#define S_IS_LOCAL(s) (S_GET_NAME(s) && \
!S_IS_DEBUG(s) && \
(S_GET_NAME(s)[0] == '\001' || \
(S_LOCAL_NAME(s) && !flagseen['L'])))
/* True if a symbol is not defined in this file */
#define S_IS_EXTERN(s) ((s)->sy_symbol.n_type & N_EXT)
/* True if the symbol has been generated because of a .stabd directive */
#define S_IS_STABD(s) (S_GET_NAME(s) == (char *)0)
/* Accessors */
/* The value of the symbol */
#define S_GET_VALUE(s) (((s)->sy_symbol.n_value))
/* The name of the symbol */
#define S_GET_NAME(s) ((s)->sy_symbol.n_un.n_name)
/* The pointer to the string table */
#define S_GET_OFFSET(s) ((s)->sy_symbol.n_un.n_strx)
/* The type of the symbol */
#define S_GET_TYPE(s) ((s)->sy_symbol.n_type & N_TYPE)
/* The numeric value of the segment */
#define S_GET_SEGMENT(s) (N_TYPE_seg[S_GET_TYPE(s)])
/* The n_other expression value */
#define S_GET_OTHER(s) ((s)->sy_symbol.n_other)
/* The n_desc expression value */
#define S_GET_DESC(s) ((s)->sy_symbol.n_desc)
/* Modifiers */
/* Set the value of the symbol */
#define S_SET_VALUE(s,v) ((s)->sy_symbol.n_value = (unsigned long) (v))
/* Assume that a symbol cannot be simultaneously in more than on segment */
/* set segment */
#define S_SET_SEGMENT(s,seg) ((s)->sy_symbol.n_type &= ~N_TYPE,(s)->sy_symbol.n_type|=SEGMENT_TO_SYMBOL_TYPE(seg))
/* The symbol is external */
#define S_SET_EXTERNAL(s) ((s)->sy_symbol.n_type |= N_EXT)
/* The symbol is not external */
#define S_CLEAR_EXTERNAL(s) ((s)->sy_symbol.n_type &= ~N_EXT)
/* Set the name of the symbol */
#define S_SET_NAME(s,v) ((s)->sy_symbol.n_un.n_name = (v))
/* Set the offset in the string table */
#define S_SET_OFFSET(s,v) ((s)->sy_symbol.n_un.n_strx = (v))
/* Set the n_other expression value */
#define S_SET_OTHER(s,v) ((s)->sy_symbol.n_other = (v))
/* Set the n_desc expression value */
#define S_SET_DESC(s,v) ((s)->sy_symbol.n_desc = (v))
/* File header macro and type definition */
#define H_GET_FILE_SIZE(h) (H_GET_HEADER_SIZE(h) \
+ H_GET_TEXT_SIZE(h) \
+ H_GET_DATA_SIZE(h) \
+ H_GET_SYMBOL_TABLE_SIZE(h) \
+ H_GET_TEXT_RELOCATION_SIZE(h) \
+ H_GET_DATA_RELOCATION_SIZE(h) \
+ H_GET_STRING_SIZE(h))
#ifndef H_GET_HEADER_SIZE
#define H_GET_HEADER_SIZE(h) (sizeof(struct exec))
#endif /* not H_GET_HEADER_SIZE */
#define H_GET_TEXT_SIZE(h) ((h)->header.a_text)
#define H_GET_DATA_SIZE(h) ((h)->header.a_data)
#define H_GET_BSS_SIZE(h) ((h)->header.a_bss)
#define H_GET_TEXT_RELOCATION_SIZE(h) ((h)->header.a_trsize)
#define H_GET_DATA_RELOCATION_SIZE(h) ((h)->header.a_drsize)
#define H_GET_SYMBOL_TABLE_SIZE(h) ((h)->header.a_syms)
#define H_GET_ENTRY_POINT(h) ((h)->header.a_entry)
#define H_GET_STRING_SIZE(h) ((h)->string_table_size)
#define H_GET_LINENO_SIZE(h) (0)
#define H_GET_DYNAMIC(h) ((h)->header.a_info >> 31)
#define H_GET_VERSION(h) (((h)->header.a_info >> 24) & 0x7f)
#define H_GET_MACHTYPE(h) (((h)->header.a_info >> 16) & 0xff)
#define H_GET_MAGIC_NUMBER(h) ((h)->header.a_info & 0xffff)
#define H_SET_DYNAMIC(h,v) ((h)->header.a_info = (((v) << 31) \
| (H_GET_VERSION(h) << 24) \
| (H_GET_MACHTYPE(h) << 16) \
| (H_GET_MAGIC_NUMBER(h))))
#define H_SET_VERSION(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC(h) << 31) \
| ((v) << 24) \
| (H_GET_MACHTYPE(h) << 16) \
| (H_GET_MAGIC_NUMBER(h))))
#define H_SET_MACHTYPE(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC(h) << 31) \
| (H_GET_VERSION(h) << 24) \
| ((v) << 16) \
| (H_GET_MAGIC_NUMBER(h))))
#define H_SET_MAGIC_NUMBER(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC(h) << 31) \
| (H_GET_VERSION(h) << 24) \
| (H_GET_MACHTYPE(h) << 16) \
| ((v))))
#define H_SET_TEXT_SIZE(h,v) ((h)->header.a_text = md_section_align(SEG_TEXT, (v)))
#define H_SET_DATA_SIZE(h,v) ((h)->header.a_data = md_section_align(SEG_DATA, (v)))
#define H_SET_BSS_SIZE(h,v) ((h)->header.a_bss = md_section_align(SEG_BSS, (v)))
#define H_SET_RELOCATION_SIZE(h,t,d) (H_SET_TEXT_RELOCATION_SIZE((h),(t)),\
H_SET_DATA_RELOCATION_SIZE((h),(d)))
#define H_SET_TEXT_RELOCATION_SIZE(h,v) ((h)->header.a_trsize = (v))
#define H_SET_DATA_RELOCATION_SIZE(h,v) ((h)->header.a_drsize = (v))
#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * \
sizeof(struct nlist))
#define H_SET_ENTRY_POINT(h,v) ((h)->header.a_entry = (v))
#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v))
/*
* Current means for getting the name of a segment.
* This will change for infinite-segments support (e.g. COFF).
*/
#define segment_name(seg) (seg_name[(int)(seg)])
extern char *const seg_name[];
typedef struct {
struct exec header; /* a.out header */
long string_table_size; /* names + '\0' + sizeof(int) */
} object_headers;
/* line numbering stuff. */
#define OBJ_EMIT_LINENO(a, b, c) {;}
#define obj_symbol_new_hook(s) {;}
#if __STDC__ == 1
struct fix;
void tc_aout_fix_to_chars(char *where, struct fix *fixP, relax_addressT segment_address);
#else /* not __STDC__ */
void tc_aout_fix_to_chars();
#endif /* not __STDC__ */
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of obj-aout.h */

View File

@ -0,0 +1,71 @@
/* obj-bfd-sunos.c
Copyright (C) 1987, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "as.h"
static
const short seg_N_TYPE[] = {
N_ABS,
N_TEXT,
N_DATA,
N_BSS,
N_UNDF, /* unknown */
N_UNDF, /* absent */
N_UNDF, /* pass1 */
N_UNDF, /* error */
N_UNDF, /* bignum/flonum */
N_UNDF, /* difference */
N_REGISTER, /* register */
};
const segT N_TYPE_seg[N_TYPE+2] = { /* N_TYPE == 0x1E = 32-2 */
SEG_UNKNOWN, /* N_UNDF == 0 */
SEG_GOOF,
SEG_ABSOLUTE, /* N_ABS == 2 */
SEG_GOOF,
SEG_TEXT, /* N_TEXT == 4 */
SEG_GOOF,
SEG_DATA, /* N_DATA == 6 */
SEG_GOOF,
SEG_BSS, /* N_BSS == 8 */
SEG_GOOF,
SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
SEG_REGISTER, /* dummy N_REGISTER for regs = 30 */
SEG_GOOF,
};
void obj_symbol_new_hook(symbolP)
symbolS *symbolP;
{
return;
} /* obj_symbol_new_hook() */
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of obj-bfd-sunos.c */

View File

@ -0,0 +1,69 @@
/*
Copyright (C) 1987, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* This file is obj-bfd-sunos.h.
*/
/* define an obj specific macro off which target cpu back ends may key. */
#define OBJ_BFD
#define OBJ_BFD_SUNOS
#include "bfd.h"
/* include whatever target cpu is appropriate. */
#include "targ-cpu.h"
/*
* SYMBOLS
*/
/*
* If your object format needs to reorder symbols, define this. When
* defined, symbols are kept on a doubly linked list and functions are
* made available for push, insert, append, and delete. If not defined,
* symbols are kept on a singly linked list, only the append and clear
* facilities are available, and they are macros.
*/
/* #define SYMBOLS_NEED_PACKPOINTERS */
typedef asymbol obj_symbol_type;
typedef void *object_headers;
#define S_SET_NAME(s, v) ((s)->sy_symbol.name = (v))
#define S_GET_NAME(s) ((s)->sy_symbol.name)
#define S_SET_SEGMENT(s,v) ((s)->sy_symbol.udata = (v))
#define S_GET_SEGMENT(s) ((s)->sy_symbol.udata)
#define S_SET_EXTERNAL(s) ((s)->sy_symbol.flags |= BSF_GLOBAL)
#define S_SET_VALUE(s,v) ((s)->sy_symbol.value = (v))
#define S_GET_VALUE(s) ((s)->sy_symbol.value)
#define S_IS_DEFINED(s) (!((s)->sy_symbol.flags & BSF_UNDEFINED))
#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (0) /* your magic number */
#define OBJ_EMIT_LINENO(a,b,c) /* must be *something*. This no-op's it out. */
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of obj-bfd-sunos.h */

View File

@ -0,0 +1,476 @@
/* b.out object file format
Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2,
or (at your option) any later version.
GAS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with GAS; see the file COPYING. If not, write
to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "as.h"
#include "obstack.h"
#ifndef NO_LISTING
#include "aout/stab_gnu.h"
#endif /* NO_LISTING */
const short /* in: segT out: N_TYPE bits */
seg_N_TYPE[] = {
N_ABS,
N_TEXT,
N_DATA,
N_BSS,
N_UNDF, /* unknown */
N_UNDF, /* absent */
N_UNDF, /* pass1 */
N_UNDF, /* error */
N_UNDF, /* bignum/flonum */
N_UNDF, /* difference */
N_REGISTER, /* register */
};
const segT N_TYPE_seg[N_TYPE+2] = { /* N_TYPE == 0x1E = 32-2 */
SEG_UNKNOWN, /* N_UNDF == 0 */
SEG_GOOF,
SEG_ABSOLUTE, /* N_ABS == 2 */
SEG_GOOF,
SEG_TEXT, /* N_TEXT == 4 */
SEG_GOOF,
SEG_DATA, /* N_DATA == 6 */
SEG_GOOF,
SEG_BSS, /* N_BSS == 8 */
SEG_GOOF,
SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
SEG_REGISTER, /* dummy N_REGISTER for regs = 30 */
SEG_GOOF,
};
#if __STDC__ == 1
static void obj_bout_stab(int what);
static void obj_bout_line(void);
static void obj_bout_desc(void);
#else /* not __STDC__ */
static void obj_bout_desc();
static void obj_bout_stab();
static void obj_bout_line();
#endif /* not __STDC__ */
const pseudo_typeS obj_pseudo_table[] = {
/* stabs (aka a.out aka b.out directives for debug symbols) */
{ "desc", obj_bout_desc, 0 }, /* def */
{ "line", obj_bout_line, 0 }, /* source code line number */
{ "stabd", obj_bout_stab, 'd' }, /* stabs */
{ "stabn", obj_bout_stab, 'n' }, /* stabs */
{ "stabs", obj_bout_stab, 's' }, /* stabs */
/* coff debugging directives. Currently ignored silently */
{ "def", s_ignore, 0 },
{ "dim", s_ignore, 0 },
{ "endef", s_ignore, 0 },
{ "ln", s_ignore, 0 },
{ "scl", s_ignore, 0 },
{ "size", s_ignore, 0 },
{ "tag", s_ignore, 0 },
{ "type", s_ignore, 0 },
{ "val", s_ignore, 0 },
/* other stuff we don't handle */
{ "ABORT", s_ignore, 0 },
{ "ident", s_ignore, 0 },
{ NULL} /* end sentinel */
}; /* obj_pseudo_table */
/* Relocation. */
/*
* emit_relocations()
*
* Crawl along a fixS chain. Emit the segment's relocations.
*/
void obj_emit_relocations(where, fixP, segment_address_in_file)
char **where;
fixS *fixP; /* Fixup chain for this segment. */
relax_addressT segment_address_in_file;
{
for (; fixP; fixP = fixP->fx_next) {
if (fixP->fx_addsy != NULL) {
tc_bout_fix_to_chars(*where, fixP, segment_address_in_file);
*where += sizeof(struct relocation_info);
} /* if there's a symbol */
} /* for each fixup */
} /* emit_relocations() */
/* Aout file generation & utilities */
/* Convert a lvalue to machine dependent data */
void obj_header_append(where, headers)
char **where;
object_headers *headers;
{
/* Always leave in host byte order */
headers->header.a_talign = section_alignment[SEG_TEXT];
if (headers->header.a_talign < 2){
headers->header.a_talign = 2;
} /* force to at least 2 */
headers->header.a_dalign = section_alignment[SEG_DATA];
headers->header.a_balign = section_alignment[SEG_BSS];
headers->header.a_tload = 0;
headers->header.a_dload = md_section_align(SEG_DATA, H_GET_TEXT_SIZE(headers));
append(where, (char *) &headers->header, sizeof(headers->header));
} /* a_header_append() */
void obj_symbol_to_chars(where, symbolP)
char **where;
symbolS *symbolP;
{
/* leave in host byte order */
append(where, (char *)&symbolP->sy_symbol, sizeof(obj_symbol_type));
} /* obj_symbol_to_chars() */
void obj_emit_symbols(where, symbol_rootP)
char **where;
symbolS *symbol_rootP;
{
symbolS * symbolP;
/*
* Emit all symbols left in the symbol chain.
*/
for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
/* Used to save the offset of the name. It is used to point
to the string in memory but must be a file offset. */
char *temp;
temp = S_GET_NAME(symbolP);
S_SET_OFFSET(symbolP, symbolP->sy_name_offset);
/* Any symbol still undefined and is not a dbg symbol is made N_EXT. */
if (!S_IS_DEBUG(symbolP) && !S_IS_DEFINED(symbolP)) S_SET_EXTERNAL(symbolP);
obj_symbol_to_chars(where, symbolP);
S_SET_NAME(symbolP,temp);
}
} /* emit_symbols() */
void obj_symbol_new_hook(symbolP)
symbolS *symbolP;
{
S_SET_OTHER(symbolP, 0);
S_SET_DESC(symbolP, 0);
return;
} /* obj_symbol_new_hook() */
static void obj_bout_line() {
/* Assume delimiter is part of expression. */
/* BSD4.2 as fails with delightful bug, so we */
/* are not being incompatible here. */
new_logical_line ((char *)NULL, (int)(get_absolute_expression ()));
demand_empty_rest_of_line();
} /* obj_bout_line() */
/*
* stab()
*
* Handle .stabX directives, which used to be open-coded.
* So much creeping featurism overloaded the semantics that we decided
* to put all .stabX thinking in one place. Here.
*
* We try to make any .stabX directive legal. Other people's AS will often
* do assembly-time consistency checks: eg assigning meaning to n_type bits
* and "protecting" you from setting them to certain values. (They also zero
* certain bits before emitting symbols. Tut tut.)
*
* If an expression is not absolute we either gripe or use the relocation
* information. Other people's assemblers silently forget information they
* don't need and invent information they need that you didn't supply.
*
* .stabX directives always make a symbol table entry. It may be junk if
* the rest of your .stabX directive is malformed.
*/
static void obj_bout_stab(what)
int what;
{
register symbolS * symbolP = 0;
register char * string;
int saved_type = 0;
int length;
int goof; /* TRUE if we have aborted. */
long longint;
/*
* Enter with input_line_pointer pointing past .stabX and any following
* whitespace.
*/
goof = 0; /* JF who forgot this?? */
if (what == 's') {
string = demand_copy_C_string(& length);
SKIP_WHITESPACE();
if (*input_line_pointer == ',')
input_line_pointer ++;
else {
as_bad("I need a comma after symbol's name");
goof = 1;
}
} else
string = "";
/*
* Input_line_pointer->after ','. String->symbol name.
*/
if (!goof) {
symbolP = symbol_new(string,
SEG_UNKNOWN,
0,
(struct frag *)0);
switch (what) {
case 'd':
S_SET_NAME(symbolP,NULL); /* .stabd feature. */
S_SET_VALUE(symbolP,obstack_next_free(&frags) -
frag_now->fr_literal);
symbolP->sy_frag = frag_now;
break;
case 'n':
symbolP->sy_frag = &zero_address_frag;
break;
case 's':
symbolP->sy_frag = & zero_address_frag;
break;
default:
BAD_CASE(what);
break;
}
if (get_absolute_expression_and_terminator(& longint) == ',')
symbolP->sy_symbol.n_type = saved_type = longint;
else {
as_bad("I want a comma after the n_type expression");
goof = 1;
input_line_pointer--; /* Backup over a non-',' char. */
}
}
if (! goof) {
if (get_absolute_expression_and_terminator (& longint) == ',')
S_SET_OTHER(symbolP,longint);
else {
as_bad("I want a comma after the n_other expression");
goof = 1;
input_line_pointer--; /* Backup over a non-',' char. */
}
}
if (! goof) {
S_SET_DESC(symbolP, get_absolute_expression ());
if (what == 's' || what == 'n') {
if (* input_line_pointer != ',') {
as_bad("I want a comma after the n_desc expression");
goof = 1;
} else {
input_line_pointer ++;
}
}
}
if ((!goof) && (what == 's' || what == 'n')) {
pseudo_set(symbolP);
symbolP->sy_symbol.n_type = saved_type;
}
#ifndef NO_LISTING
{
extern int listing;
if (listing && !goof) {
if (symbolP->sy_symbol.n_type == N_SLINE) {
listing_source_line(symbolP->sy_symbol.n_desc);
} else if (symbolP->sy_symbol.n_type == N_SO
|| symbolP->sy_symbol.n_type == N_SOL) {
listing_source_file(string);
}
}
}
#endif
if (goof)
ignore_rest_of_line ();
else
demand_empty_rest_of_line ();
} /* obj_bout_stab() */
static void obj_bout_desc() {
register char *name;
register char c;
register char *p;
register symbolS * symbolP;
register int temp;
/*
* Frob invented at RMS' request. Set the n_desc of a symbol.
*/
name = input_line_pointer;
c = get_symbol_end();
p = input_line_pointer;
* p = c;
SKIP_WHITESPACE();
if (*input_line_pointer != ',') {
*p = 0;
as_bad("Expected comma after name \"%s\"", name);
*p = c;
ignore_rest_of_line();
} else {
input_line_pointer ++;
temp = get_absolute_expression ();
*p = 0;
symbolP = symbol_find_or_make(name);
*p = c;
S_SET_DESC(symbolP,temp);
}
demand_empty_rest_of_line();
} /* obj_bout_desc() */
void obj_read_begin_hook() {
return;
} /* obj_read_begin_hook() */
void obj_crawl_symbol_chain(headers)
object_headers *headers;
{
symbolS **symbolPP;
symbolS *symbolP;
int symbol_number = 0;
/* JF deal with forward references first... */
for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
if (symbolP->sy_forward) {
S_SET_VALUE(symbolP, S_GET_VALUE(symbolP)
+ S_GET_VALUE(symbolP->sy_forward)
+ symbolP->sy_forward->sy_frag->fr_address);
symbolP->sy_forward=0;
} /* if it has a forward reference */
} /* walk the symbol chain */
tc_crawl_symbol_chain(headers);
symbolPP = & symbol_rootP; /*->last symbol chain link. */
while ((symbolP = *symbolPP) != NULL) {
if (flagseen['R'] && (S_GET_SEGMENT(symbolP) == SEG_DATA)) {
S_SET_SEGMENT(symbolP, SEG_TEXT);
} /* if pusing data into text */
S_SET_VALUE(symbolP, S_GET_VALUE(symbolP) + symbolP->sy_frag->fr_address);
/* OK, here is how we decide which symbols go out into the
brave new symtab. Symbols that do are:
* symbols with no name (stabd's?)
* symbols with debug info in their N_TYPE
Symbols that don't are:
* symbols that are registers
* symbols with \1 as their 3rd character (numeric labels)
* "local labels" as defined by S_LOCAL_NAME(name)
if the -L switch was passed to gas.
All other symbols are output. We complain if a deleted
symbol was marked external. */
if (1
&& !S_IS_REGISTER(symbolP)
&& (!S_GET_NAME(symbolP)
|| S_IS_DEBUG(symbolP)
#ifdef TC_I960
/* FIXME-SOON this ifdef seems highly dubious to me. xoxorich. */
|| !S_IS_DEFINED(symbolP)
|| S_IS_EXTERNAL(symbolP)
#endif /* TC_I960 */
|| (S_GET_NAME(symbolP)[0] != '\001' && (flagseen['L'] || ! S_LOCAL_NAME(symbolP))))) {
symbolP->sy_number = symbol_number++;
/* The + 1 after strlen account for the \0 at the
end of each string */
if (!S_IS_STABD(symbolP)) {
/* Ordinary case. */
symbolP->sy_name_offset = string_byte_count;
string_byte_count += strlen(S_GET_NAME(symbolP)) + 1;
}
else /* .Stabd case. */
symbolP->sy_name_offset = 0;
symbolPP = &(symbol_next(symbolP));
} else {
if (S_IS_EXTERNAL(symbolP) || !S_IS_DEFINED(symbolP)) {
as_bad("Local symbol %s never defined", S_GET_NAME(symbolP));
} /* oops. */
/* Unhook it from the chain */
*symbolPP = symbol_next(symbolP);
} /* if this symbol should be in the output */
} /* for each symbol */
H_SET_SYMBOL_TABLE_SIZE(headers, symbol_number);
return;
} /* obj_crawl_symbol_chain() */
/*
* Find strings by crawling along symbol table chain.
*/
void obj_emit_strings(where)
char **where;
{
symbolS *symbolP;
#ifdef CROSS_COMPILE
/* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */
md_number_to_chars(*where, string_byte_count, sizeof(string_byte_count));
*where += sizeof(string_byte_count);
#else /* CROSS_COMPILE */
append(where, (char *) &string_byte_count, (unsigned long) sizeof(string_byte_count));
#endif /* CROSS_COMPILE */
for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
if (S_GET_NAME(symbolP))
append(where, S_GET_NAME(symbolP), (unsigned long)(strlen (S_GET_NAME(symbolP)) + 1));
} /* walk symbol chain */
return;
} /* obj_emit_strings() */
void obj_pre_write_hook(headers)
object_headers *headers;
{
H_SET_MAGIC_NUMBER(headers, BMAGIC);
H_SET_ENTRY_POINT(headers, 0);
return;
} /* obj_pre_write_hook() */
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of obj-bout.c */

View File

@ -0,0 +1,313 @@
/* b.out object file format
Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2,
or (at your option) any later version.
GAS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with GAS; see the file COPYING. If not, write
to the Free Software Foundation, 675 Mass Ave, Cambridge, MA
02139, USA. */
/*
* This file is a modified version of 'a.out.h'. It is to be used in all GNU
* tools modified to support the i80960 b.out format (or tools that operate on
* object files created by such tools).
*
* All i80960 development is done in a CROSS-DEVELOPMENT environment. I.e.,
* object code is generated on, and executed under the direction of a symbolic
* debugger running on, a host system. We do not want to be subject to the
* vagaries of which host it is or whether it supports COFF or a.out format, or
* anything else. We DO want to:
*
* o always generate the same format object files, regardless of host.
*
* o have an 'a.out' header that we can modify for our own purposes
* (the 80960 is typically an embedded processor and may require
* enhanced linker support that the normal a.out.h header can't
* accommodate).
*
* As for byte-ordering, the following rules apply:
*
* o Text and data that is actually downloaded to the target is always
* in i80960 (little-endian) order.
*
* o All other numbers (in the header, symbols, relocation directives)
* are in host byte-order: object files CANNOT be lifted from a
* little-end host and used on a big-endian (or vice versa) without
* modification.
*
* o The downloader ('comm960') takes care to generate a pseudo-header
* with correct (i80960) byte-ordering before shipping text and data
* off to the NINDY monitor in the target systems. Symbols and
* relocation info are never sent to the target.
*/
#define OBJ_BOUT 1
#include "targ-cpu.h"
/* bout uses host byte order for headers */
#ifdef CROSS_COMPILE
#undef CROSS_COMPILE
#endif /* CROSS_COMPILE */
/* We want \v. */
#define BACKSLASH_V 1
#define OBJ_DEFAULT_OUTPUT_FILE_NAME "b.out"
extern const short seg_N_TYPE[];
extern const segT N_TYPE_seg[];
#define BMAGIC 0415
/* We don't accept the following (see N_BADMAG macro).
* They're just here so GNU code will compile.
*/
#define OMAGIC 0407 /* old impure format */
#define NMAGIC 0410 /* read-only text */
#define ZMAGIC 0413 /* demand load format */
/* FILE HEADER
* All 'lengths' are given as a number of bytes.
* All 'alignments' are for relinkable files only; an alignment of
* 'n' indicates the corresponding segment must begin at an
* address that is a multiple of (2**n).
*/
struct exec {
/* Standard stuff */
unsigned long a_magic; /* Identifies this as a b.out file */
unsigned long a_text; /* Length of text */
unsigned long a_data; /* Length of data */
unsigned long a_bss; /* Length of runtime uninitialized data area */
unsigned long a_syms; /* Length of symbol table */
unsigned long a_entry; /* Runtime start address */
unsigned long a_trsize; /* Length of text relocation info */
unsigned long a_drsize; /* Length of data relocation info */
/* Added for i960 */
unsigned long a_tload; /* Text runtime load address */
unsigned long a_dload; /* Data runtime load address */
unsigned char a_talign; /* Alignment of text segment */
unsigned char a_dalign; /* Alignment of data segment */
unsigned char a_balign; /* Alignment of bss segment */
unsigned char unused; /* (Just to make struct size a multiple of 4) */
};
#define N_BADMAG(x) (((x).a_magic) != BMAGIC)
#define N_TXTOFF(x) ( sizeof(struct exec) )
#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
#define N_TROFF(x) ( N_DATOFF(x) + (x).a_data )
#define N_DROFF(x) ( N_TROFF(x) + (x).a_trsize )
#define N_SYMOFF(x) ( N_DROFF(x) + (x).a_drsize )
#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
/* A single entry in the symbol table
*/
struct nlist {
union {
char *n_name;
struct nlist *n_next;
long n_strx; /* Index into string table */
} n_un;
unsigned char n_type; /* See below */
char n_other; /* Used in i80960 support -- see below */
short n_desc;
unsigned long n_value;
};
typedef struct nlist obj_symbol_type;
/* Legal values of n_type
*/
#define N_UNDF 0 /* Undefined symbol */
#define N_ABS 2 /* Absolute symbol */
#define N_TEXT 4 /* Text symbol */
#define N_DATA 6 /* Data symbol */
#define N_BSS 8 /* BSS symbol */
#define N_FN 31 /* Filename symbol */
#define N_EXT 1 /* External symbol (OR'd in with one of above) */
#define N_TYPE 036 /* Mask for all the type bits */
#define N_STAB 0340 /* Mask for all bits used for SDB entries */
#ifndef CUSTOM_RELOC_FORMAT
struct relocation_info {
int r_address; /* File address of item to be relocated */
unsigned
r_index:24,/* Index of symbol on which relocation is based*/
r_pcrel:1, /* 1 => relocate PC-relative; else absolute
* On i960, pc-relative implies 24-bit
* address, absolute implies 32-bit.
*/
r_length:2, /* Number of bytes to relocate:
* 0 => 1 byte
* 1 => 2 bytes
* 2 => 4 bytes -- only value used for i960
*/
r_extern:1,
r_bsr:1, /* Something for the GNU NS32K assembler */
r_disp:1, /* Something for the GNU NS32K assembler */
r_callj:1, /* 1 if relocation target is an i960 'callj' */
nuthin:1; /* Unused */
};
#endif /* CUSTOM_RELOC_FORMAT */
/*
* Macros to extract information from a symbol table entry.
* This syntaxic indirection allows independence regarding a.out or coff.
* The argument (s) of all these macros is a pointer to a symbol table entry.
*/
/* Predicates */
/* True if the symbol is external */
#define S_IS_EXTERNAL(s) ((s)->sy_symbol.n_type & N_EXT)
/* True if symbol has been defined, ie is in N_{TEXT,DATA,BSS,ABS} or N_EXT */
#define S_IS_DEFINED(s) ((S_GET_TYPE(s) != N_UNDF) || (S_GET_DESC(s) != 0))
#define S_IS_REGISTER(s) ((s)->sy_symbol.n_type == N_REGISTER)
/* True if a debug special symbol entry */
#define S_IS_DEBUG(s) ((s)->sy_symbol.n_type & N_STAB)
/* True if a symbol is local symbol name */
/* A symbol name whose name begin with ^A is a gas internal pseudo symbol
nameless symbols come from .stab directives. */
#define S_IS_LOCAL(s) (S_GET_NAME(s) && \
!S_IS_DEBUG(s) && \
(S_GET_NAME(s)[0] == '\001' || \
(S_LOCAL_NAME(s) && !flagseen['L'])))
/* True if a symbol is not defined in this file */
#define S_IS_EXTERN(s) ((s)->sy_symbol.n_type & N_EXT)
/* True if the symbol has been generated because of a .stabd directive */
#define S_IS_STABD(s) (S_GET_NAME(s) == NULL)
/* Accessors */
/* The value of the symbol */
#define S_GET_VALUE(s) ((unsigned long) ((s)->sy_symbol.n_value))
/* The name of the symbol */
#define S_GET_NAME(s) ((s)->sy_symbol.n_un.n_name)
/* The pointer to the string table */
#define S_GET_OFFSET(s) ((s)->sy_symbol.n_un.n_strx)
/* The type of the symbol */
#define S_GET_TYPE(s) ((s)->sy_symbol.n_type & N_TYPE)
/* The numeric value of the segment */
#define S_GET_SEGMENT(s) (N_TYPE_seg[S_GET_TYPE(s)])
/* The n_other expression value */
#define S_GET_OTHER(s) ((s)->sy_symbol.n_other)
/* The n_desc expression value */
#define S_GET_DESC(s) ((s)->sy_symbol.n_desc)
/* Modifiers */
/* Set the value of the symbol */
#define S_SET_VALUE(s,v) ((s)->sy_symbol.n_value = (unsigned long) (v))
/* Assume that a symbol cannot be simultaneously in more than on segment */
/* set segment */
#define S_SET_SEGMENT(s,seg) ((s)->sy_symbol.n_type &= ~N_TYPE,(s)->sy_symbol.n_type|=SEGMENT_TO_SYMBOL_TYPE(seg))
/* The symbol is external */
#define S_SET_EXTERNAL(s) ((s)->sy_symbol.n_type |= N_EXT)
/* The symbol is not external */
#define S_CLEAR_EXTERNAL(s) ((s)->sy_symbol.n_type &= ~N_EXT)
/* Set the name of the symbol */
#define S_SET_NAME(s,v) ((s)->sy_symbol.n_un.n_name = (v))
/* Set the offset in the string table */
#define S_SET_OFFSET(s,v) ((s)->sy_symbol.n_un.n_strx = (v))
/* Set the n_other expression value */
#define S_SET_OTHER(s,v) ((s)->sy_symbol.n_other = (v))
/* Set the n_desc expression value */
#define S_SET_DESC(s,v) ((s)->sy_symbol.n_desc = (v))
/* File header macro and type definition */
#define H_GET_FILE_SIZE(h) (sizeof(struct exec) + \
H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
H_GET_SYMBOL_TABLE_SIZE(h) + \
H_GET_TEXT_RELOCATION_SIZE(h) + \
H_GET_DATA_RELOCATION_SIZE(h) + \
(h)->string_table_size)
#define H_GET_HEADER_SIZE(h) (sizeof(struct exec))
#define H_GET_TEXT_SIZE(h) ((h)->header.a_text)
#define H_GET_DATA_SIZE(h) ((h)->header.a_data)
#define H_GET_BSS_SIZE(h) ((h)->header.a_bss)
#define H_GET_TEXT_RELOCATION_SIZE(h) ((h)->header.a_trsize)
#define H_GET_DATA_RELOCATION_SIZE(h) ((h)->header.a_drsize)
#define H_GET_SYMBOL_TABLE_SIZE(h) ((h)->header.a_syms)
#define H_GET_MAGIC_NUMBER(h) ((h)->header.a_info)
#define H_GET_ENTRY_POINT(h) ((h)->header.a_entry)
#define H_GET_STRING_SIZE(h) ((h)->string_table_size)
#define H_GET_LINENO_SIZE(h) (0)
#ifdef EXEC_MACHINE_TYPE
#define H_GET_MACHINE_TYPE(h) ((h)->header.a_machtype)
#endif /* EXEC_MACHINE_TYPE */
#ifdef EXEC_VERSION
#define H_GET_VERSION(h) ((h)->header.a_version)
#endif /* EXEC_VERSION */
#define H_SET_TEXT_SIZE(h,v) ((h)->header.a_text = (v))
#define H_SET_DATA_SIZE(h,v) ((h)->header.a_data = (v))
#define H_SET_BSS_SIZE(h,v) ((h)->header.a_bss = (v))
#define H_SET_RELOCATION_SIZE(h,t,d) (H_SET_TEXT_RELOCATION_SIZE((h),(t)),\
H_SET_DATA_RELOCATION_SIZE((h),(d)))
#define H_SET_TEXT_RELOCATION_SIZE(h,v) ((h)->header.a_trsize = (v))
#define H_SET_DATA_RELOCATION_SIZE(h,v) ((h)->header.a_drsize = (v))
#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * \
sizeof(struct nlist))
#define H_SET_MAGIC_NUMBER(h,v) ((h)->header.a_magic = (v))
#define H_SET_ENTRY_POINT(h,v) ((h)->header.a_entry = (v))
#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v))
#ifdef EXEC_MACHINE_TYPE
#define H_SET_MACHINE_TYPE(h,v) ((h)->header.a_machtype = (v))
#endif /* EXEC_MACHINE_TYPE */
#ifdef EXEC_VERSION
#define H_SET_VERSION(h,v) ((h)->header.a_version = (v))
#endif /* EXEC_VERSION */
/*
* Current means for getting the name of a segment.
* This will change for infinite-segments support (e.g. COFF).
*/
#define segment_name(seg) ( seg_name[(int)(seg)] )
extern char *const seg_name[];
typedef struct {
struct exec header; /* a.out header */
long string_table_size; /* names + '\0' + sizeof(int) */
} object_headers;
/* unused hooks. */
#define OBJ_EMIT_LINENO(a, b, c) {;}
#if __STDC__
struct fix;
void tc_aout_fix_to_chars(char *where, struct fix *fixP, relax_addressT segment_address);
#else /* not __STDC__ */
void tc_aout_fix_to_chars();
#endif /* not __STDC__ */
enum reloc_type {
NO_RELOC, RELOC_32,
};
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of obj-bout.h */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,598 @@
/* coff object file format
Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define OBJ_COFF 1
#include "targ-cpu.h"
#ifdef BFD_HEADERS
#ifdef TC_A29K
#include "bfd.h"
#include "coff/a29k.h"
/* This internal_lineno crap is to stop namespace pollution from the bfd internal
coff headerfile. */
#define internal_lineno bfd_internal_lineno
#include "coff/internal.h"
#undef internal_lineno
/*
#undef RELOC
#undef SYMENT
#undef AUXENT
#undef LINENO
#undef FILHDR
#undef SCNHDR
#define RELOC struct internal_reloc
#define SYMENT struct internal_syment
#define AUXENT union internal_auxent
#define SCNHDR struct internal_scnhdr
#define LINENO struct bfd_internal_lineno
#define AOUTHDR struct internal_aouthdr
#define FILHDR struct internal_filehdr
#define AOUTHDRSZ sizeof(struct external_aouthdr)
*/
/*#define x_endndx x_endndx.l
#define x_tagndx x_tagndx.l*/
#define TARGET_FORMAT "coff-a29k-big"
extern bfd *stdoutput;
#else /* not TC_A29K */
# ifdef TC_I386
# include "bfd.h"
# include "coff/i386.h"
# define internal_lineno bfd_internal_lineno
# include "coff/internal.h"
# undef internal_lineno
# define TARGET_FORMAT "coff-i386"
extern bfd *stdoutput;
#else /* not TC_I386 */
#error help me
#endif /* not TC_I386 */
#endif /* not TC_A29K */
#else /* not BFD_HEADERS */
#ifdef USE_NATIVE_HEADERS
#include <filehdr.h>
#include <aouthdr.h>
#include <scnhdr.h>
#include <storclass.h>
#include <linenum.h>
#include <syms.h>
#include <reloc.h>
#include <sys/types.h>
#else /* not USE_NATIVE_HEADERS */
#include "coff.h"
#endif /* not USE_NATIVE_HEADERS */
#endif /* not BFD_HEADERS */
/* Define some processor dependent values according to the processor we are on. */
#ifdef TC_M68K
#define BYTE_ORDERING F_AR32W /* See filehdr.h for more info. */
#ifndef FILE_HEADER_MAGIC
#define FILE_HEADER_MAGIC MC68MAGIC /* ... */
#endif /* FILE_HEADER_MAGIC */
#elif defined(TC_I386)
#define BYTE_ORDERING F_AR32WR /* See filehdr.h for more info. */
#ifndef FILE_HEADER_MAGIC
#define FILE_HEADER_MAGIC I386MAGIC /* ... */
#endif /* FILE_HEADER_MAGIC */
#elif defined(TC_I960)
#define BYTE_ORDERING F_AR32WR /* See filehdr.h for more info. */
#ifndef FILE_HEADER_MAGIC
#define FILE_HEADER_MAGIC I960ROMAGIC /* ... */
#endif /* FILE_HEADER_MAGIC */
#elif defined(TC_A29K)
#define BYTE_ORDERING F_AR32W /* big endian. */
#ifndef FILE_HEADER_MAGIC
#define FILE_HEADER_MAGIC SIPFBOMAGIC
#endif /* FILE_HEADER_MAGIC */
#else
you lose
#endif
#ifndef OBJ_COFF_MAX_AUXENTRIES
#define OBJ_COFF_MAX_AUXENTRIES 1
#endif /* OBJ_COFF_MAX_AUXENTRIES */
extern const short seg_N_TYPE[];
extern const segT N_TYPE_seg[];
#ifndef BFD_HEADERS
/* Add these definitions to have a consistent convention for all the
types used in COFF format. */
#define AOUTHDR struct aouthdr
#define AOUTHDRSZ sizeof(AOUTHDR)
#endif
/* SYMBOL TABLE */
/* targets may also set this */
#ifndef SYMBOLS_NEED_BACKPOINTERS
#define SYMBOLS_NEED_BACKPOINTERS 1
#endif /* SYMBOLS_NEED_BACKPOINTERS */
/* Symbol table entry data type */
typedef struct {
#ifdef BFD_HEADERS
struct internal_syment ost_entry; /* Basic symbol */
union internal_auxent ost_auxent[OBJ_COFF_MAX_AUXENTRIES]; /* Auxiliary entry. */
#else
SYMENT ost_entry; /* Basic symbol */
AUXENT ost_auxent[OBJ_COFF_MAX_AUXENTRIES]; /* Auxiliary entry. */
#endif
unsigned int ost_flags; /* obj_coff internal use only flags */
} obj_symbol_type;
#define DO_NOT_STRIP 0
#define DO_STRIP 1
/* Symbol table macros and constants */
/* Possible and usefull section number in symbol table
* The values of TEXT, DATA and BSS may not be portable.
*/
#define C_TEXT_SECTION ((short)1)
#define C_DATA_SECTION ((short)2)
#define C_BSS_SECTION ((short)3)
#define C_ABS_SECTION N_ABS
#define C_UNDEF_SECTION N_UNDEF
#define C_DEBUG_SECTION N_DEBUG
#define C_NTV_SECTION N_TV
#define C_PTV_SECTION P_TV
#define C_REGISTER_SECTION 4
/*
* Macros to extract information from a symbol table entry.
* This syntaxic indirection allows independence regarding a.out or coff.
* The argument (s) of all these macros is a pointer to a symbol table entry.
*/
/* Predicates */
/* True if the symbol is external */
#define S_IS_EXTERNAL(s) ((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION)
/* True if symbol has been defined, ie :
section > 0 (DATA, TEXT or BSS)
section == 0 and value > 0 (external bss symbol) */
#define S_IS_DEFINED(s) ((s)->sy_symbol.ost_entry.n_scnum > C_UNDEF_SECTION || \
((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION && \
(s)->sy_symbol.ost_entry.n_value > 0))
/* True if a debug special symbol entry */
#define S_IS_DEBUG(s) ((s)->sy_symbol.ost_entry.n_scnum == C_DEBUG_SECTION)
/* True if a symbol is local symbol name */
/* A symbol name whose name begin with ^A is a gas internal pseudo symbol */
#define S_IS_LOCAL(s) (S_GET_NAME(s)[0] == '\001' || \
(s)->sy_symbol.ost_entry.n_scnum == C_REGISTER_SECTION || \
(S_LOCAL_NAME(s) && !flagseen['L']))
/* True if a symbol is not defined in this file */
#define S_IS_EXTERN(s) ((s)->sy_symbol.ost_entry.n_scnum == 0 && (s)->sy_symbol.ost_entry.n_value == 0)
/*
* True if a symbol can be multiply defined (bss symbols have this def
* though it is bad practice)
*/
#define S_IS_COMMON(s) ((s)->sy_symbol.ost_entry.n_scnum == 0 && (s)->sy_symbol.ost_entry.n_value != 0)
/* True if a symbol name is in the string table, i.e. its length is > 8. */
#define S_IS_STRING(s) (strlen(S_GET_NAME(s)) > 8 ? 1 : 0)
/* Accessors */
/* The name of the symbol */
#define S_GET_NAME(s) ((char*)(s)->sy_symbol.ost_entry.n_offset)
/* The pointer to the string table */
#define S_GET_OFFSET(s) ((s)->sy_symbol.ost_entry.n_offset)
/* The zeroes if symbol name is longer than 8 chars */
#define S_GET_ZEROES(s) ((s)->sy_symbol.ost_entry.n_zeroes)
/* The value of the symbol */
#define S_GET_VALUE(s) ((unsigned) ((s)->sy_symbol.ost_entry.n_value))
/* The numeric value of the segment */
#define S_GET_SEGMENT(s) (N_TYPE_seg[(s)->sy_symbol.ost_entry.n_scnum+4])
/* The data type */
#define S_GET_DATA_TYPE(s) ((s)->sy_symbol.ost_entry.n_type)
/* The storage class */
#define S_GET_STORAGE_CLASS(s) ((s)->sy_symbol.ost_entry.n_sclass)
/* The number of auxiliary entries */
#define S_GET_NUMBER_AUXILIARY(s) ((s)->sy_symbol.ost_entry.n_numaux)
/* Modifiers */
/* Set the name of the symbol */
#define S_SET_NAME(s,v) ((s)->sy_symbol.ost_entry.n_offset = (unsigned long)(v))
/* Set the offset of the symbol */
#define S_SET_OFFSET(s,v) ((s)->sy_symbol.ost_entry.n_offset = (v))
/* The zeroes if symbol name is longer than 8 chars */
#define S_SET_ZEROES(s,v) ((s)->sy_symbol.ost_entry.n_zeroes = (v))
/* Set the value of the symbol */
#define S_SET_VALUE(s,v) ((s)->sy_symbol.ost_entry.n_value = (v))
/* The numeric value of the segment */
#define S_SET_SEGMENT(s,v) ((s)->sy_symbol.ost_entry.n_scnum = SEGMENT_TO_SYMBOL_TYPE(v))
/* The data type */
#define S_SET_DATA_TYPE(s,v) ((s)->sy_symbol.ost_entry.n_type = (v))
/* The storage class */
#define S_SET_STORAGE_CLASS(s,v) ((s)->sy_symbol.ost_entry.n_sclass = (v))
/* The number of auxiliary entries */
#define S_SET_NUMBER_AUXILIARY(s,v) ((s)->sy_symbol.ost_entry.n_numaux = (v))
/* Additional modifiers */
/* The symbol is external (does not mean undefined) */
#define S_SET_EXTERNAL(s) { S_SET_STORAGE_CLASS(s, C_EXT) ; SF_CLEAR_LOCAL(s); }
/* Auxiliary entry macros. SA_ stands for symbol auxiliary */
/* Omit the tv related fields */
/* Accessors */
#ifdef BFD_HEADERS
#define SA_GET_SYM_TAGNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx.l)
#else
#define SA_GET_SYM_TAGNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx)
#endif
#define SA_GET_SYM_LNNO(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_lnno)
#define SA_GET_SYM_SIZE(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_size)
#define SA_GET_SYM_FSIZE(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_fsize)
#define SA_GET_SYM_LNNOPTR(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_lnnoptr)
#ifdef BFD_HEADERS
#define SA_GET_SYM_ENDNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx.l)
#else
#define SA_GET_SYM_ENDNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx)
#endif
#define SA_GET_SYM_DIMEN(s,i) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen[(i)])
#define SA_GET_FILE_FNAME(s) ((s)->sy_symbol.ost_auxent[0].x_file.x_fname)
#define SA_GET_SCN_SCNLEN(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_scnlen)
#define SA_GET_SCN_NRELOC(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nreloc)
#define SA_GET_SCN_NLINNO(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nlinno)
/* Modifiers */
#ifdef BFD_HEADERS
#define SA_SET_SYM_TAGNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx.l=(v))
#else
#define SA_SET_SYM_TAGNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx=(v))
#endif
#define SA_SET_SYM_LNNO(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_lnno=(v))
#define SA_SET_SYM_SIZE(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_size=(v))
#define SA_SET_SYM_FSIZE(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_fsize=(v))
#define SA_SET_SYM_LNNOPTR(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_lnnoptr=(v))
#ifdef BFD_HEADERS
#define SA_SET_SYM_ENDNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx.l=(v))
#else
#define SA_SET_SYM_ENDNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx=(v))
#endif
#define SA_SET_SYM_DIMEN(s,i,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen[(i)]=(v))
#define SA_SET_FILE_FNAME(s,v) strncpy((s)->sy_symbol.ost_auxent[0].x_file.x_fname,(v),FILNMLEN)
#define SA_SET_SCN_SCNLEN(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_scnlen=(v))
#define SA_SET_SCN_NRELOC(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nreloc=(v))
#define SA_SET_SCN_NLINNO(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nlinno=(v))
/*
* Internal use only definitions. SF_ stands for symbol flags.
*
* These values can be assigned to sy_symbol.ost_flags field of a symbolS.
*
* You'll break i960 if you shift the SYSPROC bits anywhere else. for
* more on the balname/callname hack, see tc-i960.h. b.out is done
* differently.
*/
#define SF_I960_MASK (0x000001ff) /* Bits 0-8 are used by the i960 port. */
#define SF_SYSPROC (0x0000003f) /* bits 0-5 are used to store the sysproc number */
#define SF_IS_SYSPROC (0x00000040) /* bit 6 marks symbols that are sysprocs */
#define SF_BALNAME (0x00000080) /* bit 7 marks BALNAME symbols */
#define SF_CALLNAME (0x00000100) /* bit 8 marks CALLNAME symbols */
#define SF_NORMAL_MASK (0x0000ffff) /* bits 12-15 are general purpose. */
#define SF_STATICS (0x00001000) /* Mark the .text & all symbols */
#define SF_DEFINED (0x00002000) /* Symbol is defined in this file */
#define SF_STRING (0x00004000) /* Symbol name length > 8 */
#define SF_LOCAL (0x00008000) /* Symbol must not be emitted */
#define SF_DEBUG_MASK (0xffff0000) /* bits 16-31 are debug info */
#define SF_FUNCTION (0x00010000) /* The symbol is a function */
#define SF_PROCESS (0x00020000) /* Process symbol before write */
#define SF_TAGGED (0x00040000) /* Is associated with a tag */
#define SF_TAG (0x00080000) /* Is a tag */
#define SF_DEBUG (0x00100000) /* Is in debug or abs section */
#define SF_GET_SEGMENT (0x00200000) /* Get the section of the forward symbol. */
/* All other bits are unused. */
/* Accessors */
#define SF_GET(s) ((s)->sy_symbol.ost_flags)
#define SF_GET_NORMAL_FIELD(s) ((s)->sy_symbol.ost_flags & SF_NORMAL_MASK)
#define SF_GET_DEBUG_FIELD(s) ((s)->sy_symbol.ost_flags & SF_DEBUG_MASK)
#define SF_GET_FILE(s) ((s)->sy_symbol.ost_flags & SF_FILE)
#define SF_GET_STATICS(s) ((s)->sy_symbol.ost_flags & SF_STATICS)
#define SF_GET_DEFINED(s) ((s)->sy_symbol.ost_flags & SF_DEFINED)
#define SF_GET_STRING(s) ((s)->sy_symbol.ost_flags & SF_STRING)
#define SF_GET_LOCAL(s) ((s)->sy_symbol.ost_flags & SF_LOCAL)
#define SF_GET_FUNCTION(s) ((s)->sy_symbol.ost_flags & SF_FUNCTION)
#define SF_GET_PROCESS(s) ((s)->sy_symbol.ost_flags & SF_PROCESS)
#define SF_GET_DEBUG(s) ((s)->sy_symbol.ost_flags & SF_DEBUG)
#define SF_GET_TAGGED(s) ((s)->sy_symbol.ost_flags & SF_TAGGED)
#define SF_GET_TAG(s) ((s)->sy_symbol.ost_flags & SF_TAG)
#define SF_GET_GET_SEGMENT(s) ((s)->sy_symbol.ost_flags & SF_GET_SEGMENT)
#define SF_GET_I960(s) ((s)->sy_symbol.ost_flags & SF_I960_MASK) /* used by i960 */
#define SF_GET_BALNAME(s) ((s)->sy_symbol.ost_flags & SF_BALNAME) /* used by i960 */
#define SF_GET_CALLNAME(s) ((s)->sy_symbol.ost_flags & SF_CALLNAME) /* used by i960 */
#define SF_GET_IS_SYSPROC(s) ((s)->sy_symbol.ost_flags & SF_IS_SYSPROC) /* used by i960 */
#define SF_GET_SYSPROC(s) ((s)->sy_symbol.ost_flags & SF_SYSPROC) /* used by i960 */
/* Modifiers */
#define SF_SET(s,v) ((s)->sy_symbol.ost_flags = (v))
#define SF_SET_NORMAL_FIELD(s,v)((s)->sy_symbol.ost_flags |= ((v) & SF_NORMAL_MASK))
#define SF_SET_DEBUG_FIELD(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_DEBUG_MASK))
#define SF_SET_FILE(s) ((s)->sy_symbol.ost_flags |= SF_FILE)
#define SF_SET_STATICS(s) ((s)->sy_symbol.ost_flags |= SF_STATICS)
#define SF_SET_DEFINED(s) ((s)->sy_symbol.ost_flags |= SF_DEFINED)
#define SF_SET_STRING(s) ((s)->sy_symbol.ost_flags |= SF_STRING)
#define SF_SET_LOCAL(s) ((s)->sy_symbol.ost_flags |= SF_LOCAL)
#define SF_CLEAR_LOCAL(s) ((s)->sy_symbol.ost_flags &= ~SF_LOCAL)
#define SF_SET_FUNCTION(s) ((s)->sy_symbol.ost_flags |= SF_FUNCTION)
#define SF_SET_PROCESS(s) ((s)->sy_symbol.ost_flags |= SF_PROCESS)
#define SF_SET_DEBUG(s) ((s)->sy_symbol.ost_flags |= SF_DEBUG)
#define SF_SET_TAGGED(s) ((s)->sy_symbol.ost_flags |= SF_TAGGED)
#define SF_SET_TAG(s) ((s)->sy_symbol.ost_flags |= SF_TAG)
#define SF_SET_GET_SEGMENT(s) ((s)->sy_symbol.ost_flags |= SF_GET_SEGMENT)
#define SF_SET_I960(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_I960_MASK)) /* used by i960 */
#define SF_SET_BALNAME(s) ((s)->sy_symbol.ost_flags |= SF_BALNAME) /* used by i960 */
#define SF_SET_CALLNAME(s) ((s)->sy_symbol.ost_flags |= SF_CALLNAME) /* used by i960 */
#define SF_SET_IS_SYSPROC(s) ((s)->sy_symbol.ost_flags |= SF_IS_SYSPROC) /* used by i960 */
#define SF_SET_SYSPROC(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_SYSPROC)) /* used by i960 */
/* File header macro and type definition */
/*
* File position calculators. Beware to use them when all the
* appropriate fields are set in the header.
*/
#ifdef OBJ_COFF_OMIT_OPTIONAL_HEADER
#define OBJ_COFF_AOUTHDRSZ (0)
#else
#define OBJ_COFF_AOUTHDRSZ (AOUTHDRSZ)
#endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
#define H_GET_FILE_SIZE(h) \
(long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h) + \
H_GET_SYMBOL_TABLE_SIZE(h) + \
(h)->string_table_size)
#define H_GET_TEXT_FILE_OFFSET(h) \
(long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ)
#define H_GET_DATA_FILE_OFFSET(h) \
(long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
H_GET_TEXT_SIZE(h))
#define H_GET_BSS_FILE_OFFSET(h) 0
#define H_GET_RELOCATION_FILE_OFFSET(h) \
(long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h))
#define H_GET_LINENO_FILE_OFFSET(h) \
(long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
H_GET_RELOCATION_SIZE(h))
#define H_GET_SYMBOL_TABLE_FILE_OFFSET(h) \
(long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h))
/* Accessors */
/* aouthdr */
#define H_GET_MAGIC_NUMBER(h) ((h)->aouthdr.magic)
#define H_GET_VERSION_STAMP(h) ((h)->aouthdr.vstamp)
#define H_GET_TEXT_SIZE(h) ((h)->aouthdr.tsize)
#define H_GET_DATA_SIZE(h) ((h)->aouthdr.dsize)
#define H_GET_BSS_SIZE(h) ((h)->aouthdr.bsize)
#define H_GET_ENTRY_POINT(h) ((h)->aouthdr.entry)
#define H_GET_TEXT_START(h) ((h)->aouthdr.text_start)
#define H_GET_DATA_START(h) ((h)->aouthdr.data_start)
/* filehdr */
#define H_GET_FILE_MAGIC_NUMBER(h) ((h)->filehdr.f_magic)
#define H_GET_NUMBER_OF_SECTIONS(h) ((h)->filehdr.f_nscns)
#define H_GET_TIME_STAMP(h) ((h)->filehdr.f_timdat)
#define H_GET_SYMBOL_TABLE_POINTER(h) ((h)->filehdr.f_symptr)
#define H_GET_SYMBOL_COUNT(h) ((h)->filehdr.f_nsyms)
#define H_GET_SYMBOL_TABLE_SIZE(h) (H_GET_SYMBOL_COUNT(h) * SYMESZ)
#define H_GET_SIZEOF_OPTIONAL_HEADER(h) ((h)->filehdr.f_opthdr)
#define H_GET_FLAGS(h) ((h)->filehdr.f_flags)
/* Extra fields to achieve bsd a.out compatibility and for convenience */
#define H_GET_RELOCATION_SIZE(h) ((h)->relocation_size)
#define H_GET_STRING_SIZE(h) ((h)->string_table_size)
#define H_GET_LINENO_SIZE(h) ((h)->lineno_size)
#ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER
#define H_GET_HEADER_SIZE(h) (sizeof(FILHDR) \
+ sizeof(AOUTHDR)\
+ (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ))
#else /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
#define H_GET_HEADER_SIZE(h) (sizeof(FILHDR) \
+ (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ))
#endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
#define H_GET_TEXT_RELOCATION_SIZE(h) (text_section_header.s_nreloc * RELSZ)
#define H_GET_DATA_RELOCATION_SIZE(h) (data_section_header.s_nreloc * RELSZ)
/* Modifiers */
/* aouthdr */
#define H_SET_MAGIC_NUMBER(h,v) ((h)->aouthdr.magic = (v))
#define H_SET_VERSION_STAMP(h,v) ((h)->aouthdr.vstamp = (v))
#define H_SET_TEXT_SIZE(h,v) ((h)->aouthdr.tsize = (v))
#define H_SET_DATA_SIZE(h,v) ((h)->aouthdr.dsize = (v))
#define H_SET_BSS_SIZE(h,v) ((h)->aouthdr.bsize = (v))
#define H_SET_ENTRY_POINT(h,v) ((h)->aouthdr.entry = (v))
#define H_SET_TEXT_START(h,v) ((h)->aouthdr.text_start = (v))
#define H_SET_DATA_START(h,v) ((h)->aouthdr.data_start = (v))
/* filehdr */
#define H_SET_FILE_MAGIC_NUMBER(h,v) ((h)->filehdr.f_magic = (v))
#define H_SET_NUMBER_OF_SECTIONS(h,v) ((h)->filehdr.f_nscns = (v))
#define H_SET_TIME_STAMP(h,v) ((h)->filehdr.f_timdat = (v))
#define H_SET_SYMBOL_TABLE_POINTER(h,v) ((h)->filehdr.f_symptr = (v))
#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->filehdr.f_nsyms = (v))
#define H_SET_SIZEOF_OPTIONAL_HEADER(h,v) ((h)->filehdr.f_opthdr = (v))
#define H_SET_FLAGS(h,v) ((h)->filehdr.f_flags = (v))
/* Extra fields to achieve bsd a.out compatibility and for convinience */
#define H_SET_RELOCATION_SIZE(h,t,d) ((h)->relocation_size = (t)+(d))
#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v))
#define H_SET_LINENO_SIZE(h,v) ((h)->lineno_size = (v))
/* Segment flipping */
#define segment_name(v) (seg_name[(int) (v)])
typedef struct {
#ifdef BFD_HEADERS
struct internal_aouthdr aouthdr; /* a.out header */
struct internal_filehdr filehdr; /* File header, not machine dep. */
#else
AOUTHDR aouthdr; /* a.out header */
FILHDR filehdr; /* File header, not machine dep. */
#endif
long string_table_size; /* names + '\0' + sizeof(int) */
long relocation_size; /* Cumulated size of relocation
information for all sections in
bytes. */
long lineno_size; /* Size of the line number information
table in bytes */
} object_headers;
/* -------------- Line number handling ------- */
extern int text_lineno_number;
/* line numbering stuff. */
typedef struct internal_lineno {
#ifdef BFD_HEADERS
struct bfd_internal_lineno line;
#else
LINENO line; /* The lineno structure itself */
#endif
char* frag; /* Frag to which the line number is related */
struct internal_lineno* next; /* Forward chain pointer */
} lineno;
extern lineno *lineno_lastP;
extern lineno *lineno_rootP;
#define OBJ_EMIT_LINENO(a, b, c) obj_emit_lineno((a),(b),(c))
#if __STDC__ == 1
void obj_emit_lineno(char **where, lineno *line, char *file_start);
#else /* not __STDC__ */
void obj_emit_lineno();
#endif /* not __STDC__ */
/* stack stuff */
typedef struct {
unsigned long chunk_size;
unsigned long element_size;
unsigned long size;
char* data;
unsigned long pointer;
} stack;
#if __STDC__ == 1
char *stack_pop(stack *st);
char *stack_push(stack *st, char *element);
char *stack_top(stack *st);
stack *stack_init(unsigned long chunk_size, unsigned long element_size);
void c_dot_file_symbol(char *filename);
void obj_extra_stuff(object_headers *headers);
void stack_delete(stack *st);
#ifndef tc_headers_hook
void tc_headers_hook(object_headers *headers);
#endif /* tc_headers_hook */
#ifndef tc_coff_symbol_emit_hook
void tc_coff_symbol_emit_hook(); /* really tc_coff_symbol_emit_hook(symbolS *symbolP) */
#endif /* tc_coff_symbol_emit_hook */
void c_section_header(
#ifdef BFD_HEADERS
struct internal_scnhdr *header,
#else
SCNHDR *header,
#endif
char *name,
long core_address,
long size,
long data_ptr,
long reloc_ptr,
long lineno_ptr,
long reloc_number,
long lineno_number,
long alignment);
#else /* not __STDC__ */
char *stack_pop();
char *stack_push();
char *stack_top();
stack *stack_init();
void c_dot_file_symbol();
void c_section_header();
void obj_extra_stuff();
void stack_delete();
void tc_headers_hook();
void tc_coff_symbol_emit_hook();
#endif /* not __STDC__ */
/* sanity check */
#ifdef TC_I960
#ifndef C_LEAFSTAT
hey! Where is the C_LEAFSTAT definition? i960-coff support is depending on it.
#endif /* no C_LEAFSTAT */
#endif /* TC_I960 */
#ifdef BFD_HEADERS
extern struct internal_scnhdr data_section_header;
extern struct internal_scnhdr text_section_header;
#else
extern SCNHDR data_section_header;
extern SCNHDR text_section_header;
#endif
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of obj-coff.h */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,516 @@
/* coff object file format
Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef OBJ_FORMAT_H
#define OBJ_FORMAT_H
#define OBJ_COFF 1
#include "targ-cpu.h"
#include "bfd.h"
/*extern bfd *stdoutput;*/
/* This internal_lineno crap is to stop namespace pollution from the
bfd internal coff headerfile. */
#define internal_lineno bfd_internal_lineno
#include "coff/internal.h"
#undef internal_lineno
#if defined(TC_H8300)
#include "coff/h8300.h"
#define TARGET_FORMAT "coff-h8300"
#elif defined(TC_A29K)
#include "coff/a29k.h"
#define TARGET_FORMAT "coff-a29k-big"
#else
help me
#endif
#if 0
/* Define some processor dependent values according to the processor we are
on. */
#if defined(TC_H8300)
#define BYTE_ORDERING 0
#define FILE_HEADER_MAGIC H8300MAGIC
#elif defined(TC_M68K)
#define BYTE_ORDERING F_AR32W /* See filehdr.h for more info. */
#ifndef FILE_HEADER_MAGIC
#define FILE_HEADER_MAGIC MC68MAGIC /* ... */
#endif /* FILE_HEADER_MAGIC */
#elif defined(TC_I386)
#define BYTE_ORDERING F_AR32WR /* See filehdr.h for more info. */
#ifndef FILE_HEADER_MAGIC
#define FILE_HEADER_MAGIC I386MAGIC /* ... */
#endif /* FILE_HEADER_MAGIC */
#elif defined(TC_I960)
#define BYTE_ORDERING F_AR32WR /* See filehdr.h for more info. */
#ifndef FILE_HEADER_MAGIC
#define FILE_HEADER_MAGIC I960ROMAGIC /* ... */
#endif /* FILE_HEADER_MAGIC */
#elif defined(TC_A29K)
#define BYTE_ORDERING F_AR32W /* big endian. */
#ifndef FILE_HEADER_MAGIC
#define FILE_HEADER_MAGIC SIPFBOMAGIC
#endif /* FILE_HEADER_MAGIC */
#else
you lose
#endif
#endif
#ifndef OBJ_COFF_MAX_AUXENTRIES
#define OBJ_COFF_MAX_AUXENTRIES 1
#endif /* OBJ_COFF_MAX_AUXENTRIES */
extern const segT N_TYPE_seg[];
/* Magic number of paged executable. */
#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE 0x8300
/* SYMBOL TABLE */
/* targets may also set this */
#ifndef SYMBOLS_NEED_BACKPOINTERS
#define SYMBOLS_NEED_BACKPOINTERS 1
#endif /* SYMBOLS_NEED_BACKPOINTERS */
/* Symbol table entry data type */
typedef struct
{
struct internal_syment ost_entry; /* Basic symbol */
union internal_auxent ost_auxent[OBJ_COFF_MAX_AUXENTRIES]; /* Auxiliary entry. */
unsigned int ost_flags; /* obj_coff internal use only flags */
} obj_symbol_type;
#ifndef DO_NOT_STRIP
#define DO_NOT_STRIP 0
#define DO_STRIP 1
#endif
/* Symbol table macros and constants */
/* Possible and usefull section number in symbol table
* The values of TEXT, DATA and BSS may not be portable.
*/
#define C_ABS_SECTION N_ABS
#define C_UNDEF_SECTION N_UNDEF
#define C_DEBUG_SECTION N_DEBUG
#define C_NTV_SECTION N_TV
#define C_PTV_SECTION P_TV
#define C_REGISTER_SECTION 20
/*
* Macros to extract information from a symbol table entry.
* This syntaxic indirection allows independence regarding a.out or coff.
* The argument (s) of all these macros is a pointer to a symbol table entry.
*/
/* Predicates */
/* True if the symbol is external */
#define S_IS_EXTERNAL(s) ((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION)
/* True if symbol has been defined, ie :
section > 0 (DATA, TEXT or BSS)
section == 0 and value > 0 (external bss symbol) */
#define S_IS_DEFINED(s) ((s)->sy_symbol.ost_entry.n_scnum > C_UNDEF_SECTION || \
((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION && \
(s)->sy_symbol.ost_entry.n_value > 0))
/* True if a debug special symbol entry */
#define S_IS_DEBUG(s) ((s)->sy_symbol.ost_entry.n_scnum == C_DEBUG_SECTION)
/* True if a symbol is local symbol name */
/* A symbol name whose name begin with ^A is a gas internal pseudo symbol */
#define S_IS_LOCAL(s) (S_GET_NAME(s)[0] == '\001' || \
(s)->sy_symbol.ost_entry.n_scnum == C_REGISTER_SECTION || \
(S_LOCAL_NAME(s) && !flagseen['L']))
/* True if a symbol is not defined in this file */
#define S_IS_EXTERN(s) ((s)->sy_symbol.ost_entry.n_scnum == 0 && (s)->sy_symbol.ost_entry.n_value == 0)
/*
* True if a symbol can be multiply defined (bss symbols have this def
* though it is bad practice)
*/
#define S_IS_COMMON(s) ((s)->sy_symbol.ost_entry.n_scnum == 0 && (s)->sy_symbol.ost_entry.n_value != 0)
/* True if a symbol name is in the string table, i.e. its length is > 8. */
#define S_IS_STRING(s) (strlen(S_GET_NAME(s)) > 8 ? 1 : 0)
/* Accessors */
/* The name of the symbol */
#define S_GET_NAME(s) ((char*)(s)->sy_symbol.ost_entry.n_offset)
/* The pointer to the string table */
#define S_GET_OFFSET(s) ((s)->sy_symbol.ost_entry.n_offset)
/* The zeroes if symbol name is longer than 8 chars */
#define S_GET_ZEROES(s) ((s)->sy_symbol.ost_entry.n_zeroes)
/* The value of the symbol */
#define S_GET_VALUE(s) ((unsigned) ((s)->sy_symbol.ost_entry.n_value))
/* The numeric value of the segment */
#define S_GET_SEGMENT(s) s_get_segment(s)
/* The data type */
#define S_GET_DATA_TYPE(s) ((s)->sy_symbol.ost_entry.n_type)
/* The storage class */
#define S_GET_STORAGE_CLASS(s) ((s)->sy_symbol.ost_entry.n_sclass)
/* The number of auxiliary entries */
#define S_GET_NUMBER_AUXILIARY(s) ((s)->sy_symbol.ost_entry.n_numaux)
/* Modifiers */
/* Set the name of the symbol */
#define S_SET_NAME(s,v) ((s)->sy_symbol.ost_entry.n_offset = (unsigned long)(v))
/* Set the offset of the symbol */
#define S_SET_OFFSET(s,v) ((s)->sy_symbol.ost_entry.n_offset = (v))
/* The zeroes if symbol name is longer than 8 chars */
#define S_SET_ZEROES(s,v) ((s)->sy_symbol.ost_entry.n_zeroes = (v))
/* Set the value of the symbol */
#define S_SET_VALUE(s,v) ((s)->sy_symbol.ost_entry.n_value = (v))
/* The numeric value of the segment */
#define S_SET_SEGMENT(s,v) ((s)->sy_symbol.ost_entry.n_scnum = SEGMENT_TO_SYMBOL_TYPE(v))
/* The data type */
#define S_SET_DATA_TYPE(s,v) ((s)->sy_symbol.ost_entry.n_type = (v))
/* The storage class */
#define S_SET_STORAGE_CLASS(s,v) ((s)->sy_symbol.ost_entry.n_sclass = (v))
/* The number of auxiliary entries */
#define S_SET_NUMBER_AUXILIARY(s,v) ((s)->sy_symbol.ost_entry.n_numaux = (v))
/* Additional modifiers */
/* The symbol is external (does not mean undefined) */
#define S_SET_EXTERNAL(s) { S_SET_STORAGE_CLASS(s, C_EXT) ; SF_CLEAR_LOCAL(s); }
/* Auxiliary entry macros. SA_ stands for symbol auxiliary */
/* Omit the tv related fields */
/* Accessors */
#ifdef BFD_HEADERS
#define SA_GET_SYM_TAGNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx.l)
#else
#define SA_GET_SYM_TAGNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx)
#endif
#define SA_GET_SYM_LNNO(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_lnno)
#define SA_GET_SYM_SIZE(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_size)
#define SA_GET_SYM_FSIZE(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_fsize)
#define SA_GET_SYM_LNNOPTR(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_lnnoptr)
#ifdef BFD_HEADERS
#define SA_GET_SYM_ENDNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx.l)
#else
#define SA_GET_SYM_ENDNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx)
#endif
#define SA_GET_SYM_DIMEN(s,i) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen[(i)])
#define SA_GET_FILE_FNAME(s) ((s)->sy_symbol.ost_auxent[0].x_file.x_fname)
#define SA_GET_SCN_SCNLEN(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_scnlen)
#define SA_GET_SCN_NRELOC(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nreloc)
#define SA_GET_SCN_NLINNO(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nlinno)
/* Modifiers */
#ifdef BFD_HEADERS
#define SA_SET_SYM_TAGNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx.l=(v))
#else
#define SA_SET_SYM_TAGNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx=(v))
#endif
#define SA_SET_SYM_LNNO(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_lnno=(v))
#define SA_SET_SYM_SIZE(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_size=(v))
#define SA_SET_SYM_FSIZE(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_fsize=(v))
#define SA_SET_SYM_LNNOPTR(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_lnnoptr=(v))
#ifdef BFD_HEADERS
#define SA_SET_SYM_ENDNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx.l=(v))
#else
#define SA_SET_SYM_ENDNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx=(v))
#endif
#define SA_SET_SYM_DIMEN(s,i,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen[(i)]=(v))
#define SA_SET_FILE_FNAME(s,v) strncpy((s)->sy_symbol.ost_auxent[0].x_file.x_fname,(v),FILNMLEN)
#define SA_SET_SCN_SCNLEN(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_scnlen=(v))
#define SA_SET_SCN_NRELOC(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nreloc=(v))
#define SA_SET_SCN_NLINNO(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nlinno=(v))
/*
* Internal use only definitions. SF_ stands for symbol flags.
*
* These values can be assigned to sy_symbol.ost_flags field of a symbolS.
*
* You'll break i960 if you shift the SYSPROC bits anywhere else. for
* more on the balname/callname hack, see tc-i960.h. b.out is done
* differently.
*/
#define SF_I960_MASK (0x000001ff) /* Bits 0-8 are used by the i960 port. */
#define SF_SYSPROC (0x0000003f) /* bits 0-5 are used to store the sysproc number */
#define SF_IS_SYSPROC (0x00000040) /* bit 6 marks symbols that are sysprocs */
#define SF_BALNAME (0x00000080) /* bit 7 marks BALNAME symbols */
#define SF_CALLNAME (0x00000100) /* bit 8 marks CALLNAME symbols */
#define SF_NORMAL_MASK (0x0000ffff) /* bits 12-15 are general purpose. */
#define SF_STATICS (0x00001000) /* Mark the .text & all symbols */
#define SF_DEFINED (0x00002000) /* Symbol is defined in this file */
#define SF_STRING (0x00004000) /* Symbol name length > 8 */
#define SF_LOCAL (0x00008000) /* Symbol must not be emitted */
#define SF_DEBUG_MASK (0xffff0000) /* bits 16-31 are debug info */
#define SF_FUNCTION (0x00010000) /* The symbol is a function */
#define SF_PROCESS (0x00020000) /* Process symbol before write */
#define SF_TAGGED (0x00040000) /* Is associated with a tag */
#define SF_TAG (0x00080000) /* Is a tag */
#define SF_DEBUG (0x00100000) /* Is in debug or abs section */
#define SF_GET_SEGMENT (0x00200000) /* Get the section of the forward symbol. */
/* All other bits are unused. */
/* Accessors */
#define SF_GET(s) ((s)->sy_symbol.ost_flags)
#define SF_GET_NORMAL_FIELD(s) ((s)->sy_symbol.ost_flags & SF_NORMAL_MASK)
#define SF_GET_DEBUG_FIELD(s) ((s)->sy_symbol.ost_flags & SF_DEBUG_MASK)
#define SF_GET_FILE(s) ((s)->sy_symbol.ost_flags & SF_FILE)
#define SF_GET_STATICS(s) ((s)->sy_symbol.ost_flags & SF_STATICS)
#define SF_GET_DEFINED(s) ((s)->sy_symbol.ost_flags & SF_DEFINED)
#define SF_GET_STRING(s) ((s)->sy_symbol.ost_flags & SF_STRING)
#define SF_GET_LOCAL(s) ((s)->sy_symbol.ost_flags & SF_LOCAL)
#define SF_GET_FUNCTION(s) ((s)->sy_symbol.ost_flags & SF_FUNCTION)
#define SF_GET_PROCESS(s) ((s)->sy_symbol.ost_flags & SF_PROCESS)
#define SF_GET_DEBUG(s) ((s)->sy_symbol.ost_flags & SF_DEBUG)
#define SF_GET_TAGGED(s) ((s)->sy_symbol.ost_flags & SF_TAGGED)
#define SF_GET_TAG(s) ((s)->sy_symbol.ost_flags & SF_TAG)
#define SF_GET_GET_SEGMENT(s) ((s)->sy_symbol.ost_flags & SF_GET_SEGMENT)
#define SF_GET_I960(s) ((s)->sy_symbol.ost_flags & SF_I960_MASK) /* used by i960 */
#define SF_GET_BALNAME(s) ((s)->sy_symbol.ost_flags & SF_BALNAME) /* used by i960 */
#define SF_GET_CALLNAME(s) ((s)->sy_symbol.ost_flags & SF_CALLNAME) /* used by i960 */
#define SF_GET_IS_SYSPROC(s) ((s)->sy_symbol.ost_flags & SF_IS_SYSPROC) /* used by i960 */
#define SF_GET_SYSPROC(s) ((s)->sy_symbol.ost_flags & SF_SYSPROC) /* used by i960 */
/* Modifiers */
#define SF_SET(s,v) ((s)->sy_symbol.ost_flags = (v))
#define SF_SET_NORMAL_FIELD(s,v)((s)->sy_symbol.ost_flags |= ((v) & SF_NORMAL_MASK))
#define SF_SET_DEBUG_FIELD(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_DEBUG_MASK))
#define SF_SET_FILE(s) ((s)->sy_symbol.ost_flags |= SF_FILE)
#define SF_SET_STATICS(s) ((s)->sy_symbol.ost_flags |= SF_STATICS)
#define SF_SET_DEFINED(s) ((s)->sy_symbol.ost_flags |= SF_DEFINED)
#define SF_SET_STRING(s) ((s)->sy_symbol.ost_flags |= SF_STRING)
#define SF_SET_LOCAL(s) ((s)->sy_symbol.ost_flags |= SF_LOCAL)
#define SF_CLEAR_LOCAL(s) ((s)->sy_symbol.ost_flags &= ~SF_LOCAL)
#define SF_SET_FUNCTION(s) ((s)->sy_symbol.ost_flags |= SF_FUNCTION)
#define SF_SET_PROCESS(s) ((s)->sy_symbol.ost_flags |= SF_PROCESS)
#define SF_SET_DEBUG(s) ((s)->sy_symbol.ost_flags |= SF_DEBUG)
#define SF_SET_TAGGED(s) ((s)->sy_symbol.ost_flags |= SF_TAGGED)
#define SF_SET_TAG(s) ((s)->sy_symbol.ost_flags |= SF_TAG)
#define SF_SET_GET_SEGMENT(s) ((s)->sy_symbol.ost_flags |= SF_GET_SEGMENT)
#define SF_SET_I960(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_I960_MASK)) /* used by i960 */
#define SF_SET_BALNAME(s) ((s)->sy_symbol.ost_flags |= SF_BALNAME) /* used by i960 */
#define SF_SET_CALLNAME(s) ((s)->sy_symbol.ost_flags |= SF_CALLNAME) /* used by i960 */
#define SF_SET_IS_SYSPROC(s) ((s)->sy_symbol.ost_flags |= SF_IS_SYSPROC) /* used by i960 */
#define SF_SET_SYSPROC(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_SYSPROC)) /* used by i960 */
/* File header macro and type definition */
/*
* File position calculators. Beware to use them when all the
* appropriate fields are set in the header.
*/
#ifdef OBJ_COFF_OMIT_OPTIONAL_HEADER
#define OBJ_COFF_AOUTHDRSZ (0)
#else
#define OBJ_COFF_AOUTHDRSZ (AOUTHDRSZ)
#endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
#define H_GET_FILE_SIZE(h) \
(long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h) + \
H_GET_SYMBOL_TABLE_SIZE(h) + \
(h)->string_table_size)
#define H_GET_TEXT_FILE_OFFSET(h) \
(long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ)
#define H_GET_DATA_FILE_OFFSET(h) \
(long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
H_GET_TEXT_SIZE(h))
#define H_GET_BSS_FILE_OFFSET(h) 0
#define H_GET_RELOCATION_FILE_OFFSET(h) \
(long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h))
#define H_GET_LINENO_FILE_OFFSET(h) \
(long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
H_GET_RELOCATION_SIZE(h))
#define H_GET_SYMBOL_TABLE_FILE_OFFSET(h) \
(long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h))
/* Accessors */
/* aouthdr */
#define H_GET_MAGIC_NUMBER(h) ((h)->aouthdr.magic)
#define H_GET_VERSION_STAMP(h) ((h)->aouthdr.vstamp)
#define H_GET_TEXT_SIZE(h) ((h)->aouthdr.tsize)
#define H_GET_DATA_SIZE(h) ((h)->aouthdr.dsize)
#define H_GET_BSS_SIZE(h) ((h)->aouthdr.bsize)
#define H_GET_ENTRY_POINT(h) ((h)->aouthdr.entry)
#define H_GET_TEXT_START(h) ((h)->aouthdr.text_start)
#define H_GET_DATA_START(h) ((h)->aouthdr.data_start)
/* filehdr */
#define H_GET_FILE_MAGIC_NUMBER(h) ((h)->filehdr.f_magic)
#define H_GET_NUMBER_OF_SECTIONS(h) ((h)->filehdr.f_nscns)
#define H_GET_TIME_STAMP(h) ((h)->filehdr.f_timdat)
#define H_GET_SYMBOL_TABLE_POINTER(h) ((h)->filehdr.f_symptr)
#define H_GET_SYMBOL_COUNT(h) ((h)->filehdr.f_nsyms)
#define H_GET_SYMBOL_TABLE_SIZE(h) (H_GET_SYMBOL_COUNT(h) * SYMESZ)
#define H_GET_SIZEOF_OPTIONAL_HEADER(h) ((h)->filehdr.f_opthdr)
#define H_GET_FLAGS(h) ((h)->filehdr.f_flags)
/* Extra fields to achieve bsd a.out compatibility and for convenience */
#define H_GET_RELOCATION_SIZE(h) ((h)->relocation_size)
#define H_GET_STRING_SIZE(h) ((h)->string_table_size)
#define H_GET_LINENO_SIZE(h) ((h)->lineno_size)
#ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER
#define H_GET_HEADER_SIZE(h) (sizeof(FILHDR) \
+ sizeof(AOUTHDR)\
+ (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ))
#else /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
#define H_GET_HEADER_SIZE(h) (sizeof(FILHDR) \
+ (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ))
#endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
#define H_GET_TEXT_RELOCATION_SIZE(h) (text_section_header.s_nreloc * RELSZ)
#define H_GET_DATA_RELOCATION_SIZE(h) (data_section_header.s_nreloc * RELSZ)
/* Modifiers */
/* aouthdr */
#define H_SET_MAGIC_NUMBER(h,v) ((h)->aouthdr.magic = (v))
#define H_SET_VERSION_STAMP(h,v) ((h)->aouthdr.vstamp = (v))
#define H_SET_TEXT_SIZE(h,v) ((h)->aouthdr.tsize = (v))
#define H_SET_DATA_SIZE(h,v) ((h)->aouthdr.dsize = (v))
#define H_SET_BSS_SIZE(h,v) ((h)->aouthdr.bsize = (v))
#define H_SET_ENTRY_POINT(h,v) ((h)->aouthdr.entry = (v))
#define H_SET_TEXT_START(h,v) ((h)->aouthdr.text_start = (v))
#define H_SET_DATA_START(h,v) ((h)->aouthdr.data_start = (v))
/* filehdr */
#define H_SET_FILE_MAGIC_NUMBER(h,v) ((h)->filehdr.f_magic = (v))
#define H_SET_NUMBER_OF_SECTIONS(h,v) ((h)->filehdr.f_nscns = (v))
#define H_SET_TIME_STAMP(h,v) ((h)->filehdr.f_timdat = (v))
#define H_SET_SYMBOL_TABLE_POINTER(h,v) ((h)->filehdr.f_symptr = (v))
#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->filehdr.f_nsyms = (v))
#define H_SET_SIZEOF_OPTIONAL_HEADER(h,v) ((h)->filehdr.f_opthdr = (v))
#define H_SET_FLAGS(h,v) ((h)->filehdr.f_flags = (v))
/* Extra fields to achieve bsd a.out compatibility and for convinience */
#define H_SET_RELOCATION_SIZE(h,t,d) ((h)->relocation_size = (t)+(d))
#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v))
#define H_SET_LINENO_SIZE(h,v) ((h)->lineno_size = (v))
/* Segment flipping */
#define segment_name(v) (seg_name[(int) (v)])
typedef struct {
#ifdef BFD_HEADERS
struct internal_aouthdr aouthdr; /* a.out header */
struct internal_filehdr filehdr; /* File header, not machine dep. */
#else
AOUTHDR aouthdr; /* a.out header */
FILHDR filehdr; /* File header, not machine dep. */
#endif
long string_table_size; /* names + '\0' + sizeof(int) */
long relocation_size; /* Cumulated size of relocation
information for all sections in
bytes. */
long lineno_size; /* Size of the line number information
table in bytes */
} object_headers;
struct lineno_list
{
struct bfd_internal_lineno line;
char* frag; /* Frag to which the line number is related */
struct lineno_list* next; /* Forward chain pointer */
} ;
/* stack stuff */
typedef struct {
unsigned long chunk_size;
unsigned long element_size;
unsigned long size;
char* data;
unsigned long pointer;
} stack;
char *EXFUN(stack_pop,(stack *st));
char *EXFUN(stack_push,(stack *st, char *element));
char *EXFUN(stack_top,(stack *st));
stack *EXFUN(stack_init,(unsigned long chunk_size, unsigned long element_size));
void EXFUN(c_dot_file_symbol,(char *filename));
void EXFUN(obj_extra_stuff,(object_headers *headers));
void EXFUN(stack_delete,(stack *st));
void EXFUN(c_section_header,(
struct internal_scnhdr *header,
char *name,
long core_address,
long size,
long data_ptr,
long reloc_ptr,
long lineno_ptr,
long reloc_number,
long lineno_number,
long alignment));
/* sanity check */
#ifdef TC_I960
#ifndef C_LEAFSTAT
hey! Where is the C_LEAFSTAT definition? i960-coff support is depending on it.
#endif /* no C_LEAFSTAT */
#endif /* TC_I960 */
#ifdef BFD_HEADERS
extern struct internal_scnhdr data_section_header;
extern struct internal_scnhdr text_section_header;
#else
extern SCNHDR data_section_header;
extern SCNHDR text_section_header;
#endif
#endif
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of obj-coffbfd.h */

View File

@ -0,0 +1,41 @@
/* This file is obj-generic.c and is intended to be a template for
object format specific source files.
Copyright (C) 1987-1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Chars that can be used to separate mant from exp in floating point nums */
char EXP_CHARS[] = "eE";
/* Chars that mean this number is a floating point constant */
/* As in 0f12.456 */
/* or 0d1.2345e12 */
char FLT_CHARS[] = "rRsSfFdDxXpP";
/* These chars start a comment anywhere in a source file (except inside
another comment */
const char comment_chars[] = "#";
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of obj-generic.c */

View File

@ -0,0 +1,78 @@
/* This file is obj-generic.h
Copyright (C) 1987-1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* This file is obj-generic.h and is intended to be a template for
* object format specific header files.
*/
/* define an obj specific macro off which target cpu back ends may key. */
#define OBJ_GENERIC 1
/* include whatever target cpu is appropriate. */
#include "targ-cpu.h"
/*
* SYMBOLS
*/
/*
* If your object format needs to reorder symbols, define this. When
* defined, symbols are kept on a doubly linked list and functions are
* made available for push, insert, append, and delete. If not defined,
* symbols are kept on a singly linked list, only the append and clear
* facilities are available, and they are macros.
*/
/* #define SYMBOLS_NEED_PACKPOINTERS */
/* */
typedef struct {
void *nothing;
} obj_symbol_type; /* should be the format's symbol structure */
typedef void *object_headers;
/* symbols have names */
#define S_GET_NAME(s) ("foo") /* get the name of a symbolP */
#define S_SET_NAME(s,v) ;
/* symbols have segments */
#define S_GET_SEGMENT(s) (SEG_UNKNOWN)
#define S_SET_SEGMENT(s,v) ;
/* symbols have a value */
#define S_GET_VALUE(s) (0)
#define S_SET_VALUE(s,v) ;
/* symbols may be external */
#define S_IS_EXTERNAL(s) (0)
#define S_SET_EXTERNAL(s) ;
/* symbols may or may not be defined */
#define S_IS_DEFINED(s) (0)
#define OBJ_EMIT_LINENO(a,b,c) /* must be *something*. This no-op's it out. */
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of obj-generic.h */

View File

@ -0,0 +1,539 @@
/* obj-format for ieee-695 records.
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
created by
steve chamberlain steve@cygnus.com
*/
/*
this will hopefully become the port through which bfd and gas talk,
for the moment, only ieee is known to work well.
*/
#include "bfd.h"
#include "as.h"
#include "subsegs.h"
#include "output-file.h"
#include "frags.h"
bfd *abfd;
/* How many addresses does the .align take? */
static relax_addressT relax_align(address, alignment)
register relax_addressT address; /* Address now. */
register long alignment; /* Alignment (binary). */
{
relax_addressT mask;
relax_addressT new_address;
mask = ~ ( (~0) << alignment );
new_address = (address + mask) & (~ mask);
return (new_address - address);
} /* relax_align() */
/* calculate the size of the frag chain and create a bfd section
to contain all of it */
static void DEFUN(size_section,(abfd, idx),
bfd *abfd AND
unsigned int idx)
{
asection *sec;
unsigned int size = 0;
fragS *frag = segment_info[idx].frag_root;
while (frag) {
if (frag->fr_address != size) {
printf("Out of step\n");
size = frag->fr_address;
}
size += frag->fr_fix;
switch (frag->fr_type) {
case rs_fill:
case rs_org:
size += frag->fr_offset * frag->fr_var;
break;
case rs_align:
size += relax_align(size, frag->fr_offset);
}
frag = frag->fr_next;
}
if (size) {
char *name = segment_info[idx].name;
if (name == (char *)NULL) {
name = ".data";
}
segment_info[idx].user_stuff = (char *)(sec = bfd_make_section(abfd, name));
/* Make it output through itself */
sec->output_section = sec;
sec->flags |= SEC_HAS_CONTENTS;
bfd_set_section_size(abfd, sec, size);
}
}
/* run through a frag chain and write out the data to go with it */
static void DEFUN(fill_section,(abfd, idx),
bfd *abfd AND
unsigned int idx)
{
asection *sec = segment_info[idx].user_stuff;
if (sec) {
fragS *frag = segment_info[idx].frag_root;
unsigned int offset = 0;
while (frag) {
unsigned int fill_size;
unsigned int count;
switch (frag->fr_type) {
case rs_fill:
case rs_align:
case rs_org:
if (frag->fr_fix)
{
bfd_set_section_contents(abfd,
sec,
frag->fr_literal,
frag->fr_address,
frag->fr_fix);
}
offset += frag->fr_fix;
fill_size = frag->fr_var;
if (fill_size)
{
unsigned int off = frag->fr_fix;
for (count = frag->fr_offset; count; count--)
{
bfd_set_section_contents(abfd, sec,
frag->fr_literal +
frag->fr_fix,
frag->fr_address + off,
fill_size);
off += fill_size;
}
}
break;
default:
abort();
}
frag = frag->fr_next;
}
}
}
/* Count the relocations in a chain */
static unsigned int DEFUN(count_entries_in_chain,(idx),
unsigned int idx)
{
unsigned int nrelocs;
fixS *fixup_ptr;
/* Count the relocations */
fixup_ptr = segment_info[idx].fix_root;
nrelocs = 0;
while (fixup_ptr != (fixS *)NULL)
{
fixup_ptr = fixup_ptr->fx_next;
nrelocs ++ ;
}
return nrelocs;
}
/* output all the relocations for a section */
void DEFUN(do_relocs_for,(idx),
unsigned int idx)
{
unsigned int nrelocs;
arelent **reloc_ptr_vector;
arelent *reloc_vector;
asymbol **ptrs;
asection *section = (asection *)(segment_info[idx].user_stuff);
unsigned int i;
fixS *from;
if (section) {
nrelocs = count_entries_in_chain(idx);
reloc_ptr_vector = (arelent**)malloc((nrelocs+1) * sizeof(arelent *));
reloc_vector = (arelent*)malloc(nrelocs * sizeof(arelent));
ptrs = (asymbol **)malloc(nrelocs * sizeof(asymbol *));
from = segment_info[idx].fix_root;
for (i = 0; i < nrelocs; i++)
{
arelent *to = reloc_vector + i;
asymbol *s ;
reloc_ptr_vector[i] = to;
to->howto = (reloc_howto_type *)(from->fx_r_type);
/* We can't represent complicated things in a reloc yet */
/* if (from->fx_addsy == 0 ||
from->fx_subsy != 0) abort();
*/
s = &( from->fx_addsy->sy_symbol.sy);
to->address = ((char *)( from->fx_frag->fr_address +
from->fx_where))
- ((char *)(&(from->fx_frag->fr_literal)));
to->addend = from->fx_offset ;
/* If we know the symbol which we want to relocate to, turn this
reloaction into a section relative.
If this relocation is pcrelative, and we know the
destination, we still want to keep the relocation - since
the linker might relax some of the bytes, but it stops
being pc relative and turns into an absolute relocation.
*/
if (s) {
if ((s->flags & BSF_UNDEFINED) == 0) {
to->section = s->section;
to->addend += s->value ;
to->sym_ptr_ptr = 0;
if (to->howto->pcrel_offset) {
/* This is a pcrel relocation, the addend should be adjusted */
to->addend -= to->address +1;
}
}
else {
to->section = 0;
*ptrs = &(from->fx_addsy->sy_symbol.sy);
to->sym_ptr_ptr = ptrs;
if (to->howto->pcrel_offset) {
/* This is a pcrel relocation, the addend should be adjusted */
to->addend -= to->address -1;
}
}
}
else {
to->section = 0;
}
ptrs++;
from = from->fx_next;
}
/* attatch to the section */
section->orelocation = reloc_ptr_vector;
section->reloc_count = nrelocs;
section->flags |= SEC_LOAD;
}
}
/* do the symbols.. */
static void DEFUN(do_symbols, (abfd),
bfd *abfd)
{
extern symbolS *symbol_rootP;
symbolS *ptr;
asymbol **symbol_ptr_vec;
asymbol *symbol_vec;
unsigned int count = 0;
unsigned int index;
for (ptr = symbol_rootP;
ptr != (symbolS *)NULL;
ptr = ptr->sy_next)
{
if (SEG_NORMAL(ptr->sy_symbol.seg))
{
ptr->sy_symbol.sy.section =
(asection *)(segment_info[ptr->sy_symbol.seg].user_stuff);
ptr->sy_symbol.sy.value += ptr->sy_frag->fr_address;
if (ptr->sy_symbol.sy.flags == 0) {
ptr->sy_symbol.sy.flags = BSF_LOCAL ;
}
}
else {
switch (ptr->sy_symbol.seg) {
case SEG_ABSOLUTE:
ptr->sy_symbol.sy.flags |= BSF_ABSOLUTE;
ptr->sy_symbol.sy.section = 0;
break;
case SEG_UNKNOWN:
ptr->sy_symbol.sy.flags = BSF_UNDEFINED ;
ptr->sy_symbol.sy.section = 0;
break;
default:
abort();
}
}
count++;
}
symbol_ptr_vec = (asymbol **)malloc((count+1) * sizeof(asymbol *));
index = 0;
for (ptr = symbol_rootP;
ptr != (symbolS *)NULL;
ptr = ptr->sy_next)
{
symbol_ptr_vec[index] = &(ptr->sy_symbol.sy);
index++;
}
symbol_ptr_vec[index] =0;
abfd->outsymbols = symbol_ptr_vec;
abfd->symcount = count;
}
/* The generic as->bfd converter. Other backends may have special case
code */
void DEFUN_VOID(bfd_as_write_hook)
{
int i;
for (i = SEG_E0; i < SEG_UNKNOWN; i++) {
size_section(abfd, i);
}
for (i = SEG_E0; i < SEG_UNKNOWN; i++)
fill_section(abfd,i);
do_symbols(abfd);
for (i = SEG_E0; i < SEG_UNKNOWN; i++)
do_relocs_for(i);
}
S_GET_VALUE(x)
symbolS *x;
{
return x->sy_symbol.sy.value;
}
S_SET_SEGMENT(x,y)
symbolS *x ;
int y;
{
x->sy_symbol.seg = y;
}
S_IS_DEFINED(x)
symbolS *x;
{
if (SEG_NORMAL(x->sy_symbol.seg))
{
return 1;
}
switch (x->sy_symbol.seg)
{
case SEG_UNKNOWN:
return 0;
default:
abort();
}
}
S_IS_EXTERNAL(x) { abort(); }
S_GET_DESC(x) { abort() ; }
S_GET_SEGMENT(x)
symbolS *x;
{ return x->sy_symbol.seg; }
S_SET_EXTERNAL(x)
symbolS *x;
{
x->sy_symbol.sy.flags |= BSF_GLOBAL | BSF_EXPORT;
}
S_SET_NAME(x,y)
symbolS*x;
char *y; {
x->sy_symbol.sy.name = y; }
S_SET_VALUE(s,v)
symbolS *s;
long v;
{
s->sy_symbol.sy.value = v;
}
S_GET_OTHER(x) { abort() ;}
S_IS_DEBUG(x) { abort(); }
char *segment_name() { abort(); }
void obj_read_begin_hook() { }
static void obj_ieee_section(ignore)
int ignore;
{
extern char *input_line_pointer;
extern char is_end_of_line[];
char *p= input_line_pointer;
char *s = p;
int i;
/* Look up the name, if it doesn't exist, make it */
while (*p &&* p != ' ' && *p != ',' && !is_end_of_line[*p]) {
p++;
}
for (i = SEG_E0; i < SEG_UNKNOWN; i++) {
if (segment_info[i].hadone){
if (strncmp(segment_info[i].name, s, p-s) == 0) {
goto ok;
}
}
else break;
}
if (i == SEG_UNKNOWN) {
as_bad("too many sections");
return;
}
segment_info[i].hadone = 1;
segment_info[i].name = malloc(p-s + 1);
memcpy(segment_info[i].name, s, p-s);
segment_info[i].name[p-s] = 0;
ok:
subseg_new(i,0);
while (!is_end_of_line[*p])
p++;
input_line_pointer = p;
}
void cons();
void s_ignore();
/*
* stringer()
*
* We read 0 or more ',' seperated, double-quoted strings.
*
* Caller should have checked need_pass_2 is FALSE because we don't check it.
*/
void stringer();
void s_globl();
const pseudo_typeS obj_pseudo_table[] =
{
{"section", obj_ieee_section, 0},
{"data.b", cons, 1},
{"data.w", cons, 2},
{"data.l", cons, 4},
{"export", s_globl, 0},
{"option", s_ignore, 0},
{"end", s_ignore, 0},
{"import", s_ignore, 0},
{"sdata", stringer, 0},
0,
};
void obj_symbol_new_hook(symbolP)
symbolS *symbolP;
{
symbolP->sy_symbol.sy.the_bfd = abfd;
}
#if 1
extern void DEFUN_VOID(write_object_file)
{
int i;
struct frchain *frchain_ptr;
struct frag *frag_ptr;
abfd = bfd_openw(out_file_name, "ieee");
if (abfd == 0) {
as_perror ("FATAL: Can't create %s", out_file_name);
exit(42);
}
bfd_set_format(abfd, bfd_object);
bfd_set_arch_mach(abfd, bfd_arch_h8300, 0);
subseg_new(1,0);
subseg_new(2,0);
subseg_new(3,0);
for (frchain_ptr = frchain_root;
frchain_ptr != (struct frchain *)NULL;
frchain_ptr = frchain_ptr->frch_next) {
/* Run through all the sub-segments and align them up. Also close any
open frags. We tack a .fill onto the end of the frag chain so
that any .align's size can be worked by looking at the next
frag */
subseg_new(frchain_ptr->frch_seg, frchain_ptr->frch_subseg);
#define SUB_SEGMENT_ALIGN 2
frag_align(SUB_SEGMENT_ALIGN,0);
frag_wane(frag_now);
frag_now->fr_fix = 0;
know( frag_now->fr_next == NULL );
}
/* Now build one big frag chain for each segment, linked through
fr_next. */
for (i = SEG_E0; i < SEG_UNKNOWN; i++)
{
fragS ** prev_frag_ptr_ptr ;
struct frchain *next_frchain_ptr;
/* struct frag **head_ptr = segment_info[i].frag_root;*/
segment_info[i].frag_root = segment_info[i].frchainP->frch_root;
#if 0
/* Im not sure what this is for */
for (frchain_ptr = segment_info[i].frchainP->frch_root;
frchain_ptr != (struct frchain *)NULL;
frchain_ptr = frchain_ptr->frch_next)
{
*head_ptr = frchain_ptr;
head_ptr = &frchain_ptr->next;
}
#endif
}
for (i = SEG_E0; i < SEG_UNKNOWN; i++) {
relax_segment(segment_info[i].frag_root, i);
}
/* Now the addresses of the frags are correct within the segment */
bfd_as_write_hook();
bfd_close(abfd);
}
#endif
H_SET_TEXT_SIZE(a,b) { abort(); }
H_GET_TEXT_SIZE() { abort(); }
H_SET_BSS_SIZE() { abort(); }
H_SET_STRING_SIZE() { abort(); }
H_SET_RELOCATION_SIZE() { abort(); }
H_SET_MAGIC_NUMBER() { abort(); }
H_GET_FILE_SIZE() { abort(); }
H_GET_TEXT_RELOCATION_SIZE() { abort(); }
/* end of obj-ieee.c */

View File

@ -0,0 +1,46 @@
/* This file is obj-ieee.h
Copyright (C) 1987-1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define BFD 1
#include <bfd.h>
typedef struct
{
asymbol sy;
int seg;
} obj_symbol_type;
#define S_GET_NAME(s) (((s)->sy_symbol.sy.name))
typedef struct {
int x;
}
object_headers;
#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE 1
int lineno_rootP;
#define IEEE_STYLE
/* end of obj-ieee.h */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,474 @@
/* VMS object file format
Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2,
or (at your option) any later version.
GAS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with GAS; see the file COPYING. If not, write
to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Tag to validate a.out object file format processing */
#define OBJ_VMS 1
#include "targ-cpu.h"
/* This flag is used to remember whether we are in the const or the
data section. By and large they are identical, but we set a no-write
bit for psects in the const section. */
extern char const_flag;
/* These are defined in obj-vms.c. */
extern const short seg_N_TYPE[];
extern const segT N_TYPE_seg[];
enum reloc_type {
NO_RELOC, RELOC_32
};
#define N_BADMAG(x) (0)
#define N_TXTOFF(x) ( sizeof(struct exec) )
#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
#define N_TROFF(x) ( N_DATOFF(x) + (x).a_data )
#define N_DROFF(x) ( N_TROFF(x) + (x).a_trsize )
#define N_SYMOFF(x) ( N_DROFF(x) + (x).a_drsize )
#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
/* We use this copy of the exec header for VMS. We do not actually use it, but
what we actually do is let gas fill in the relevant slots, and when we get
around to writing an obj file, we just pick out what we need. */
struct exec
{
unsigned long a_text; /* length of text, in bytes */
unsigned long a_data; /* length of data, in bytes */
unsigned long a_bss; /* length of uninitialized data area for file, in bytes */
unsigned long a_trsize; /* length of relocation info for text, in bytes */
unsigned long a_drsize; /* length of relocation info for data, in bytes */
unsigned long a_entry; /* start address */
unsigned long a_syms; /* length of symbol table data in file, in bytes */
};
typedef struct {
struct exec header; /* a.out header */
long string_table_size; /* names + '\0' + sizeof(int) */
} object_headers;
/* A single entry in the symbol table
*/
struct nlist {
union {
char *n_name;
struct nlist *n_next;
long n_strx; /* Index into string table */
} n_un;
unsigned char n_type; /* See below */
char n_other; /* Used in i80960 support -- see below */
short n_desc;
unsigned long n_value;
};
/* Legal values of n_type
*/
#define N_UNDF 0 /* Undefined symbol */
#define N_ABS 2 /* Absolute symbol */
#define N_TEXT 4 /* Text symbol */
#define N_DATA 6 /* Data symbol */
#define N_BSS 8 /* BSS symbol */
#define N_FN 31 /* Filename symbol */
#define N_EXT 1 /* External symbol (OR'd in with one of above) */
#define N_TYPE 036 /* Mask for all the type bits */
#define N_STAB 0340 /* Mask for all bits used for SDB entries */
#define N_GSYM 0x20 /* global symbol: name,,0,type,0 */
#define N_FNAME 0x22 /* procedure name (f77 kludge): name,,0 */
#define N_FUN 0x24 /* procedure: name,,0,linenumber,address */
#define N_STSYM 0x26 /* static symbol: name,,0,type,address */
#define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,address */
#define N_RSYM 0x40 /* register sym: name,,0,type,register */
#define N_SLINE 0x44 /* src line: 0,,0,linenumber,address */
#define N_CATCH 0x54 /* */
#define N_SSYM 0x60 /* structure elt: name,,0,type,struct_offset */
#define N_SO 0x64 /* source file name: name,,0,0,address */
#define N_LSYM 0x80 /* local sym: name,,0,type,offset */
#define N_SOL 0x84 /* #included file name: name,,0,0,address */
#define N_PSYM 0xa0 /* parameter: name,,0,type,offset */
#define N_ENTRY 0xa4 /* alternate entry: name,linenumber,address */
#define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,address */
#define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,address */
#define N_BCOMM 0xe2 /* begin common: name,, */
#define N_ECOMM 0xe4 /* end common: name,, */
#define N_ECOML 0xe8 /* end common (local name): ,,address */
#define N_LENG 0xfe /* second stab entry with length information */
/* SYMBOL TABLE */
/* Symbol table entry data type */
typedef struct nlist obj_symbol_type; /* Symbol table entry */
/* Symbol table macros and constants */
/*
* Macros to extract information from a symbol table entry.
* This syntaxic indirection allows independence regarding a.out or coff.
* The argument (s) of all these macros is a pointer to a symbol table entry.
*/
/* True if the symbol is external */
#define S_IS_EXTERNAL(s) ((s)->sy_symbol.n_type & N_EXT)
/* True if symbol has been defined, ie is in N_{TEXT,DATA,BSS,ABS} or N_EXT */
#define S_IS_DEFINED(s) (S_GET_TYPE(s) != N_UNDF)
#define S_IS_REGISTER(s) ((s)->sy_symbol.n_type == N_REGISTER)
/* True if a debug special symbol entry */
#define S_IS_DEBUG(s) ((s)->sy_symbol.n_type & N_STAB)
/* True if a symbol is local symbol name */
/* A symbol name whose name begin with ^A is a gas internal pseudo symbol
nameless symbols come from .stab directives. */
#define S_IS_LOCAL(s) (S_GET_NAME(s) && \
!S_IS_DEBUG(s) && \
(S_GET_NAME(s)[0] == '\001' || \
(S_LOCAL_NAME(s) && !flagseen['L'])))
/* True if a symbol is not defined in this file */
#define S_IS_EXTERN(s) ((s)->sy_symbol.n_type & N_EXT)
/* True if the symbol has been generated because of a .stabd directive */
#define S_IS_STABD(s) (S_GET_NAME(s) == (char *)0)
/* Accessors */
/* The value of the symbol */
#define S_GET_VALUE(s) (((s)->sy_symbol.n_value))
/* The name of the symbol */
#define S_GET_NAME(s) ((s)->sy_symbol.n_un.n_name)
/* The pointer to the string table */
#define S_GET_OFFSET(s) ((s)->sy_symbol.n_un.n_strx)
/* The raw type of the symbol */
#define S_GET_RAW_TYPE(s) ((s)->sy_symbol.n_type)
/* The type of the symbol */
#define S_GET_TYPE(s) ((s)->sy_symbol.n_type & N_TYPE)
/* The numeric value of the segment */
#define S_GET_SEGMENT(s) (N_TYPE_seg[S_GET_TYPE(s)])
/* The n_other expression value */
#define S_GET_OTHER(s) ((s)->sy_symbol.n_other)
/* The n_desc expression value */
#define S_GET_DESC(s) ((s)->sy_symbol.n_desc)
/* Modifiers */
/* Set the value of the symbol */
#define S_SET_VALUE(s,v) ((s)->sy_symbol.n_value = (unsigned long) (v))
/* Assume that a symbol cannot be simultaneously in more than on segment */
/* set segment */
#define S_SET_SEGMENT(s,seg) ((s)->sy_symbol.n_type &= ~N_TYPE,(s)->sy_symbol.n_type|=SEGMENT_TO_SYMBOL_TYPE(seg))
/* The symbol is external */
#define S_SET_EXTERNAL(s) ((s)->sy_symbol.n_type |= N_EXT)
/* The symbol is not external */
#define S_CLEAR_EXTERNAL(s) ((s)->sy_symbol.n_type &= ~N_EXT)
/* Set the name of the symbol */
#define S_SET_NAME(s,v) ((s)->sy_symbol.n_un.n_name = (v))
/* Set the offset in the string table */
#define S_SET_OFFSET(s,v) ((s)->sy_symbol.n_un.n_strx = (v))
/* Set the n_other expression value */
#define S_SET_OTHER(s,v) ((s)->sy_symbol.n_other = (v))
/* Set the n_desc expression value */
#define S_SET_DESC(s,v) ((s)->sy_symbol.n_desc = (v))
/* File header macro and type definition */
#define H_GET_TEXT_SIZE(h) ((h)->header.a_text)
#define H_GET_DATA_SIZE(h) ((h)->header.a_data)
#define H_GET_BSS_SIZE(h) ((h)->header.a_bss)
#define H_SET_TEXT_SIZE(h,v) ((h)->header.a_text = md_section_align(SEG_TEXT, (v)))
#define H_SET_DATA_SIZE(h,v) ((h)->header.a_data = md_section_align(SEG_DATA, (v)))
#define H_SET_BSS_SIZE(h,v) ((h)->header.a_bss = md_section_align(SEG_BSS, (v)))
#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v))
#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * \
sizeof(struct nlist))
/*
* Current means for getting the name of a segment.
* This will change for infinite-segments support (e.g. COFF).
*/
#define segment_name(seg) ( seg_name[(int)(seg)] )
extern char *const seg_name[];
/* line numbering stuff. */
#define OBJ_EMIT_LINENO(a, b, c) {;}
#define obj_symbol_new_hook(s) {;}
#ifdef __STDC__
struct fix;
void tc_aout_fix_to_chars(char *where, struct fix *fixP, relax_addressT segment_address);
#else
void tc_aout_fix_to_chars();
#endif /* __STDC__ */
/* The rest of this file contains definitions for constants used within the actual
VMS object file. We do not use a $ in the symbols (as per usual VMS
convention) since System V gags on it. */
#define OBJ_S_C_HDR 0
#define OBJ_S_C_HDR_MHD 0
#define OBJ_S_C_HDR_LNM 1
#define OBJ_S_C_HDR_SRC 2
#define OBJ_S_C_HDR_TTL 3
#define OBJ_S_C_HDR_CPR 4
#define OBJ_S_C_HDR_MTC 5
#define OBJ_S_C_HDR_GTX 6
#define OBJ_S_C_GSD 1
#define OBJ_S_C_GSD_PSC 0
#define OBJ_S_C_GSD_SYM 1
#define OBJ_S_C_GSD_EPM 2
#define OBJ_S_C_GSD_PRO 3
#define OBJ_S_C_GSD_SYMW 4
#define OBJ_S_C_GSD_EPMW 5
#define OBJ_S_C_GSD_PROW 6
#define OBJ_S_C_GSD_IDC 7
#define OBJ_S_C_GSD_ENV 8
#define OBJ_S_C_GSD_LSY 9
#define OBJ_S_C_GSD_LEPM 10
#define OBJ_S_C_GSD_LPRO 11
#define OBJ_S_C_GSD_SPSC 12
#define OBJ_S_C_TIR 2
#define OBJ_S_C_EOM 3
#define OBJ_S_C_DBG 4
#define OBJ_S_C_TBT 5
#define OBJ_S_C_LNK 6
#define OBJ_S_C_EOMW 7
#define OBJ_S_C_MAXRECTYP 7
#define OBJ_S_K_SUBTYP 1
#define OBJ_S_C_SUBTYP 1
#define OBJ_S_C_MAXRECSIZ 2048
#define OBJ_S_C_STRLVL 0
#define OBJ_S_C_SYMSIZ 31
#define OBJ_S_C_STOREPLIM -1
#define OBJ_S_C_PSCALILIM 9
#define MHD_S_C_MHD 0
#define MHD_S_C_LNM 1
#define MHD_S_C_SRC 2
#define MHD_S_C_TTL 3
#define MHD_S_C_CPR 4
#define MHD_S_C_MTC 5
#define MHD_S_C_GTX 6
#define MHD_S_C_MAXHDRTYP 6
#define GSD_S_K_ENTRIES 1
#define GSD_S_C_ENTRIES 1
#define GSD_S_C_PSC 0
#define GSD_S_C_SYM 1
#define GSD_S_C_EPM 2
#define GSD_S_C_PRO 3
#define GSD_S_C_SYMW 4
#define GSD_S_C_EPMW 5
#define GSD_S_C_PROW 6
#define GSD_S_C_IDC 7
#define GSD_S_C_ENV 8
#define GSD_S_C_LSY 9
#define GSD_S_C_LEPM 10
#define GSD_S_C_LPRO 11
#define GSD_S_C_SPSC 12
#define GSD_S_C_SYMV 13
#define GSD_S_C_EPMV 14
#define GSD_S_C_PROV 15
#define GSD_S_C_MAXRECTYP 15
#define GSY_S_M_WEAK 1
#define GSY_S_M_DEF 2
#define GSY_S_M_UNI 4
#define GSY_S_M_REL 8
#define GPS_S_M_PIC 1
#define GPS_S_M_LIB 2
#define GPS_S_M_OVR 4
#define GPS_S_M_REL 8
#define GPS_S_M_GBL 16
#define GPS_S_M_SHR 32
#define GPS_S_M_EXE 64
#define GPS_S_M_RD 128
#define GPS_S_M_WRT 256
#define GPS_S_M_VEC 512
#define GPS_S_K_NAME 9
#define GPS_S_C_NAME 9
#define TIR_S_C_STA_GBL 0
#define TIR_S_C_STA_SB 1
#define TIR_S_C_STA_SW 2
#define TIR_S_C_STA_LW 3
#define TIR_S_C_STA_PB 4
#define TIR_S_C_STA_PW 5
#define TIR_S_C_STA_PL 6
#define TIR_S_C_STA_UB 7
#define TIR_S_C_STA_UW 8
#define TIR_S_C_STA_BFI 9
#define TIR_S_C_STA_WFI 10
#define TIR_S_C_STA_LFI 11
#define TIR_S_C_STA_EPM 12
#define TIR_S_C_STA_CKARG 13
#define TIR_S_C_STA_WPB 14
#define TIR_S_C_STA_WPW 15
#define TIR_S_C_STA_WPL 16
#define TIR_S_C_STA_LSY 17
#define TIR_S_C_STA_LIT 18
#define TIR_S_C_STA_LEPM 19
#define TIR_S_C_MAXSTACOD 19
#define TIR_S_C_MINSTOCOD 20
#define TIR_S_C_STO_SB 20
#define TIR_S_C_STO_SW 21
#define TIR_S_C_STO_L 22
#define TIR_S_C_STO_BD 23
#define TIR_S_C_STO_WD 24
#define TIR_S_C_STO_LD 25
#define TIR_S_C_STO_LI 26
#define TIR_S_C_STO_PIDR 27
#define TIR_S_C_STO_PICR 28
#define TIR_S_C_STO_RSB 29
#define TIR_S_C_STO_RSW 30
#define TIR_S_C_STO_RL 31
#define TIR_S_C_STO_VPS 32
#define TIR_S_C_STO_USB 33
#define TIR_S_C_STO_USW 34
#define TIR_S_C_STO_RUB 35
#define TIR_S_C_STO_RUW 36
#define TIR_S_C_STO_B 37
#define TIR_S_C_STO_W 38
#define TIR_S_C_STO_RB 39
#define TIR_S_C_STO_RW 40
#define TIR_S_C_STO_RIVB 41
#define TIR_S_C_STO_PIRR 42
#define TIR_S_C_MAXSTOCOD 42
#define TIR_S_C_MINOPRCOD 50
#define TIR_S_C_OPR_NOP 50
#define TIR_S_C_OPR_ADD 51
#define TIR_S_C_OPR_SUB 52
#define TIR_S_C_OPR_MUL 53
#define TIR_S_C_OPR_DIV 54
#define TIR_S_C_OPR_AND 55
#define TIR_S_C_OPR_IOR 56
#define TIR_S_C_OPR_EOR 57
#define TIR_S_C_OPR_NEG 58
#define TIR_S_C_OPR_COM 59
#define TIR_S_C_OPR_INSV 60
#define TIR_S_C_OPR_ASH 61
#define TIR_S_C_OPR_USH 62
#define TIR_S_C_OPR_ROT 63
#define TIR_S_C_OPR_SEL 64
#define TIR_S_C_OPR_REDEF 65
#define TIR_S_C_OPR_DFLIT 66
#define TIR_S_C_MAXOPRCOD 66
#define TIR_S_C_MINCTLCOD 80
#define TIR_S_C_CTL_SETRB 80
#define TIR_S_C_CTL_AUGRB 81
#define TIR_S_C_CTL_DFLOC 82
#define TIR_S_C_CTL_STLOC 83
#define TIR_S_C_CTL_STKDL 84
#define TIR_S_C_MAXCTLCOD 84
/*
* Debugger symbol definitions: These are done by hand, as no
* machine-readable version seems
* to be available.
*/
#define DST_S_C_C 7 /* Language == "C" */
#define DST_S_C_VERSION 153
#define DST_S_C_SOURCE 155 /* Source file */
#define DST_S_C_PROLOG 162
#define DST_S_C_BLKBEG 176 /* Beginning of block */
#define DST_S_C_BLKEND 177 /* End of block */
#define DST_S_C_ENTRY 181
#define DST_S_C_PSECT 184
#define DST_S_C_LINE_NUM 185 /* Line Number */
#define DST_S_C_LBLORLIT 186
#define DST_S_C_LABEL 187
#define DST_S_C_MODBEG 188 /* Beginning of module */
#define DST_S_C_MODEND 189 /* End of module */
#define DST_S_C_RTNBEG 190 /* Beginning of routine */
#define DST_S_C_RTNEND 191 /* End of routine */
#define DST_S_C_DELTA_PC_W 1 /* Incr PC */
#define DST_S_C_INCR_LINUM 2 /* Incr Line # */
#define DST_S_C_INCR_LINUM_W 3 /* Incr Line # */
#define DST_S_C_SET_LINUM_INCR 4
#define DST_S_C_SET_LINUM_INCR_W 5
#define DST_S_C_RESET_LINUM_INCR 6
#define DST_S_C_BEG_STMT_MODE 7
#define DST_S_C_END_STMT_MODE 8
#define DST_S_C_SET_LINE_NUM 9 /* Set Line # */
#define DST_S_C_SET_PC 10
#define DST_S_C_SET_PC_W 11
#define DST_S_C_SET_PC_L 12
#define DST_S_C_SET_STMTNUM 13
#define DST_S_C_TERM 14 /* End of lines */
#define DST_S_C_TERM_W 15 /* End of lines */
#define DST_S_C_SET_ABS_PC 16 /* Set PC */
#define DST_S_C_DELTA_PC_L 17 /* Incr PC */
#define DST_S_C_INCR_LINUM_L 18 /* Incr Line # */
#define DST_S_C_SET_LINUM_B 19 /* Set Line # */
#define DST_S_C_SET_LINUM_L 20 /* Set Line # */
#define DST_S_C_TERM_L 21 /* End of lines */
/* these are used with DST_S_C_SOURCE */
#define DST_S_C_SRC_FORMFEED 16 /* ^L counts */
#define DST_S_C_SRC_DECLFILE 1 /* Declare file */
#define DST_S_C_SRC_SETFILE 2 /* Set file */
#define DST_S_C_SRC_SETREC_L 3 /* Set record */
#define DST_S_C_SRC_DEFLINES_W 10 /* # of line */
/* the following are the codes for the various data types. Anything not on
* the list is included under 'advanced_type'
*/
#define DBG_S_C_UCHAR 0x02
#define DBG_S_C_USINT 0x03
#define DBG_S_C_ULINT 0x04
#define DBG_S_C_SCHAR 0x06
#define DBG_S_C_SSINT 0x07
#define DBG_S_C_SLINT 0x08
#define DBG_S_C_REAL4 0x0a
#define DBG_S_C_REAL8 0x0b
#define DBG_S_C_FUNCTION_ADDR 0x17
#define DBG_S_C_ADVANCED_TYPE 0xa3
/* These are the codes that are used to generate the definitions of struct
* union and enum records
*/
#define DBG_S_C_ENUM_ITEM 0xa4
#define DBG_S_C_ENUM_START 0xa5
#define DBG_S_C_ENUM_END 0xa6
#define DBG_S_C_STRUCT_START 0xab
#define DBG_S_C_STRUCT_ITEM 0xff
#define DBG_S_C_STRUCT_END 0xac
/* These are the codes that are used in the suffix records to determine the
* actual data type
*/
#define DBG_S_C_BASIC 0x01
#define DBG_S_C_BASIC_ARRAY 0x02
#define DBG_S_C_STRUCT 0x03
#define DBG_S_C_POINTER 0x04
#define DBG_S_C_VOID 0x05
#define DBG_S_C_COMPLEX_ARRAY 0x07
/* These codes are used in the generation of the symbol definition records
*/
#define DBG_S_C_FUNCTION_PARAMETER 0xc9
#define DBG_S_C_LOCAL_SYM 0xd9
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of obj-vms.h */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,40 @@
/* tc-a29k.h -- Assemble for the AMD 29000.
Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define TC_A29K
#define NO_LISTING
#define tc_aout_pre_write_hook(x) {;} /* not used */
#define tc_coff_symbol_emit_hook(a) {;} /* not used */
#define tc_crawl_symbol_chain(a) {;} /* not used */
#define tc_headers_hook(a) {;} /* not used */
#define AOUT_MACHTYPE 101
#define TC_COFF_FIX2RTYPE(fix_ptr) tc_coff_fix2rtype(fix_ptr)
#define BFD_ARCH bfd_arch_a29k
#define COFF_MAGIC SIPFBOMAGIC
/* Should the reloc be output ?
on the 29k, this is true only if there is a symbol attatched.
on the h8, this is allways true, since no fixup is done
*/
#define TC_COUNT_RELOC(x) (x->fx_addsy)
/* end of tc-a29k.h */

View File

View File

@ -0,0 +1,37 @@
/* This file is tc-generic.h
Copyright (C) 1987-1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* This file is tc-generic.h and is intended to be a template for target cpu
* specific header files. It is my intent that this file compile. It is also
* my intent that this file grow into something that can be used as both a
* template for porting, and a stub for testing. xoxorich.
*/
#define TC_GENERIC 1
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of tc-generic.h */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,38 @@
/* This file is tc-h8300.h
Copyright (C) 1987-1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define TC_H8300
/* This macro translates between an internal fix and an coff reloc type */
#define TC_COFF_FIX2RTYPE(fixP) abort();
#define BFD_ARCH bfd_arch_h8300
#define COFF_MAGIC 0x8300
#define TC_COUNT_RELOC(x) (1)
#define TC_RELOC_MANGLE(a,b,c) tc_reloc_mangle(a,b,c)
#define DO_NOT_STRIP 1
#define DO_STRIP 0
#define LISTING_HEADER "Hitachi H8/300 GAS "
/* end of tc-h8300.h */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,254 @@
/* tc-i386.h -- Header file for tc-i386.c
Copyright (C) 1989, 1992 Free Software Foundation.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* $Id: tc-i386.h,v 1.1 1993/10/02 20:59:21 pk Exp $
*/
#ifndef TC_I386
#define TC_I386 1
#if 0
#define AOUT_MACHTYPE 100
#endif
#define REVERSE_SORT_RELOCS
#define LOCAL_LABELS_FB
#define NO_LISTING
#define tc_coff_symbol_emit_hook(a) ; /* not used */
/* Local labels starts with .L */
/* fixme-now: this is for testing against old gas */
/* #define LOCAL_LABEL(name) ((name)[0] == '.' && (name)[1] == 'L') */
#define tc_aout_pre_write_hook(x) {;} /* not used */
#define tc_crawl_symbol_chain(a) {;} /* not used */
#define tc_headers_hook(a) {;} /* not used */
#define MAX_OPERANDS 3 /* max operands per insn */
#define MAX_PREFIXES 4 /* max prefixes per opcode */
#define MAX_IMMEDIATE_OPERANDS 2 /* max immediates per insn */
#define MAX_MEMORY_OPERANDS 2 /* max memory ref per insn
* lcall uses 2
*/
/* we define the syntax here (modulo base,index,scale syntax) */
#define REGISTER_PREFIX '%'
#define IMMEDIATE_PREFIX '$'
#define ABSOLUTE_PREFIX '*'
#define PREFIX_SEPERATOR '/'
#define TWO_BYTE_OPCODE_ESCAPE 0x0f
#ifndef OLD_GAS
#define NOP_OPCODE 0x90
#else /* OLD_GAS */
#define NOP_OPCODE 0x00
#endif /* OLD_GAS */
/* register numbers */
#define EBP_REG_NUM 5
#define ESP_REG_NUM 4
/* modrm_byte.regmem for twobyte escape */
#define ESCAPE_TO_TWO_BYTE_ADDRESSING ESP_REG_NUM
/* index_base_byte.index for no index register addressing */
#define NO_INDEX_REGISTER ESP_REG_NUM
/* index_base_byte.base for no base register addressing */
#define NO_BASE_REGISTER EBP_REG_NUM
/* these are the att as opcode suffixes, making movl --> mov, for example */
#define DWORD_OPCODE_SUFFIX 'l'
#define WORD_OPCODE_SUFFIX 'w'
#define BYTE_OPCODE_SUFFIX 'b'
/* modrm.mode = REGMEM_FIELD_HAS_REG when a register is in there */
#define REGMEM_FIELD_HAS_REG 0x3 /* always = 0x3 */
#define REGMEM_FIELD_HAS_MEM (~REGMEM_FIELD_HAS_REG)
#define END_OF_INSN '\0'
/*
When an operand is read in it is classified by its type. This type includes
all the possible ways an operand can be used. Thus, '%eax' is both 'register
# 0' and 'The Accumulator'. In our language this is expressed by OR'ing
'Reg32' (any 32 bit register) and 'Acc' (the accumulator).
Operands are classified so that we can match given operand types with
the opcode table in i386-opcode.h.
*/
#define Unknown 0x0
/* register */
#define Reg8 0x1 /* 8 bit reg */
#define Reg16 0x2 /* 16 bit reg */
#define Reg32 0x4 /* 32 bit reg */
#define Reg (Reg8|Reg16|Reg32) /* gen'l register */
#define WordReg (Reg16|Reg32) /* for push/pop operands */
/* immediate */
#define Imm8 0x8 /* 8 bit immediate */
#define Imm8S 0x10 /* 8 bit immediate sign extended */
#define Imm16 0x20 /* 16 bit immediate */
#define Imm32 0x40 /* 32 bit immediate */
#define Imm1 0x80 /* 1 bit immediate */
#define ImmUnknown Imm32 /* for unknown expressions */
#define Imm (Imm8|Imm8S|Imm16|Imm32) /* gen'l immediate */
/* memory */
#define Disp8 0x200 /* 8 bit displacement (for jumps) */
#define Disp16 0x400 /* 16 bit displacement */
#define Disp32 0x800 /* 32 bit displacement */
#define Disp (Disp8|Disp16|Disp32) /* General displacement */
#define DispUnknown Disp32 /* for unknown size displacements */
#define Mem8 0x1000
#define Mem16 0x2000
#define Mem32 0x4000
#define BaseIndex 0x8000
#define Mem (Disp|Mem8|Mem16|Mem32|BaseIndex) /* General memory */
#define WordMem (Mem16|Mem32|Disp|BaseIndex)
#define ByteMem (Mem8|Disp|BaseIndex)
/* specials */
#define InOutPortReg 0x10000 /* register to hold in/out port addr = dx */
#define ShiftCount 0x20000 /* register to hold shift cound = cl */
#define Control 0x40000 /* Control register */
#define Debug 0x80000 /* Debug register */
#define Test 0x100000 /* Test register */
#define FloatReg 0x200000 /* Float register */
#define FloatAcc 0x400000 /* Float stack top %st(0) */
#define SReg2 0x800000 /* 2 bit segment register */
#define SReg3 0x1000000 /* 3 bit segment register */
#define Acc 0x2000000 /* Accumulator %al or %ax or %eax */
#define ImplicitRegister (InOutPortReg|ShiftCount|Acc|FloatAcc)
#define JumpAbsolute 0x4000000
#define Abs8 0x08000000
#define Abs16 0x10000000
#define Abs32 0x20000000
#define Abs (Abs8|Abs16|Abs32)
#define Byte (Reg8|Imm8|Imm8S)
#define Word (Reg16|Imm16)
#define DWord (Reg32|Imm32)
#define SMALLEST_DISP_TYPE(num) \
fits_in_signed_byte(num) ? (Disp8|Disp32|Abs8|Abs32) : (Disp32|Abs32)
typedef struct {
/* instruction name sans width suffix ("mov" for movl insns) */
char *name;
/* how many operands */
unsigned int operands;
/* base_opcode is the fundamental opcode byte with a optional prefix(es). */
unsigned int base_opcode;
/* extension_opcode is the 3 bit extension for group <n> insns.
If this template has no extension opcode (the usual case) use None */
unsigned char extension_opcode;
#define None 0xff /* If no extension_opcode is possible. */
/* the bits in opcode_modifier are used to generate the final opcode from
the base_opcode. These bits also are used to detect alternate forms of
the same instruction */
unsigned int opcode_modifier;
/* opcode_modifier bits: */
#define W 0x1 /* set if operands are words or dwords */
#define D 0x2 /* D = 0 if Reg --> Regmem; D = 1 if Regmem --> Reg */
/* direction flag for floating insns: MUST BE 0x400 */
#define FloatD 0x400
/* shorthand */
#define DW (D|W)
#define ShortForm 0x10 /* register is in low 3 bits of opcode */
#define ShortFormW 0x20 /* ShortForm and W bit is 0x8 */
#define Seg2ShortForm 0x40 /* encoding of load segment reg insns */
#define Seg3ShortForm 0x80 /* fs/gs segment register insns. */
#define Jump 0x100 /* special case for jump insns. */
#define JumpInterSegment 0x200 /* special case for intersegment leaps/calls */
/* 0x400 CANNOT BE USED since it's already used by FloatD above */
#define DONT_USE 0x400
#define NoModrm 0x800
#define Modrm 0x1000
#define imulKludge 0x2000
#define JumpByte 0x4000
#define JumpDword 0x8000
#define ReverseRegRegmem 0x10000
/* (opcode_modifier & COMES_IN_ALL_SIZES) is true if the
instuction comes in byte, word, and dword sizes and is encoded into
machine code in the canonical way. */
#define COMES_IN_ALL_SIZES (W)
/* (opcode_modifier & COMES_IN_BOTH_DIRECTIONS) indicates that the
source and destination operands can be reversed by setting either
the D (for integer insns) or the FloatD (for floating insns) bit
in base_opcode. */
#define COMES_IN_BOTH_DIRECTIONS (D|FloatD)
/* operand_types[i] describes the type of operand i. This is made
by OR'ing together all of the possible type masks. (e.g.
'operand_types[i] = Reg|Imm' specifies that operand i can be
either a register or an immediate operand */
unsigned int operand_types[3];
} template;
/*
'templates' is for grouping together 'template' structures for opcodes
of the same name. This is only used for storing the insns in the grand
ole hash table of insns.
The templates themselves start at START and range up to (but not including)
END.
*/
typedef struct {
template *start;
template *end;
} templates;
/* these are for register name --> number & type hash lookup */
typedef struct {
char *reg_name;
unsigned int reg_type;
unsigned int reg_num;
} reg_entry;
typedef struct {
char *seg_name;
unsigned int seg_prefix;
} seg_entry;
/* these are for prefix name --> prefix code hash lookup */
typedef struct {
char *prefix_name;
unsigned char prefix_code;
} prefix_entry;
/* 386 operand encoding bytes: see 386 book for details of this. */
typedef struct {
unsigned regmem:3; /* codes register or memory operand */
unsigned reg:3; /* codes register operand (or extended opcode) */
unsigned mode:2; /* how to interpret regmem & reg */
} modrm_byte;
/* 386 opcode byte to code indirect addressing. */
typedef struct {
unsigned base:3;
unsigned index:3;
unsigned scale:2;
} base_index_byte;
#endif /* TC_I386 */
/* end of tc-i386.h */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
/*
* This file is tc-i860.h.
*/
#define TC_I860 1
#define NO_LISTING
#ifdef OLD_GAS
#define REVERSE_SORT_RELOCS
#endif /* OLD_GAS */
#define tc_headers_hook(a) {;} /* not used */
#define tc_crawl_symbol_chain(a) {;} /* not used */
#define tc_aout_pre_write_hook(x) {;} /* not used */
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of tc-i860.h */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,281 @@
/* tc-i960.h - Basic 80960 instruction formats.
Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2,
or (at your option) any later version.
GAS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with GAS; see the file COPYING. If not, write
to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef TC_I960
#define TC_I960 1
#define NO_LISTING
/*
* The 'COJ' instructions are actually COBR instructions with the 'b' in
* the mnemonic replaced by a 'j'; they are ALWAYS "de-optimized" if necessary:
* if the displacement will not fit in 13 bits, the assembler will replace them
* with the corresponding compare and branch instructions.
*
* All of the 'MEMn' instructions are the same format; the 'n' in the name
* indicates the default index scale factor (the size of the datum operated on).
*
* The FBRA formats are not actually an instruction format. They are the
* "convenience directives" for branching on floating-point comparisons,
* each of which generates 2 instructions (a 'bno' and one other branch).
*
* The CALLJ format is not actually an instruction format. It indicates that
* the instruction generated (a CTRL-format 'call') should have its relocation
* specially flagged for link-time replacement with a 'bal' or 'calls' if
* appropriate.
*/
/* tailor gas */
#define SYMBOLS_NEED_BACKPOINTERS
#define LOCAL_LABELS_FB
#define WANT_BITFIELDS
/* tailor the coff format */
#define OBJ_COFF_SECTION_HEADER_HAS_ALIGNMENT
#define OBJ_COFF_MAX_AUXENTRIES (2)
/* other */
#define CTRL 0
#define COBR 1
#define COJ 2
#define REG 3
#define MEM1 4
#define MEM2 5
#define MEM4 6
#define MEM8 7
#define MEM12 8
#define MEM16 9
#define FBRA 10
#define CALLJ 11
/* Masks for the mode bits in REG format instructions */
#define M1 0x0800
#define M2 0x1000
#define M3 0x2000
/* Generate the 12-bit opcode for a REG format instruction by placing the
* high 8 bits in instruction bits 24-31, the low 4 bits in instruction bits
* 7-10.
*/
#define REG_OPC(opc) ((opc & 0xff0) << 20) | ((opc & 0xf) << 7)
/* Generate a template for a REG format instruction: place the opcode bits
* in the appropriate fields and OR in mode bits for the operands that will not
* be used. I.e.,
* set m1=1, if src1 will not be used
* set m2=1, if src2 will not be used
* set m3=1, if dst will not be used
*
* Setting the "unused" mode bits to 1 speeds up instruction execution(!).
* The information is also useful to us because some 1-operand REG instructions
* use the src1 field, others the dst field; and some 2-operand REG instructions
* use src1/src2, others src1/dst. The set mode bits enable us to distinguish.
*/
#define R_0(opc) ( REG_OPC(opc) | M1 | M2 | M3 ) /* No operands */
#define R_1(opc) ( REG_OPC(opc) | M2 | M3 ) /* 1 operand: src1 */
#define R_1D(opc) ( REG_OPC(opc) | M1 | M2 ) /* 1 operand: dst */
#define R_2(opc) ( REG_OPC(opc) | M3 ) /* 2 ops: src1/src2 */
#define R_2D(opc) ( REG_OPC(opc) | M2 ) /* 2 ops: src1/dst */
#define R_3(opc) ( REG_OPC(opc) ) /* 3 operands */
/* DESCRIPTOR BYTES FOR REGISTER OPERANDS
*
* Interpret names as follows:
* R: global or local register only
* RS: global, local, or (if target allows) special-function register only
* RL: global or local register, or integer literal
* RSL: global, local, or (if target allows) special-function register;
* or integer literal
* F: global, local, or floating-point register
* FL: global, local, or floating-point register; or literal (including
* floating point)
*
* A number appended to a name indicates that registers must be aligned,
* as follows:
* 2: register number must be multiple of 2
* 4: register number must be multiple of 4
*/
#define SFR 0x10 /* Mask for the "sfr-OK" bit */
#define LIT 0x08 /* Mask for the "literal-OK" bit */
#define FP 0x04 /* Mask for "floating-point-OK" bit */
/* This macro ors the bits together. Note that 'align' is a mask
* for the low 0, 1, or 2 bits of the register number, as appropriate.
*/
#define OP(align,lit,fp,sfr) ( align | lit | fp | sfr )
#define R OP( 0, 0, 0, 0 )
#define RS OP( 0, 0, 0, SFR )
#define RL OP( 0, LIT, 0, 0 )
#define RSL OP( 0, LIT, 0, SFR )
#define F OP( 0, 0, FP, 0 )
#define FL OP( 0, LIT, FP, 0 )
#define R2 OP( 1, 0, 0, 0 )
#define RL2 OP( 1, LIT, 0, 0 )
#define F2 OP( 1, 0, FP, 0 )
#define FL2 OP( 1, LIT, FP, 0 )
#define R4 OP( 3, 0, 0, 0 )
#define RL4 OP( 3, LIT, 0, 0 )
#define F4 OP( 3, 0, FP, 0 )
#define FL4 OP( 3, LIT, FP, 0 )
#define M 0x7f /* Memory operand (MEMA & MEMB format instructions) */
/* Macros to extract info from the register operand descriptor byte 'od'.
*/
#define SFR_OK(od) (od & SFR) /* TRUE if sfr operand allowed */
#define LIT_OK(od) (od & LIT) /* TRUE if literal operand allowed */
#define FP_OK(od) (od & FP) /* TRUE if floating-point op allowed */
#define REG_ALIGN(od,n) ((od & 0x3 & n) == 0)
/* TRUE if reg #n is properly aligned */
#define MEMOP(od) (od == M) /* TRUE if operand is a memory operand*/
/* Classes of 960 intructions:
* - each instruction falls into one class.
* - each target architecture supports one or more classes.
*
* EACH CONSTANT MUST CONTAIN 1 AND ONLY 1 SET BIT!: see targ_has_iclass().
*/
#define I_BASE 0x01 /* 80960 base instruction set */
#define I_CX 0x02 /* 80960Cx instruction */
#define I_DEC 0x04 /* Decimal instruction */
#define I_FP 0x08 /* Floating point instruction */
#define I_KX 0x10 /* 80960Kx instruction */
#define I_MIL 0x20 /* Military instruction */
/* MEANING OF 'n_other' in the symbol record.
*
* If non-zero, the 'n_other' fields indicates either a leaf procedure or
* a system procedure, as follows:
*
* 1 <= n_other <= 32 :
* The symbol is the entry point to a system procedure.
* 'n_value' is the address of the entry, as for any other
* procedure. The system procedure number (which can be used in
* a 'calls' instruction) is (n_other-1). These entries come from
* '.sysproc' directives.
*
* n_other == N_CALLNAME
* the symbol is the 'call' entry point to a leaf procedure.
* The *next* symbol in the symbol table must be the corresponding
* 'bal' entry point to the procedure (see following). These
* entries come from '.leafproc' directives in which two different
* symbols are specified (the first one is represented here).
*
*
* n_other == N_BALNAME
* the symbol is the 'bal' entry point to a leaf procedure.
* These entries result from '.leafproc' directives in which only
* one symbol is specified, or in which the same symbol is
* specified twice.
*
* Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry,
* but not every N_BALNAME entry must have an N_CALLNAME entry.
*/
#define N_CALLNAME (-1)
#define N_BALNAME (-2)
/* i960 uses a custom relocation record. */
/* let obj-aout.h know */
#define CUSTOM_RELOC_FORMAT 1
/* let a.out.gnu.h know */
#define N_RELOCATION_INFO_DECLARED 1
struct relocation_info {
int r_address; /* File address of item to be relocated */
unsigned
r_index:24,/* Index of symbol on which relocation is based*/
r_pcrel:1, /* 1 => relocate PC-relative; else absolute
* On i960, pc-relative implies 24-bit
* address, absolute implies 32-bit.
*/
r_length:2, /* Number of bytes to relocate:
* 0 => 1 byte
* 1 => 2 bytes
* 2 => 4 bytes -- only value used for i960
*/
r_extern:1,
r_bsr:1, /* Something for the GNU NS32K assembler */
r_disp:1, /* Something for the GNU NS32K assembler */
r_callj:1, /* 1 if relocation target is an i960 'callj' */
nuthin:1; /* Unused */
};
/* hacks for tracking callj's */
#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
#define TC_S_IS_SYSPROC(s) ((1 <= S_GET_OTHER(s)) && (S_GET_OTHER(s) <= 32))
#define TC_S_IS_BALNAME(s) (S_GET_OTHER(s) == N_BALNAME)
#define TC_S_IS_CALLNAME(s) (S_GET_OTHER(s) == N_CALLNAME)
#define TC_S_IS_BADPROC(s) ((S_GET_OTHER(s) != 0) && !TC_S_IS_CALLNAME(s) && !TC_S_IS_BALNAME(s) && !TC_S_IS_SYSPROC(s))
#define TC_S_SET_SYSPROC(s, p) (S_SET_OTHER((s), (p)+1))
#define TC_S_GET_SYSPROC(s) (S_GET_OTHER(s)-1)
#define TC_S_FORCE_TO_BALNAME(s) (S_SET_OTHER((s), N_BALNAME))
#define TC_S_FORCE_TO_CALLNAME(s) (S_SET_OTHER((s), N_CALLNAME))
#define TC_S_FORCE_TO_SYSPROC(s) {;}
#elif defined(OBJ_COFF)
#define TC_S_IS_SYSPROC(s) (S_GET_STORAGE_CLASS(s) == C_SCALL)
#define TC_S_IS_BALNAME(s) (SF_GET_BALNAME(s))
#define TC_S_IS_CALLNAME(s) (SF_GET_CALLNAME(s))
#define TC_S_IS_BADPROC(s) (TC_S_IS_SYSPROC(s) && TC_S_GET_SYSPROC(s) < 0 && 31 < TC_S_GET_SYSPROC(s))
#define TC_S_SET_SYSPROC(s, p) ((s)->sy_symbol.ost_auxent[1].x_sc.x_stindx = (p))
#define TC_S_GET_SYSPROC(s) ((s)->sy_symbol.ost_auxent[1].x_sc.x_stindx)
#define TC_S_FORCE_TO_BALNAME(s) (SF_SET_BALNAME(s))
#define TC_S_FORCE_TO_CALLNAME(s) (SF_SET_CALLNAME(s))
#define TC_S_FORCE_TO_SYSPROC(s) (S_SET_STORAGE_CLASS((s), C_SCALL))
#else /* switch on OBJ */
you lose
#endif /* witch on OBJ */
#if __STDC__ == 1
void brtab_emit(void);
void reloc_callj(); /* this is really reloc_callj(fixS *fixP) but I don't want to change header inclusion order. */
void tc_set_bal_of_call(); /* this is really tc_set_bal_of_call(symbolS *callP, symbolS *balP) */
#else /* not __STDC__ */
void brtab_emit();
void reloc_callj();
void tc_set_bal_of_call();
#endif /* not __STDC__ */
char *_tc_get_bal_of_call(); /* this is really symbolS *tc_get_bal_of_call(symbolS *callP). */
#define tc_get_bal_of_call(c) ((symbolS *) _tc_get_bal_of_call(c))
#endif
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of tc-i960.h */

View File

@ -0,0 +1,304 @@
/* This file is tc-m68851.h
Copyright (C) 1987-1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* pmmu.h
*/
/* I suppose we have to copyright this file. Someone on the net sent it
to us as part of the changes for the m68851 Memory Management Unit */
/* Copyright (C) 1987 Free Software Foundation, Inc.
This file is part of Gas, the GNU Assembler.
The GNU assembler is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY. No author or distributor
accepts responsibility to anyone for the consequences of using it
or for whether it serves any particular purpose or works at all,
unless he says so in writing. Refer to the GNU Assembler General
Public License for full details.
Everyone is granted permission to copy, modify and redistribute
the GNU Assembler, but only under the conditions described in the
GNU Assembler General Public License. A copy of this license is
supposed to have been given to you along with the GNU Assembler
so you can know your rights and responsibilities. It should be
in a file named COPYING. Among other things, the copyright
notice and this notice must be preserved on all copies. */
#ifdef m68851
/*
I didn't use much imagination in choosing the
following codes, so many of them aren't very
mnemonic. -rab
P pmmu register
Possible values:
000 TC Translation Control reg
100 CAL Current Access Level
101 VAL Validate Access Level
110 SCC Stack Change Control
111 AC Access Control
W wide pmmu registers
Possible values:
001 DRP Dma Root Pointer
010 SRP Supervisor Root Pointer
011 CRP Cpu Root Pointer
f function code register
0 SFC
1 DFC
V VAL register only
X BADx, BACx
100 BAD Breakpoint Acknowledge Data
101 BAC Breakpoint Acknowledge Control
Y PSR
Z PCSR
| memory (modes 2-6, 7.*)
*/
/*
* these defines should be in m68k.c but
* i put them here to keep all the m68851 stuff
* together -rab
* JF--Make sure these #s don't clash with the ones in m68k.c
* That would be BAD.
*/
#define TC (FPS+1) /* 48 */
#define DRP (TC+1) /* 49 */
#define SRP (DRP+1) /* 50 */
#define CRP (SRP+1) /* 51 */
#define CAL (CRP+1) /* 52 */
#define VAL (CAL+1) /* 53 */
#define SCC (VAL+1) /* 54 */
#define AC (SCC+1) /* 55 */
#define BAD (AC+1) /* 56,57,58,59, 60,61,62,63 */
#define BAC (BAD+8) /* 64,65,66,67, 68,69,70,71 */
#define PSR (BAC+8) /* 72 */
#define PCSR (PSR+1) /* 73 */
/* name */ /* opcode */ /* match */ /* args */
{"pbac", one(0xf0c7), one(0xffbf), "Bc"},
{"pbacw", one(0xf087), one(0xffbf), "Bc"},
{"pbas", one(0xf0c6), one(0xffbf), "Bc"},
{"pbasw", one(0xf086), one(0xffbf), "Bc"},
{"pbbc", one(0xf0c1), one(0xffbf), "Bc"},
{"pbbcw", one(0xf081), one(0xffbf), "Bc"},
{"pbbs", one(0xf0c0), one(0xffbf), "Bc"},
{"pbbsw", one(0xf080), one(0xffbf), "Bc"},
{"pbcc", one(0xf0cf), one(0xffbf), "Bc"},
{"pbccw", one(0xf08f), one(0xffbf), "Bc"},
{"pbcs", one(0xf0ce), one(0xffbf), "Bc"},
{"pbcsw", one(0xf08e), one(0xffbf), "Bc"},
{"pbgc", one(0xf0cd), one(0xffbf), "Bc"},
{"pbgcw", one(0xf08d), one(0xffbf), "Bc"},
{"pbgs", one(0xf0cc), one(0xffbf), "Bc"},
{"pbgsw", one(0xf08c), one(0xffbf), "Bc"},
{"pbic", one(0xf0cb), one(0xffbf), "Bc"},
{"pbicw", one(0xf08b), one(0xffbf), "Bc"},
{"pbis", one(0xf0ca), one(0xffbf), "Bc"},
{"pbisw", one(0xf08a), one(0xffbf), "Bc"},
{"pblc", one(0xf0c3), one(0xffbf), "Bc"},
{"pblcw", one(0xf083), one(0xffbf), "Bc"},
{"pbls", one(0xf0c2), one(0xffbf), "Bc"},
{"pblsw", one(0xf082), one(0xffbf), "Bc"},
{"pbsc", one(0xf0c5), one(0xffbf), "Bc"},
{"pbscw", one(0xf085), one(0xffbf), "Bc"},
{"pbss", one(0xf0c4), one(0xffbf), "Bc"},
{"pbssw", one(0xf084), one(0xffbf), "Bc"},
{"pbwc", one(0xf0c9), one(0xffbf), "Bc"},
{"pbwcw", one(0xf089), one(0xffbf), "Bc"},
{"pbws", one(0xf0c8), one(0xffbf), "Bc"},
{"pbwsw", one(0xf088), one(0xffbf), "Bc"},
{"pdbac", two(0xf048, 0x0007), two(0xfff8, 0xffff), "DsBw"},
{"pdbas", two(0xf048, 0x0006), two(0xfff8, 0xffff), "DsBw"},
{"pdbbc", two(0xf048, 0x0001), two(0xfff8, 0xffff), "DsBw"},
{"pdbbs", two(0xf048, 0x0000), two(0xfff8, 0xffff), "DsBw"},
{"pdbcc", two(0xf048, 0x000f), two(0xfff8, 0xffff), "DsBw"},
{"pdbcs", two(0xf048, 0x000e), two(0xfff8, 0xffff), "DsBw"},
{"pdbgc", two(0xf048, 0x000d), two(0xfff8, 0xffff), "DsBw"},
{"pdbgs", two(0xf048, 0x000c), two(0xfff8, 0xffff), "DsBw"},
{"pdbic", two(0xf048, 0x000b), two(0xfff8, 0xffff), "DsBw"},
{"pdbis", two(0xf048, 0x000a), two(0xfff8, 0xffff), "DsBw"},
{"pdblc", two(0xf048, 0x0003), two(0xfff8, 0xffff), "DsBw"},
{"pdbls", two(0xf048, 0x0002), two(0xfff8, 0xffff), "DsBw"},
{"pdbsc", two(0xf048, 0x0005), two(0xfff8, 0xffff), "DsBw"},
{"pdbss", two(0xf048, 0x0004), two(0xfff8, 0xffff), "DsBw"},
{"pdbwc", two(0xf048, 0x0009), two(0xfff8, 0xffff), "DsBw"},
{"pdbws", two(0xf048, 0x0008), two(0xfff8, 0xffff), "DsBw"},
{"pflusha", two(0xf000, 0x2400), two(0xffff, 0xffff), "" },
{"pflush", two(0xf000, 0x3010), two(0xffc0, 0xfe10), "T3T9" },
{"pflush", two(0xf000, 0x3810), two(0xffc0, 0xfe10), "T3T9&s" },
{"pflush", two(0xf000, 0x3008), two(0xffc0, 0xfe18), "D3T9" },
{"pflush", two(0xf000, 0x3808), two(0xffc0, 0xfe18), "D3T9&s" },
{"pflush", two(0xf000, 0x3000), two(0xffc0, 0xfe1e), "f3T9" },
{"pflush", two(0xf000, 0x3800), two(0xffc0, 0xfe1e), "f3T9&s" },
{"pflushs", two(0xf000, 0x3410), two(0xfff8, 0xfe10), "T3T9" },
{"pflushs", two(0xf000, 0x3c00), two(0xfff8, 0xfe00), "T3T9&s" },
{"pflushs", two(0xf000, 0x3408), two(0xfff8, 0xfe18), "D3T9" },
{"pflushs", two(0xf000, 0x3c08), two(0xfff8, 0xfe18), "D3T9&s" },
{"pflushs", two(0xf000, 0x3400), two(0xfff8, 0xfe1e), "f3T9" },
{"pflushs", two(0xf000, 0x3c00), two(0xfff8, 0xfe1e), "f3T9&s"},
{"pflushr", two(0xf000, 0xa000), two(0xffc0, 0xffff), "|s" },
{"ploadr", two(0xf000, 0x2210), two(0xffc0, 0xfff0), "T3&s" },
{"ploadr", two(0xf000, 0x2208), two(0xffc0, 0xfff8), "D3&s" },
{"ploadr", two(0xf000, 0x2200), two(0xffc0, 0xfffe), "f3&s" },
{"ploadw", two(0xf000, 0x2010), two(0xffc0, 0xfff0), "T3&s" },
{"ploadw", two(0xf000, 0x2008), two(0xffc0, 0xfff8), "D3&s" },
{"ploadw", two(0xf000, 0x2000), two(0xffc0, 0xfffe), "f3&s" },
/* TC, CRP, DRP, SRP, CAL, VAL, SCC, AC */
{"pmove", two(0xf000, 0x4000), two(0xffc0, 0xe3ff), "*sP8" },
{"pmove", two(0xf000, 0x4200), two(0xffc0, 0xe3ff), "P8%s" },
{"pmove", two(0xf000, 0x4000), two(0xffc0, 0xe3ff), "|sW8" },
{"pmove", two(0xf000, 0x4200), two(0xffc0, 0xe3ff), "W8~s" },
/* BADx, BACx */
{"pmove", two(0xf000, 0x6200), two(0xffc0, 0xe3e3), "*sX3" },
{"pmove", two(0xf000, 0x6000), two(0xffc0, 0xe3e3), "X3%s" },
/* PSR, PCSR */
/* {"pmove", two(0xf000, 0x6100), two(oxffc0, oxffff), "*sZ8" }, */
{"pmove", two(0xf000, 0x6000), two(0xffc0, 0xffff), "*sY8" },
{"pmove", two(0xf000, 0x6200), two(0xffc0, 0xffff), "Y8%s" },
{"pmove", two(0xf000, 0x6600), two(0xffc0, 0xffff), "Z8%s" },
{"prestore", one(0xf140), one(0xffc0), "&s"},
{"prestore", one(0xf158), one(0xfff8), "+s"},
{"psave", one(0xf100), one(0xffc0), "&s"},
{"psave", one(0xf100), one(0xffc0), "+s"},
{"psac", two(0xf040, 0x0007), two(0xffc0, 0xffff), "@s"},
{"psas", two(0xf040, 0x0006), two(0xffc0, 0xffff), "@s"},
{"psbc", two(0xf040, 0x0001), two(0xffc0, 0xffff), "@s"},
{"psbs", two(0xf040, 0x0000), two(0xffc0, 0xffff), "@s"},
{"pscc", two(0xf040, 0x000f), two(0xffc0, 0xffff), "@s"},
{"pscs", two(0xf040, 0x000e), two(0xffc0, 0xffff), "@s"},
{"psgc", two(0xf040, 0x000d), two(0xffc0, 0xffff), "@s"},
{"psgs", two(0xf040, 0x000c), two(0xffc0, 0xffff), "@s"},
{"psic", two(0xf040, 0x000b), two(0xffc0, 0xffff), "@s"},
{"psis", two(0xf040, 0x000a), two(0xffc0, 0xffff), "@s"},
{"pslc", two(0xf040, 0x0003), two(0xffc0, 0xffff), "@s"},
{"psls", two(0xf040, 0x0002), two(0xffc0, 0xffff), "@s"},
{"pssc", two(0xf040, 0x0005), two(0xffc0, 0xffff), "@s"},
{"psss", two(0xf040, 0x0004), two(0xffc0, 0xffff), "@s"},
{"pswc", two(0xf040, 0x0009), two(0xffc0, 0xffff), "@s"},
{"psws", two(0xf040, 0x0008), two(0xffc0, 0xffff), "@s"},
{"ptestr", two(0xf000, 0x8210), two(0xffc0, 0xe3f0), "T3&sQ8" },
{"ptestr", two(0xf000, 0x8310), two(0xffc0, 0xe310), "T3&sQ8A9" },
{"ptestr", two(0xf000, 0x8208), two(0xffc0, 0xe3f8), "D3&sQ8" },
{"ptestr", two(0xf000, 0x8308), two(0xffc0, 0xe318), "D3&sQ8A9" },
{"ptestr", two(0xf000, 0x8200), two(0xffc0, 0xe3fe), "f3&sQ8" },
{"ptestr", two(0xf000, 0x8300), two(0xffc0, 0xe31e), "f3&sQ8A9" },
{"ptestw", two(0xf000, 0x8010), two(0xffc0, 0xe3f0), "T3&sQ8" },
{"ptestw", two(0xf000, 0x8110), two(0xffc0, 0xe310), "T3&sQ8A9" },
{"ptestw", two(0xf000, 0x8008), two(0xffc0, 0xe3f8), "D3&sQ8" },
{"ptestw", two(0xf000, 0x8108), two(0xffc0, 0xe318), "D3&sQ8A9" },
{"ptestw", two(0xf000, 0x8000), two(0xffc0, 0xe3fe), "f3&sQ8" },
{"ptestw", two(0xf000, 0x8100), two(0xffc0, 0xe31e), "f3&sQ8A9" },
{"ptrapacw", two(0xf07a, 0x0007), two(0xffff, 0xffff), "#w"},
{"ptrapacl", two(0xf07b, 0x0007), two(0xffff, 0xffff), "#l"},
{"ptrapac", two(0xf07c, 0x0007), two(0xffff, 0xffff), ""},
{"ptrapasw", two(0xf07a, 0x0006), two(0xffff, 0xffff), "#w"},
{"ptrapasl", two(0xf07b, 0x0006), two(0xffff, 0xffff), "#l"},
{"ptrapas", two(0xf07c, 0x0006), two(0xffff, 0xffff), ""},
{"ptrapbcw", two(0xf07a, 0x0001), two(0xffff, 0xffff), "#w"},
{"ptrapbcl", two(0xf07b, 0x0001), two(0xffff, 0xffff), "#l"},
{"ptrapbc", two(0xf07c, 0x0001), two(0xffff, 0xffff), ""},
{"ptrapbsw", two(0xf07a, 0x0000), two(0xffff, 0xffff), "#w"},
{"ptrapbsl", two(0xf07b, 0x0000), two(0xffff, 0xffff), "#l"},
{"ptrapbs", two(0xf07c, 0x0000), two(0xffff, 0xffff), ""},
{"ptrapccw", two(0xf07a, 0x000f), two(0xffff, 0xffff), "#w"},
{"ptrapccl", two(0xf07b, 0x000f), two(0xffff, 0xffff), "#l"},
{"ptrapcc", two(0xf07c, 0x000f), two(0xffff, 0xffff), ""},
{"ptrapcsw", two(0xf07a, 0x000e), two(0xffff, 0xffff), "#w"},
{"ptrapcsl", two(0xf07b, 0x000e), two(0xffff, 0xffff), "#l"},
{"ptrapcs", two(0xf07c, 0x000e), two(0xffff, 0xffff), ""},
{"ptrapgcw", two(0xf07a, 0x000d), two(0xffff, 0xffff), "#w"},
{"ptrapgcl", two(0xf07b, 0x000d), two(0xffff, 0xffff), "#l"},
{"ptrapgc", two(0xf07c, 0x000d), two(0xffff, 0xffff), ""},
{"ptrapgsw", two(0xf07a, 0x000c), two(0xffff, 0xffff), "#w"},
{"ptrapgsl", two(0xf07b, 0x000c), two(0xffff, 0xffff), "#l"},
{"ptrapgs", two(0xf07c, 0x000c), two(0xffff, 0xffff), ""},
{"ptrapicw", two(0xf07a, 0x000b), two(0xffff, 0xffff), "#w"},
{"ptrapicl", two(0xf07b, 0x000b), two(0xffff, 0xffff), "#l"},
{"ptrapic", two(0xf07c, 0x000b), two(0xffff, 0xffff), ""},
{"ptrapisw", two(0xf07a, 0x000a), two(0xffff, 0xffff), "#w"},
{"ptrapisl", two(0xf07b, 0x000a), two(0xffff, 0xffff), "#l"},
{"ptrapis", two(0xf07c, 0x000a), two(0xffff, 0xffff), ""},
{"ptraplcw", two(0xf07a, 0x0003), two(0xffff, 0xffff), "#w"},
{"ptraplcl", two(0xf07b, 0x0003), two(0xffff, 0xffff), "#l"},
{"ptraplc", two(0xf07c, 0x0003), two(0xffff, 0xffff), ""},
{"ptraplsw", two(0xf07a, 0x0002), two(0xffff, 0xffff), "#w"},
{"ptraplsl", two(0xf07b, 0x0002), two(0xffff, 0xffff), "#l"},
{"ptrapls", two(0xf07c, 0x0002), two(0xffff, 0xffff), ""},
{"ptrapscw", two(0xf07a, 0x0005), two(0xffff, 0xffff), "#w"},
{"ptrapscl", two(0xf07b, 0x0005), two(0xffff, 0xffff), "#l"},
{"ptrapsc", two(0xf07c, 0x0005), two(0xffff, 0xffff), ""},
{"ptrapssw", two(0xf07a, 0x0004), two(0xffff, 0xffff), "#w"},
{"ptrapssl", two(0xf07b, 0x0004), two(0xffff, 0xffff), "#l"},
{"ptrapss", two(0xf07c, 0x0004), two(0xffff, 0xffff), ""},
{"ptrapwcw", two(0xf07a, 0x0009), two(0xffff, 0xffff), "#w"},
{"ptrapwcl", two(0xf07b, 0x0009), two(0xffff, 0xffff), "#l"},
{"ptrapwc", two(0xf07c, 0x0009), two(0xffff, 0xffff), ""},
{"ptrapwsw", two(0xf07a, 0x0008), two(0xffff, 0xffff), "#w"},
{"ptrapwsl", two(0xf07b, 0x0008), two(0xffff, 0xffff), "#l"},
{"ptrapws", two(0xf07c, 0x0008), two(0xffff, 0xffff), ""},
{"pvalid", two(0xf000, 0x2800), two(0xffc0, 0xffff), "Vs&s"},
{"pvalid", two(0xf000, 0x2c00), two(0xffc0, 0xfff8), "A3&s" },
#endif /* m68851 */
/* end of tc-m68851.h */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,60 @@
/* This file is tc-m68k.h
Copyright (C) 1987-1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* This file is tp-generic.h and is intended to be a template for
* target processor specific header files.
*/
#define TC_M68K 1
#define NO_LISTING
#ifdef OLD_GAS
#define REVERSE_SORT_RELOCS
#endif /* OLD_GAS */
#define AOUT_MACHTYPE 0x2
#define LOCAL_LABELS_FB
#define tc_crawl_symbol_chain(a) {;} /* not used */
#define tc_headers_hook(a) {;} /* not used */
#define tc_aout_pre_write_hook(x) {;} /* not used */
#define LISTING_WORD_SIZE 2 /* A word is 2 bytes */
#define LISTING_LHS_WIDTH 2 /* One word on the first line */
#define LISTING_LHS_WIDTH_SECOND 2 /* One word on the second line */
#define LISTING_LHS_CONT_LINES 4 /* And 4 lines max */
#define LISTING_HEADER "68K GAS "
/* Copied from write.c */
#define M68K_AIM_KLUDGE(aim, this_state,this_type) \
if (aim == 0 && this_state == 4) { /* hard encoded from tc-m68k.c */ \
aim=this_type->rlx_forward+1; /* Force relaxation into word mode */ \
}
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of tc-m68k.h */

View File

@ -0,0 +1,64 @@
/* This file is tc-m68kmote.h
Copyright (C) 1987-1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* This file is tp-generic.h and is intended to be a template for
* target processor specific header files.
*/
#define TC_M68K 1
#ifdef TE_SUN3
/* This variable contains the value to write out at the beginning of
the a.out file. The 2<<16 means that this is a 68020 file instead
of an old-style 68000 file */
#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (2<<16|OMAGIC); /* Magic byte for file header */
#endif /* TE_SUN3 */
#define AOUT_MACHTYPE 0x2
#define REVERSE_SORT_RELOCS /* FIXME-NOW: this line can be removed. */
#define LOCAL_LABELS_FB
#define tc_crawl_symbol_chain(a) {;} /* not used */
#define tc_headers_hook(a) {;} /* not used */
#define tc_aout_pre_write_hook(x) {;} /* not used */
#define LISTING_WORD_SIZE 2 /* A word is 2 bytes */
#define LISTING_LHS_WIDTH 3 /* 3 word on the first line */
#define LISTING_LHS_WIDTH_SECOND 3 /* One word on the second line */
#define LISTING_LHS_CONT_LINES 4 /* And 4 lines max */
#define LISTING_HEADER "68K GAS "
/* Copied from write.c */
#define M68K_AIM_KLUDGE(aim, this_state,this_type) \
if (aim == 0 && this_state == 4) { /* hard encoded from tc-m68k.c */ \
aim=this_type->rlx_forward+1; /* Force relaxation into word mode */ \
}
#define MRI
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of tc-m68kmote.h */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
/* m88k.h -- Assembler for the Motorola 88000
Contributed by Devon Bowen of Buffalo University
and Torbjorn Granlund of the Swedish Institute of Computer Science.
Copyright (C) 1989-1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define TC_M88K 1
#define NO_LISTING
#define NO_DOT_PSEUDOS
#define ALLOW_ATSIGN
#define LOCAL_LABEL(name) (name[0] == '@' \
&& ( name[1] == 'L' || name[1] == '.' ))
#define tc_crawl_symbol_chain(a) {;} /* not used */
#define tc_headers_hook(a) {;} /* not used */
#define tc_aout_pre_write_hook(x) {;} /* not used */
/* end of tc-m88k.h */

View File

View File

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,60 @@
/* tc-ns32k.h -- Opcode table for National Semi 32k processor
Copyright (C) 1987, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "bit_fix.h"
#define NO_LISTING
#define tc_aout_pre_write_hook(x) {;} /* not used */
#define tc_crawl_symbol_chain(a) {;} /* not used */
#define tc_headers_hook(a) {;} /* not used */
#ifndef DEF_MODEC
#define DEF_MODEC 20
#endif
#ifndef DEF_MODEL
#define DEF_MODEL 20
#endif
#define MAX_ARGS 4
#define ARG_LEN 50
#if __STDC__ == 1
void fix_new_ns32k(fragS *frag,
int where,
int size,
struct symbol *add_symbol,
struct symbol *sub_symbol,
long offset,
int pcrel,
int pcrel_adjust,
int im_disp,
bit_fixS *bit_fixP, /* really bit_fixS */
int bsr);
#else /* not __STDC__ */
void fix_new_ns32k();
#endif /* not __STDC__ */
/* end of tc-ns32k.h */

View File

View File

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,54 @@
/* tc-sparc.h - Macros and type defines for the sparc.
Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2,
or (at your option) any later version.
GAS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with GAS; see the file COPYING. If not, write
to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* $Id: tc-sparc.h,v 1.1 1993/10/02 20:59:41 pk Exp $
*/
#define TC_SPARC 1
#define NO_LISTING
#define LOCAL_LABELS_FB
#define WORKING_DOT_WORD
#ifdef OBJ_BOUT
#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE ((0x103 << 16) | BMAGIC) /* Magic number for header */
#else
#ifdef OBJ_AOUT
#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE ((0x103 << 16) | OMAGIC) /* Magic number for header */
#endif /* OBJ_AOUT */
#endif /* OBJ_BOUT */
#define AOUT_MACHTYPE 3
#define tc_headers_hook(a) {;} /* don't need it. */
#define tc_crawl_symbol_chain(a) {;} /* don't need it. */
void tc_aout_pre_write_hook();
#define LISTING_HEADER "SPARC GAS "
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of tc-sparc.h */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,36 @@
/* This file is tc-tahoe.h
Copyright (C) 1987-1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define TC_TAHOE 1
#define NO_LISTING
#define tc_headers_hook(a) {;} /* don't need it. */
#define tc_crawl_symbol_chain(a) {;} /* don't need it. */
#define tc_aout_pre_write_hook(a) {;}
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of tc-tahoe.h */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,25 @@
/*
* This file is tc-vax.h.
*/
#define TC_VAX 1
#define NO_LISTING
/* use this to compare against gas-1.38 */
#ifdef OLD_GAS
#define REVERSE_SORT_RELOCS
#endif
#define tc_aout_pre_write_hook(x) {;} /* not used */
#define tc_crawl_symbol_chain(a) {;} /* not used */
#define tc_headers_hook(a) {;} /* not used */
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of tc-vax.h */

View File

@ -0,0 +1,8 @@
/* Machine specific defines for the dpx2 machine */
#define dpx2
#define TC_M68K
/* The magic number is not the usual MC68MAGIC. */
#define FILE_HEADER_MAGIC MC68KBCSMAGIC
/* end of te-dpx2.h */

View File

@ -0,0 +1,25 @@
/*
* This file is te-generic.h and is intended to be a template for
* target environment specific header files.
*
* It is my intent that this file will evolve into a file suitable for config,
* compile, and copying as an aid for testing and porting. xoxorich.
*/
/*
* $Id: te-generic.h,v 1.1 1993/10/02 20:59:49 pk Exp $
*/
#define TE_GENERIC 1
/* these define interfaces */
#include "obj-format.h"
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of te-generic.h */

View File

@ -0,0 +1,99 @@
/* Special version of <a.out.h> for use under hp-ux.
Copyright (C) 1988, 1992 Free Software Foundation, Inc.
This file is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this file; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define TE_HPUX
#define HP9000S200_ID (0x20C)
#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (HP9000S200_ID)
/* hpux has "special" headers. */
#define H_GET_HEADER_SIZE(h) (64)
#include "obj-format.h"
/* This stuff is from an old a.out.hpux.h. It isn't used anymore,
(see obj-aout.c, obj_header_append) but I'm including it here for
context. xoxorich. */
#if comment
/* The `exec' structure and overall layout must be close to HP's when
we are running on an HP system, otherwise we will not be able to
execute the resulting file. */
/* Allow this file to be included twice. */
#ifndef __GNU_EXEC_MACROS__
struct exec
{
unsigned short a_machtype; /* machine type */
unsigned short a_info; /* magic number */
unsigned long a_spare1;
unsigned long a_spare2;
unsigned long a_text; /* length of text, in bytes */
unsigned long a_data; /* length of data, in bytes */
unsigned long a_bss; /* length of uninitialized data area for file, in bytes */
unsigned long a_trsize; /* length of relocation info for text, in bytes */
unsigned long a_drsize; /* length of relocation info for data, in bytes */
unsigned long a_spare3; /* HP = pascal interface size */
unsigned long a_spare4; /* HP = symbol table size */
unsigned long a_spare5; /* HP = debug name table size */
unsigned long a_entry; /* start address */
unsigned long a_spare6; /* HP = source line table size */
unsigned long a_spare7; /* HP = value table size */
unsigned long a_syms; /* length of symbol table data in file, in bytes */
unsigned long a_spare8;
};
/* Tell a.out.gnu.h not to define `struct exec'. */
#define __STRUCT_EXEC_OVERRIDE__
#include "a.out.gnu.h"
#undef N_MAGIC
#undef N_MACHTYPE
#undef N_FLAGS
#undef N_SET_INFO
#undef N_SET_MAGIC
#undef N_SET_MACHTYPE
#undef N_SET_FLAGS
#define N_MAGIC(exec) ((exec) . a_magic)
#define N_MACHTYPE(exec) ((exec) . a_machtype)
#define N_SET_MAGIC(exec, magic) (((exec) . a_magic) = (magic))
#define N_SET_MACHTYPE(exec, machtype) (((exec) . a_machtype) = (machtype))
#undef N_BADMAG
#define N_BADMAG(x) ((_N_BADMAG (x)) || (_N_BADMACH (x)))
#define _N_BADMACH(x) \
(((N_MACHTYPE (x)) != HP9000S200_ID) && \
((N_MACHTYPE (x)) != HP98x6_ID))
#define HP98x6_ID 0x20A
#define HP9000S200_ID 0x20C
#undef _N_HDROFF
#define _N_HDROFF(x) (SEGMENT_SIZE - (sizeof (struct exec)))
#define SEGMENT_SIZE 0x1000
#endif /* __GNU_EXEC_MACROS__ */
#endif /* comment */
/* end of te-hpux.h */

View File

@ -0,0 +1,19 @@
/*
* This file is te-i386aix.h and is built from pieces of code from Minh Tran-Le
* <TRANLE@INTELLICORP.COM> by rich@cygnus.com.
*/
#define TE_I386AIX 1
#include "obj-format.h"
#define KEEP_RELOC_INFO
/*
* Local Variables:
* comment-column: 0
* fill-column: 79
* End:
*/
/* end of te-i386aix.h */

View File

@ -0,0 +1,46 @@
/* This file is twe-ic960.h
Copyright (C) 1987-1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* This file is te-ic960.h and is intended to define ic960 environment
* specific differences.
*/
#define TE_IC960 1
/* intel uses host byte order for headers */
#ifdef CROSS_COMPILE
#undef CROSS_COMPILE
#endif /* CROSS_COMPILE */
#define OBJ_COFF_OMIT_OPTIONAL_HEADER
#define LOCAL_LABEL(name) ( (name[0] == 'L') \
|| (name[0] == '.' \
&& (name[1] == 'C' || name[1] == 'I' || name[1] == '.')))
#include "obj-format.h"
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of te-ic960.h */

View File

@ -0,0 +1,7 @@
/* Machine specific defines for the SCO Unix V.3.2 ODT */
#define scounix
/* Return true if s (a non null string pointer), points to a local variable name. */
#define LOCAL_LABEL(n) ((n)[0] == '.' && (n)[1] == 'L')
/* end of te-sco386.h */

View File

@ -0,0 +1,32 @@
/*
* This file is te-sequent.h and is intended to set up emulation with
* sequent's development tools.
*
*/
#define TE_SEQUENT 1
/* sequent has a "special" header. */
#define H_GET_HEADER_SIZE(h) (128)
#ifdef TC_I386
/* zmagic is 0x22eb */
#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (0x12eb)
#endif /* TC_I386 */
#ifdef TC_NS32K
/* zmagic is 0x10ea */
#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (0x00ea)
#endif /* TC_NS32K */
/* these define interfaces */
#include "obj-format.h"
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of te-sequent.h */

View File

@ -0,0 +1,49 @@
/* te-sun3.h -- Sun-3 target environment declarations.
Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* This header file contains the #defines specific
to SUN computer SUN 3 series computers. (The only kind
we have around here, unfortunatly.)
Rumor has it that this file will work on the Sun-2 if the assembler
is called with -m68010 This is not tested. */
/* Could also be :
#define S_LOCAL_NAME(s) (S_GET_NAME(s)[0] == '.' &&
S_GET_NAME(s)[1] == 'L' ||
S_GET_NAME(s)[1] == '.')
*/
/* This variable contains the value to write out at the beginning of
the a.out file. The 2<<16 means that this is a 68020 file instead
of an old-style 68000 file */
#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (2<<16|OMAGIC) /* Magic byte for file header */
#include "obj-format.h"
/*
* Local Variables:
* comment-column: 0
* fill-column: 131
* End:
*/
/* end of te-sun3.h */

View File

@ -0,0 +1,4 @@
/* Remove leading underscore from the gcc generated symbol names */
#define STRIP_UNDERSCORE
/* end of te-sysv32.h */

View File

@ -1,24 +1,21 @@
/* vax-inst.h - GNU - Part of vax.c
Copyright (C) 1987 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: vax-inst.h,v 1.2 1993/08/02 17:27:27 mycroft Exp $
*/
Copyright (C) 1987, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* This is part of vax-ins-parse.c & friends.
@ -26,35 +23,35 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define VIT_MAX_OPERANDS (6) /* maximum number of operands in one */
/* single vax instruction */
/* single vax instruction */
struct vop /* vax instruction operand */
{
short int vop_ndx; /* -1, or index register. eg 7=[R7] */
short int vop_reg; /* -1, or register number. eg @I^#=0xF */
/* Helps distinguish "abs" from "abs(PC)". */
short int vop_mode; /* addressing mode 4 bits. eg I^#=0x9 */
char vop_short; /* operand displacement length as written */
/* ' '=none, "bilsw"=B^I^L^S^W^. */
char vop_access; /* 'b'branch ' 'no-instruction 'amrvw'norm */
char vop_width; /* Operand width, one of "bdfghloqw" */
char * vop_warn; /* warning message of this operand, if any */
char * vop_error; /* say if operand is inappropriate */
char * vop_expr_begin; /* Unparsed expression, 1st char ... */
char * vop_expr_end; /* ... last char. */
unsigned char vop_nbytes; /* number of bytes in datum */
short int vop_ndx; /* -1, or index register. eg 7=[R7] */
short int vop_reg; /* -1, or register number. eg @I^#=0xF */
/* Helps distinguish "abs" from "abs(PC)". */
short int vop_mode; /* addressing mode 4 bits. eg I^#=0x9 */
char vop_short; /* operand displacement length as written */
/* ' '=none, "bilsw"=B^I^L^S^W^. */
char vop_access; /* 'b'branch ' 'no-instruction 'amrvw'norm */
char vop_width; /* Operand width, one of "bdfghloqw" */
char *vop_warn; /* warning message of this operand, if any */
char *vop_error; /* say if operand is inappropriate */
char *vop_expr_begin; /* Unparsed expression, 1st char ... */
char *vop_expr_end; /* ... last char. */
unsigned char vop_nbytes; /* number of bytes in datum */
};
typedef long int vax_opcodeT; /* For initialising array of opcodes */
/* Some synthetic opcodes > 16 bits! */
typedef long vax_opcodeT; /* For initialising array of opcodes */
/* Some synthetic opcodes > 16 bits! */
#define VIT_OPCODE_SYNTHETIC 0x80000000 /* Not real hardware instruction. */
#define VIT_OPCODE_SPECIAL 0x40000000 /* Not normal branch optimising. */
/* Never set without ..._SYNTHETIC */
/* Never set without ..._SYNTHETIC */
#define VAX_WIDTH_UNCONDITIONAL_JUMP '-' /* These are encoded into */
#define VAX_WIDTH_CONDITIONAL_JUMP '?' /* vop_width when vop_access=='b' */
#define VAX_WIDTH_CONDITIONAL_JUMP '?' /* vop_width when vop_access == 'b' */
#define VAX_WIDTH_WORD_JUMP '!' /* and VIT_OPCODE_SYNTHETIC set. */
#define VAX_WIDTH_BYTE_JUMP ':' /* */
@ -65,16 +62,16 @@ typedef long int vax_opcodeT; /* For initialising array of opcodes */
#define VAX_BRW (0x31) /* Another canonical branch */
#define VAX_WIDEN_WORD (0x20) /* Add this to byte branch to get word br. */
#define VAX_WIDEN_LONG (0x6) /* Add this to byte branch to get long jmp.*/
/* Needs VAX_PC_RELATIVE_MODE byte after it*/
/* Needs VAX_PC_RELATIVE_MODE byte after it*/
struct vit /* vax instruction tree */
{
/* vit_opcode is char[] for portability. */
char vit_opcode [ sizeof (vax_opcodeT) ];
unsigned char vit_opcode_nbytes; /* How long is _opcode? (chars) */
unsigned char vit_operands;/* */
struct vop vit_operand[VIT_MAX_OPERANDS]; /* operands */
char * vit_error; /* "" or error text */
/* vit_opcode is char[] for portability. */
char vit_opcode[ sizeof (vax_opcodeT) ];
unsigned char vit_opcode_nbytes; /* How long is _opcode? (chars) */
unsigned char vit_operands;/* */
struct vop vit_operand[VIT_MAX_OPERANDS]; /* operands */
char * vit_error; /* "" or error text */
};
/* end: vax-inst.h */
/* end of vax-inst.h */