diff options
Diffstat (limited to 'gas/config')
92 files changed, 61 insertions, 15582 deletions
diff --git a/gas/config/aout_gnu.h b/gas/config/aout_gnu.h index 091b2de..e17fda9 100644 --- a/gas/config/aout_gnu.h +++ b/gas/config/aout_gnu.h @@ -26,15 +26,15 @@ relocations, and one which uses extended relocations. Today, the extended reloc uses are - TC_SPARC, TC_A29K + TC_SPARC each must define the enum reloc_type */ -#define USE_EXTENDED_RELOC (defined(TC_SPARC) || defined(TC_A29K)) +#define USE_EXTENDED_RELOC defined(TC_SPARC) -#if defined(TC_SPARC) || defined(TC_A29K) +#if defined(TC_SPARC) enum reloc_type { RELOC_8, RELOC_16, RELOC_32,/* simple relocations */ @@ -62,7 +62,7 @@ enum reloc_type NO_RELOC }; -#endif /* TC_SPARC or TC_A29K */ +#endif /* TC_SPARC */ #define __GNU_EXEC_MACROS__ diff --git a/gas/config/atof-tahoe.c b/gas/config/atof-tahoe.c deleted file mode 100644 index 6345cf7..0000000 --- a/gas/config/atof-tahoe.c +++ /dev/null @@ -1,415 +0,0 @@ -/* atof_tahoe.c - turn a string into a Tahoe floating point number - Copyright 1987, 1993, 2000, 2003 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? Devon E Bowen <bowen@cs.buffalo.edu> - - I don't allow uppercase letters in the precision descriptors. - i.e. '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; -{ - /* Floating Reserved Operand Code. */ - *words = 0x8000; -} - -static int /* 0 means letter is OK. */ -what_kind_of_float (letter, precisionP, exponent_bitsP) - /* In: lowercase please. What kind of float? */ - char letter; - - /* Number of 16-bit words in the float. */ - int *precisionP; - - /* Number of exponent bits. */ - long int *exponent_bitsP; -{ - 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)) - { - /* We lost. */ - return_value = NULL; - 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); - /* We lost. */ - return_value = NULL; - } - 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; -} - -/* 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 0. - * 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 ? 0 : _("Bad call to md_atof()"); -} diff --git a/gas/config/m88k-opcode.h b/gas/config/m88k-opcode.h deleted file mode 100644 index b9a3c93..0000000 --- a/gas/config/m88k-opcode.h +++ /dev/null @@ -1,559 +0,0 @@ -/* m88k-opcode.h -- Instruction information for the Motorola 88000 - Contributed by Devon Bowen of Buffalo University - and Torbjorn Granlund of the Swedish Institute of Computer Science. - Copyright 1989, 1990, 1991, 1993, 2000 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, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ - -#if !defined(__STDC__) && !defined(const) -#define const -#endif - -/* - Character codes for op_spec field below. - Reserved for self-matching: [ ] , - - d = GRF Destination register (21:5) - x = XRF register prefix. Makes next d, 1, or 2, match an extended register. - 1 = Source register 1 (16:5) - 2 = Source register 2 (0:5) - 3 = Both source registers (same value) (0:5 and 16:5) - I = IMM16 (0:16) - b = bit field spec. (0:10) - p = 16 bit pc displ. (0:16) - P = 26 bit pc displ. (0:26) - B = bb0/bb1 condition (21:5) - M = bcnd condition (21:5) - f = fcr (5:6) - c = cr (5:6) - V = VEC9 (0:9) - o = O6 field of "prot" insn (10:7) - ? = Give warning for this insn/operand combination - */ - -/* instruction descriptor structure */ - -struct m88k_opcode -{ - unsigned int opcode; - char *name; - char *op_spec; -}; - -/* and introducing... the Motorola 88100 and 88110 instruction sets... */ - -/* By default, include the 88110 instructions. */ -#define MC88110 - -#if defined (MC88110) -#define _MC88100(OPCODE,MNEM,OP_SPEC) -#define _MC88110(OPCODE,MNEM,OP_SPEC) {OPCODE,MNEM,OP_SPEC}, -#else -#define _MC88100(OPCODE,MNEM,OP_SPEC) {OPCODE,MNEM,OP_SPEC}, -#define _MC88110(OPCODE,MNEM,OP_SPEC) -#endif - -#define _MC88xxx(OPCODE,MNEM,OP_SPEC) {OPCODE,MNEM,OP_SPEC}, - -/* Equal mnemonics must be adjacent. - More specific operand specification must go before more general. - For example, "d,1,2" must go before "d,1,I" as a register for s2 - would otherwise be considered a variable name. */ - -static struct m88k_opcode m88k_opcodes[] = -{ - /* Opcode Mnemonic Opspec */ - - _MC88xxx (0xf4007000, "add", "d,1,2") - _MC88xxx (0x70000000, "add", "d,1,I") - _MC88xxx (0xf4007200, "add.ci", "d,1,2") - _MC88xxx (0xf4007300, "add.cio", "d,1,2") - _MC88xxx (0xf4007100, "add.co", "d,1,2") - _MC88xxx (0xf4006000, "addu", "d,1,2") - _MC88xxx (0x60000000, "addu", "d,1,I") - _MC88xxx (0xf4006200, "addu.ci", "d,1,2") - _MC88xxx (0xf4006300, "addu.cio", "d,1,2") - _MC88xxx (0xf4006100, "addu.co", "d,1,2") - _MC88xxx (0xf4004000, "and", "d,1,2") - _MC88xxx (0x40000000, "and", "d,1,I") - _MC88xxx (0xf4004400, "and.c", "d,1,2") - _MC88xxx (0x44000000, "and.u", "d,1,I") - _MC88xxx (0xd0000000, "bb0", "B,1,p") - _MC88xxx (0xd4000000, "bb0.n", "B,1,p") - _MC88xxx (0xd8000000, "bb1", "B,1,p") - _MC88xxx (0xdc000000, "bb1.n", "B,1,p") - _MC88xxx (0xe8000000, "bcnd", "M,1,p") - _MC88xxx (0xec000000, "bcnd.n", "M,1,p") - _MC88xxx (0xc0000000, "br", "P") - _MC88xxx (0xc4000000, "br.n", "P") - _MC88xxx (0xc8000000, "bsr", "P") - _MC88xxx (0xcc000000, "bsr.n", "P") - _MC88xxx (0xf4008000, "clr", "d,1,2") - _MC88xxx (0xf0008000, "clr", "d,1,b") - _MC88xxx (0xf4007c00, "cmp", "d,1,2") - _MC88xxx (0x7c000000, "cmp", "d,1,I") - _MC88xxx (0xf4007800, "div", "d,1,2") - _MC88xxx (0x78000000, "div", "d,1,I") - _MC88xxx (0xf4007800, "divs", "d,1,2") - _MC88xxx (0x78000000, "divs", "d,1,I") - _MC88110 (0xf4006900, "divu.d", "d,1,2") - _MC88xxx (0xf4006800, "divu", "d,1,2") - _MC88xxx (0x68000000, "divu", "d,1,I") - _MC88xxx (0xf4009000, "ext", "d,1,2") - _MC88xxx (0xf0009000, "ext", "d,1,b") - _MC88xxx (0xf4009800, "extu", "d,1,2") - _MC88xxx (0xf0009800, "extu", "d,1,b") - _MC88xxx (0x84002800, "fadd.sss", "d,1,2") - _MC88110 (0x8400a800, "fadd.sss", "xd,x1,x2") - _MC88xxx (0x84002880, "fadd.ssd", "d,1,2") - _MC88110 (0x8400a820, "fadd.ssd", "xd,x1,x2") - _MC88110 (0x8400a840, "fadd.ssx", "xd,x1,x2") - _MC88xxx (0x84002a00, "fadd.sds", "d,1,2") - _MC88110 (0x8400a880, "fadd.sds", "xd,x1,x2") - _MC88xxx (0x84002a80, "fadd.sdd", "d,1,2") - _MC88110 (0x8400a8a0, "fadd.sdd", "xd,x1,x2") - _MC88110 (0x8400a8c0, "fadd.sdx", "xd,x1,x2") - _MC88110 (0x8400a900, "fadd.sxs", "xd,x1,x2") - _MC88110 (0x8400a920, "fadd.sxd", "xd,x1,x2") - _MC88110 (0x8400a940, "fadd.sxx", "xd,x1,x2") - _MC88xxx (0x84002820, "fadd.dss", "d,1,2") - _MC88110 (0x8400aa00, "fadd.dss", "xd,x1,x2") - _MC88xxx (0x840028a0, "fadd.dsd", "d,1,2") - _MC88110 (0x8400aa20, "fadd.dsd", "xd,x1,x2") - _MC88110 (0x8400aa40, "fadd.dsx", "xd,x1,x2") - _MC88xxx (0x84002a20, "fadd.dds", "d,1,2") - _MC88110 (0x8400aa80, "fadd.dds", "xd,x1,x2") - _MC88xxx (0x84002aa0, "fadd.ddd", "d,1,2") - _MC88110 (0x8400aaa0, "fadd.ddd", "xd,x1,x2") - _MC88110 (0x8400aac0, "fadd.ddx", "xd,x1,x2") - _MC88110 (0x8400ab00, "fadd.dxs", "xd,x1,x2") - _MC88110 (0x8400ab20, "fadd.dxd", "xd,x1,x2") - _MC88110 (0x8400ab40, "fadd.dxx", "xd,x1,x2") - _MC88110 (0x8400ac00, "fadd.xss", "xd,x1,x2") - _MC88110 (0x8400ac20, "fadd.xsd", "xd,x1,x2") - _MC88110 (0x8400ac40, "fadd.xsx", "xd,x1,x2") - _MC88110 (0x8400ac80, "fadd.xds", "xd,x1,x2") - _MC88110 (0x8400aca0, "fadd.xdd", "xd,x1,x2") - _MC88110 (0x8400acc0, "fadd.xdx", "xd,x1,x2") - _MC88110 (0x8400ad00, "fadd.xxs", "xd,x1,x2") - _MC88110 (0x8400ad20, "fadd.xxd", "xd,x1,x2") - _MC88110 (0x8400ad40, "fadd.xxx", "xd,x1,x2") - _MC88xxx (0x84003a80, "fcmp.sdd", "d,1,2") - _MC88110 (0x8400ba80, "fcmp.sdd", "d,x1,x2") - _MC88xxx (0x84003a00, "fcmp.sds", "d,1,2") - _MC88110 (0x8400ba00, "fcmp.sds", "d,x1,x2") - _MC88110 (0x8400bb00, "fcmp.sdx", "d,x1,x2") - _MC88xxx (0x84003880, "fcmp.ssd", "d,1,2") - _MC88110 (0x8400b880, "fcmp.ssd", "d,x1,x2") - _MC88xxx (0x84003800, "fcmp.sss", "d,1,2") - _MC88110 (0x8400b800, "fcmp.sss", "d,x1,x2") - _MC88110 (0x8400b900, "fcmp.ssx", "d,x1,x2") - _MC88110 (0x8400bc80, "fcmp.sxd", "d,x1,x2") - _MC88110 (0x8400bc00, "fcmp.sxs", "d,x1,x2") - _MC88110 (0x8400bd00, "fcmp.sxx", "d,x1,x2") - _MC88110 (0x84003aa0, "fcmpu.sdd", "d,1,2") - _MC88110 (0x8400baa0, "fcmpu.sdd", "d,x1,x2") - _MC88110 (0x84003a20, "fcmpu.sds", "d,1,2") - _MC88110 (0x8400ba20, "fcmpu.sds", "d,x1,x2") - _MC88110 (0x8400bb20, "fcmpu.sdx", "d,x1,x2") - _MC88110 (0x840038a0, "fcmpu.ssd", "d,1,2") - _MC88110 (0x8400b8a0, "fcmpu.ssd", "d,x1,x2") - _MC88110 (0x84003820, "fcmpu.sss", "d,1,2") - _MC88110 (0x8400b820, "fcmpu.sss", "d,x1,x2") - _MC88110 (0x8400b920, "fcmpu.ssx", "d,x1,x2") - _MC88110 (0x8400bca0, "fcmpu.sxd", "d,x1,x2") - _MC88110 (0x8400bc20, "fcmpu.sxs", "d,x1,x2") - _MC88110 (0x8400bd20, "fcmpu.sxx", "d,x1,x2") - _MC88110 (0x84000880, "fcvt.ds", "d,2") - _MC88110 (0x84008880, "fcvt.ds", "xd,x2") - _MC88110 (0x840088c0, "fcvt.dx", "xd,x2") - _MC88110 (0x84000820, "fcvt.sd", "d,2") - _MC88110 (0x84008820, "fcvt.sd", "xd,x2") - _MC88110 (0x84008840, "fcvt.sx", "xd,x2") - _MC88110 (0x84008920, "fcvt.xd", "xd,x2") - _MC88110 (0x84008900, "fcvt.xs", "xd,x2") - _MC88xxx (0x84007000, "fdiv.sss", "d,1,2") - _MC88110 (0x8400f000, "fdiv.sss", "xd,x1,x2") - _MC88xxx (0x84007080, "fdiv.ssd", "d,1,2") - _MC88110 (0x8400f020, "fdiv.ssd", "xd,x1,x2") - _MC88110 (0x8400f040, "fdiv.ssx", "xd,x1,x2") - _MC88xxx (0x84007200, "fdiv.sds", "d,1,2") - _MC88110 (0x8400f080, "fdiv.sds", "xd,x1,x2") - _MC88xxx (0x84007280, "fdiv.sdd", "d,1,2") - _MC88110 (0x8400f0a0, "fdiv.sdd", "xd,x1,x2") - _MC88110 (0x8400f0c0, "fdiv.sdx", "xd,x1,x2") - _MC88110 (0x8400f100, "fdiv.sxs", "xd,x1,x2") - _MC88110 (0x8400f120, "fdiv.sxd", "xd,x1,x2") - _MC88110 (0x8400f140, "fdiv.sxx", "xd,x1,x2") - _MC88xxx (0x84007020, "fdiv.dss", "d,1,2") - _MC88110 (0x8400f200, "fdiv.dss", "xd,x1,x2") - _MC88xxx (0x840070a0, "fdiv.dsd", "d,1,2") - _MC88110 (0x8400f220, "fdiv.dsd", "xd,x1,x2") - _MC88110 (0x8400f240, "fdiv.dsx", "xd,x1,x2") - _MC88xxx (0x84007220, "fdiv.dds", "d,1,2") - _MC88110 (0x8400f280, "fdiv.dds", "xd,x1,x2") - _MC88xxx (0x840072a0, "fdiv.ddd", "d,1,2") - _MC88110 (0x8400f2a0, "fdiv.ddd", "xd,x1,x2") - _MC88110 (0x8400f2c0, "fdiv.ddx", "xd,x1,x2") - _MC88110 (0x8400f300, "fdiv.dxs", "xd,x1,x2") - _MC88110 (0x8400f320, "fdiv.dxd", "xd,x1,x2") - _MC88110 (0x8400f340, "fdiv.dxx", "xd,x1,x2") - _MC88110 (0x8400f400, "fdiv.xss", "xd,x1,x2") - _MC88110 (0x8400f420, "fdiv.xsd", "xd,x1,x2") - _MC88110 (0x8400f440, "fdiv.xsx", "xd,x1,x2") - _MC88110 (0x8400f480, "fdiv.xds", "xd,x1,x2") - _MC88110 (0x8400f4a0, "fdiv.xdd", "xd,x1,x2") - _MC88110 (0x8400f4c0, "fdiv.xdx", "xd,x1,x2") - _MC88110 (0x8400f500, "fdiv.xxs", "xd,x1,x2") - _MC88110 (0x8400f520, "fdiv.xxd", "xd,x1,x2") - _MC88110 (0x8400f540, "fdiv.xxx", "xd,x1,x2") - _MC88xxx (0xf400ec00, "ff0", "d,2") - _MC88xxx (0xf400e800, "ff1", "d,2") - _MC88xxx (0x80004800, "fldcr", "d,f") - _MC88xxx (0x84002020, "flt.ds", "d,2") - _MC88110 (0x84002220, "flt.ds", "xd,2") - _MC88xxx (0x84002000, "flt.ss", "d,2") - _MC88110 (0x84002200, "flt.ss", "xd,2") - _MC88110 (0x84002240, "flt.xs", "xd,2") - _MC88xxx (0x84000000, "fmul.sss", "d,1,2") - _MC88110 (0x84008000, "fmul.sss", "xd,x1,x2") - _MC88xxx (0x84000080, "fmul.ssd", "d,1,2") - _MC88110 (0x84008020, "fmul.ssd", "xd,x1,x2") - _MC88110 (0x84008040, "fmul.ssx", "xd,x1,x2") - _MC88xxx (0x84000200, "fmul.sds", "d,1,2") - _MC88110 (0x84008080, "fmul.sds", "xd,x1,x2") - _MC88xxx (0x84000280, "fmul.sdd", "d,1,2") - _MC88110 (0x840080a0, "fmul.sdd", "xd,x1,x2") - _MC88110 (0x840080c0, "fmul.sdx", "xd,x1,x2") - _MC88110 (0x84008100, "fmul.sxs", "xd,x1,x2") - _MC88110 (0x84008120, "fmul.sxd", "xd,x1,x2") - _MC88110 (0x84008140, "fmul.sxx", "xd,x1,x2") - _MC88xxx (0x84000020, "fmul.dss", "d,1,2") - _MC88110 (0x84008200, "fmul.dss", "xd,x1,x2") - _MC88xxx (0x840000a0, "fmul.dsd", "d,1,2") - _MC88110 (0x84008220, "fmul.dsd", "xd,x1,x2") - _MC88110 (0x84008240, "fmul.dsx", "xd,x1,x2") - _MC88xxx (0x84000220, "fmul.dds", "d,1,2") - _MC88110 (0x84008280, "fmul.dds", "xd,x1,x2") - _MC88xxx (0x840002a0, "fmul.ddd", "d,1,2") - _MC88110 (0x840082a0, "fmul.ddd", "xd,x1,x2") - _MC88110 (0x840082c0, "fmul.ddx", "xd,x1,x2") - _MC88110 (0x84008300, "fmul.dxs", "xd,x1,x2") - _MC88110 (0x84008320, "fmul.dxd", "xd,x1,x2") - _MC88110 (0x84008340, "fmul.dxx", "xd,x1,x2") - _MC88110 (0x84008400, "fmul.xss", "xd,x1,x2") - _MC88110 (0x84008420, "fmul.xsd", "xd,x1,x2") - _MC88110 (0x84008440, "fmul.xsx", "xd,x1,x2") - _MC88110 (0x84008480, "fmul.xds", "xd,x1,x2") - _MC88110 (0x840084a0, "fmul.xdd", "xd,x1,x2") - _MC88110 (0x840084c0, "fmul.xdx", "xd,x1,x2") - _MC88110 (0x84008500, "fmul.xxs", "xd,x1,x2") - _MC88110 (0x84008520, "fmul.xxd", "xd,x1,x2") - _MC88110 (0x84008540, "fmul.xxx", "xd,x1,x2") - _MC88110 (0x840078a0, "fsqrt.dd", "d,2") - _MC88110 (0x8400f8a0, "fsqrt.dd", "xd,x2") - _MC88110 (0x84007880, "fsqrt.ds", "d,2") - _MC88110 (0x8400f880, "fsqrt.ds", "xd,x2") - _MC88110 (0x8400f8c0, "fsqrt.dx", "xd,x2") - _MC88110 (0x84007820, "fsqrt.sd", "d,2") - _MC88110 (0x8400f820, "fsqrt.sd", "xd,x2") - _MC88110 (0x84007800, "fsqrt.ss", "d,2") - _MC88110 (0x8400f800, "fsqrt.ss", "xd,x2") - _MC88110 (0x8400f840, "fsqrt.sx", "xd,x2") - _MC88110 (0x8400f920, "fsqrt.xd", "xd,x2") - _MC88110 (0x8400f900, "fsqrt.xs", "xd,x2") - _MC88110 (0x8400f940, "fsqrt.xx", "xd,x2") - _MC88xxx (0x80008800, "fstcr", "3,f") - _MC88xxx (0x84003000, "fsub.sss", "d,1,2") - _MC88110 (0x8400b000, "fsub.sss", "xd,x1,x2") - _MC88xxx (0x84003080, "fsub.ssd", "d,1,2") - _MC88110 (0x8400b020, "fsub.ssd", "xd,x1,x2") - _MC88110 (0x8400b040, "fsub.ssx", "xd,x1,x2") - _MC88xxx (0x84003200, "fsub.sds", "d,1,2") - _MC88110 (0x8400b080, "fsub.sds", "xd,x1,x2") - _MC88xxx (0x84003280, "fsub.sdd", "d,1,2") - _MC88110 (0x8400b0a0, "fsub.sdd", "xd,x1,x2") - _MC88110 (0x8400b0c0, "fsub.sdx", "xd,x1,x2") - _MC88110 (0x8400b100, "fsub.sxs", "xd,x1,x2") - _MC88110 (0x8400b120, "fsub.sxd", "xd,x1,x2") - _MC88110 (0x8400b140, "fsub.sxx", "xd,x1,x2") - _MC88xxx (0x84003020, "fsub.dss", "d,1,2") - _MC88110 (0x8400b200, "fsub.dss", "xd,x1,x2") - _MC88xxx (0x840030a0, "fsub.dsd", "d,1,2") - _MC88110 (0x8400b220, "fsub.dsd", "xd,x1,x2") - _MC88110 (0x8400b240, "fsub.dsx", "xd,x1,x2") - _MC88xxx (0x84003220, "fsub.dds", "d,1,2") - _MC88110 (0x8400b280, "fsub.dds", "xd,x1,x2") - _MC88xxx (0x840032a0, "fsub.ddd", "d,1,2") - _MC88110 (0x8400b2a0, "fsub.ddd", "xd,x1,x2") - _MC88110 (0x8400b2c0, "fsub.ddx", "xd,x1,x2") - _MC88110 (0x8400b300, "fsub.dxs", "xd,x1,x2") - _MC88110 (0x8400b320, "fsub.dxd", "xd,x1,x2") - _MC88110 (0x8400b340, "fsub.dxx", "xd,x1,x2") - _MC88110 (0x8400b400, "fsub.xss", "xd,x1,x2") - _MC88110 (0x8400b420, "fsub.xsd", "xd,x1,x2") - _MC88110 (0x8400b440, "fsub.xsx", "xd,x1,x2") - _MC88110 (0x8400b480, "fsub.xds", "xd,x1,x2") - _MC88110 (0x8400b4a0, "fsub.xdd", "xd,x1,x2") - _MC88110 (0x8400b4c0, "fsub.xdx", "xd,x1,x2") - _MC88110 (0x8400b500, "fsub.xxs", "xd,x1,x2") - _MC88110 (0x8400b520, "fsub.xxd", "xd,x1,x2") - _MC88110 (0x8400b540, "fsub.xxx", "xd,x1,x2") - _MC88xxx (0x8000c800, "fxcr", "d,3,f") - _MC88xxx (0x8400fc01, "illop1", "") - _MC88xxx (0x8400fc02, "illop2", "") - _MC88xxx (0x8400fc03, "illop3", "") - _MC88xxx (0x84004880, "int.sd", "d,2") - _MC88110 (0x8400c880, "int.sd", "d,x2") - _MC88xxx (0x84004800, "int.ss", "d,2") - _MC88110 (0x8400c800, "int.ss", "d,x2") - _MC88110 (0x8400c900, "int.sx", "d,x2") - _MC88xxx (0xf400c000, "jmp", "2") - _MC88xxx (0xf400c400, "jmp.n", "2") - _MC88xxx (0xf400c800, "jsr", "2") - _MC88xxx (0xf400cc00, "jsr.n", "2") - _MC88xxx (0xf4001400, "ld", "d,1,2") - _MC88xxx (0xf4001600, "ld", "d,1[2]") - _MC88xxx (0x14000000, "ld", "d,1,I") - _MC88110 (0xf0001600, "ld", "xd,1[2]") - _MC88110 (0xf0001400, "ld", "xd,1,2") - _MC88110 (0x04000000, "ld", "xd,1,I") - _MC88xxx (0xf4001e00, "ld.b", "d,1[2]") - _MC88xxx (0xf4001c00, "ld.b", "d,1,2") - _MC88xxx (0x1c000000, "ld.b", "d,1,I") - _MC88xxx (0xf4001d00, "ld.b.usr", "d,1,2") - _MC88xxx (0xf4001f00, "ld.b.usr", "d,1[2]") - _MC88xxx (0xf4000e00, "ld.bu", "d,1[2]") - _MC88xxx (0xf4000c00, "ld.bu", "d,1,2") - _MC88xxx (0x0c000000, "ld.bu", "d,1,I") - _MC88xxx (0xf4000d00, "ld.bu.usr", "d,1,2") - _MC88xxx (0xf4000f00, "ld.bu.usr", "d,1[2]") - _MC88xxx (0xf4001200, "ld.d", "d,1[2]") - _MC88xxx (0xf4001000, "ld.d", "d,1,2") - _MC88xxx (0x10000000, "ld.d", "d,1,I") - _MC88110 (0xf0001200, "ld.d", "xd,1[2]") - _MC88110 (0xf0001000, "ld.d", "xd,1,2") - _MC88110 (0x00000000, "ld.d", "xd,1,I") - _MC88xxx (0xf4001100, "ld.d.usr", "d,1,2") - _MC88xxx (0xf4001300, "ld.d.usr", "d,1[2]") - _MC88110 (0xf0001100, "ld.d.usr", "xd,1,2") - _MC88110 (0xf0001300, "ld.d.usr", "xd,1[2]") - _MC88xxx (0xf4001a00, "ld.h", "d,1[2]") - _MC88xxx (0xf4001800, "ld.h", "d,1,2") - _MC88xxx (0x18000000, "ld.h", "d,1,I") - _MC88xxx (0xf4001900, "ld.h.usr", "d,1,2") - _MC88xxx (0xf4001b00, "ld.h.usr", "d,1[2]") - _MC88xxx (0xf4000a00, "ld.hu", "d,1[2]") - _MC88xxx (0xf4000800, "ld.hu", "d,1,2") - _MC88xxx (0x08000000, "ld.hu", "d,1,I") - _MC88xxx (0xf4000900, "ld.hu.usr", "d,1,2") - _MC88xxx (0xf4000b00, "ld.hu.usr", "d,1[2]") - _MC88xxx (0xf4001500, "ld.usr", "d,1,2") - _MC88xxx (0xf4001700, "ld.usr", "d,1[2]") - _MC88110 (0xf0001500, "ld.usr", "xd,1,2") - _MC88110 (0xf0001700, "ld.usr", "xd,1[2]") - _MC88110 (0xf0001a00, "ld.x", "xd,1[2]") - _MC88110 (0xf0001800, "ld.x", "xd,1,2") - _MC88110 (0x3c000000, "ld.x", "xd,1,I") - _MC88110 (0xf0001900, "ld.x.usr", "xd,1,2") - _MC88110 (0xf0001b00, "ld.x.usr", "xd,1[2]") - _MC88xxx (0xf4003600, "lda", "d,1[2]") - _MC88xxx (0xf4006000, "lda", "?d,1,2") /* Output addu */ - _MC88xxx (0x60000000, "lda", "?d,1,I") /* Output addu */ - _MC88xxx (0xf4006000, "lda.b", "?d,1[2]") /* Output addu */ - _MC88xxx (0xf4006000, "lda.b", "?d,1,2") /* Output addu */ - _MC88xxx (0x60000000, "lda.b", "?d,1,I") /* Output addu */ - _MC88xxx (0xf4003200, "lda.d", "d,1[2]") - _MC88xxx (0xf4006000, "lda.d", "?d,1,2") /* Output addu */ - _MC88xxx (0x60000000, "lda.d", "?d,1,I") /* Output addu */ - _MC88110 (0xf4003e00, "lda.x", "d,1[2]") - _MC88xxx (0xf4003a00, "lda.h", "d,1[2]") - _MC88xxx (0xf4006000, "lda.h", "?d,1,2") /* Output addu */ - _MC88xxx (0x60000000, "lda.h", "?d,1,I") /* Output addu */ - _MC88xxx (0x80004000, "ldcr", "d,c") - _MC88xxx (0xf400a000, "mak", "d,1,2") - _MC88xxx (0xf000a000, "mak", "d,1,b") - _MC88xxx (0x48000000, "mask", "d,1,I") - _MC88xxx (0x4c000000, "mask.u", "d,1,I") - _MC88110 (0x8400c000, "mov.s", "d,x2") - _MC88110 (0x84004200, "mov.s", "xd,2") - _MC88110 (0x8400c080, "mov.d", "d,x2") - _MC88110 (0x84004280, "mov.d", "xd,2") - _MC88110 (0x8400c300, "mov", "xd,x2") - _MC88xxx (0xf4006c00, "mul", "d,1,2") - _MC88xxx (0x6c000000, "mul", "d,1,I") - _MC88xxx (0xf4006e00, "muls", "d,1,2") - _MC88xxx (0x6c000000, "muls", "d,1,I") - _MC88xxx (0xf4006c00, "mulu", "d,1,2") /* synonym for mul */ - _MC88xxx (0x6c000000, "mulu", "d,1,I") /* synonym for mul */ - _MC88110 (0xf4006d00, "mulu.d", "d,1,2") - _MC88xxx (0x84005080, "nint.sd", "d,2") - _MC88110 (0x8400d080, "nint.sd", "d,x2") - _MC88xxx (0x84005000, "nint.ss", "d,2") - _MC88110 (0x8400d000, "nint.ss", "d,x2") - _MC88110 (0x8400d100, "nint.sx", "d,x2") - _MC88xxx (0xf4005800, "or", "d,1,2") - _MC88xxx (0x58000000, "or", "d,1,I") - _MC88xxx (0xf4005c00, "or.c", "d,1,2") - _MC88xxx (0x5c000000, "or.u", "d,1,I") - _MC88110 (0x88002020, "padd.b", "d,1,2") - _MC88110 (0x88002040, "padd.h", "d,1,2") - _MC88110 (0x88002060, "padd", "d,1,2") - _MC88110 (0x880020a0, "padds.u.b", "d,1,2") - _MC88110 (0x880020c0, "padds.u.h", "d,1,2") - _MC88110 (0x880020e0, "padds.u", "d,1,2") - _MC88110 (0x88002120, "padds.us.b", "d,1,2") - _MC88110 (0x88002140, "padds.us.h", "d,1,2") - _MC88110 (0x88002160, "padds.us", "d,1,2") - _MC88110 (0x880021a0, "padds.s.b", "d,1,2") - _MC88110 (0x880021c0, "padds.s.h", "d,1,2") - _MC88110 (0x880021e0, "padds.s", "d,1,2") - _MC88110 (0x88003860, "pcmp", "d,1,2") - _MC88110 (0x88000000, "pmul", "d,1,2") - _MC88110 (0x88006420, "ppack.32.b", "d,1,2") - _MC88110 (0x88006240, "ppack.16.h", "d,1,2") - _MC88110 (0x88006440, "ppack.32.h", "d,1,2") - _MC88110 (0x88006160, "ppack.8", "d,1,2") - _MC88110 (0x88006260, "ppack.16", "d,1,2") - _MC88110 (0x88006460, "ppack.32", "d,1,2") - _MC88110 (0x88007800, "prot", "d,1,2") - _MC88110 (0x88007000, "prot", "d,1,o") - _MC88110 (0x88003020, "psub.b", "d,1,2") - _MC88110 (0x88003040, "psub.h", "d,1,2") - _MC88110 (0x88003060, "psub", "d,1,2") - _MC88110 (0x880030a0, "psubs.u.b", "d,1,2") - _MC88110 (0x880030c0, "psubs.u.h", "d,1,2") - _MC88110 (0x880030e0, "psubs.u", "d,1,2") - _MC88110 (0x88003120, "psubs.us.b", "d,1,2") - _MC88110 (0x88003140, "psubs.us.h", "d,1,2") - _MC88110 (0x88003160, "psubs.us", "d,1,2") - _MC88110 (0x880031a0, "psubs.s.b", "d,1,2") - _MC88110 (0x880031c0, "psubs.s.h", "d,1,2") - _MC88110 (0x880031e0, "psubs.s", "d,1,2") - _MC88110 (0x88006800, "punpk.n", "d,1") - _MC88110 (0x88006820, "punpk.b", "d,1") - _MC88110 (0x88006840, "punpk.h", "d,1") - _MC88xxx (0xf400a800, "rot", "d,1,2") - _MC88xxx (0xf000a800, "rot", "d,1,b") - _MC88xxx (0xf400fc00, "rte", "") - _MC88xxx (0xf4008800, "set", "d,1,2") - _MC88xxx (0xf0008800, "set", "d,1,b") - _MC88xxx (0xf4002600, "st", "d,1[2]") - _MC88xxx (0xf4002400, "st", "d,1,2") - _MC88xxx (0x24000000, "st", "d,1,I") - _MC88110 (0xf0002600, "st", "xd,1[2]") - _MC88110 (0xf0002400, "st", "xd,1,2") - _MC88110 (0x34000000, "st", "xd,1,I") - _MC88xxx (0xf4002e00, "st.b", "d,1[2]") - _MC88xxx (0xf4002c00, "st.b", "d,1,2") - _MC88xxx (0x2c000000, "st.b", "d,1,I") - _MC88xxx (0xf4002d00, "st.b.usr", "d,1,2") - _MC88xxx (0xf4002f00, "st.b.usr", "d,1[2]") - _MC88110 (0xf4002d80, "st.b.usr.wt", "d,1,2") - _MC88110 (0xf4002f80, "st.b.usr.wt", "d,1[2]") - _MC88110 (0xf4002c80, "st.b.wt", "d,1,2") - _MC88110 (0xf4002e80, "st.b.wt", "d,1[2]") - _MC88xxx (0xf4002200, "st.d", "d,1[2]") - _MC88xxx (0xf4002000, "st.d", "d,1,2") - _MC88xxx (0x20000000, "st.d", "d,1,I") - _MC88110 (0xf0002200, "st.d", "xd,1[2]") - _MC88110 (0xf0002000, "st.d", "xd,1,2") - _MC88110 (0x30000000, "st.d", "xd,1,I") - _MC88xxx (0xf4002100, "st.d.usr", "d,1,2") - _MC88xxx (0xf4002300, "st.d.usr", "d,1[2]") - _MC88110 (0xf0002100, "st.d.usr", "xd,1,2") - _MC88110 (0xf0002300, "st.d.usr", "xd,1[2]") - _MC88110 (0xf4002180, "st.d.usr.wt", "d,1,2") - _MC88110 (0xf4002380, "st.d.usr.wt", "d,1[2]") - _MC88110 (0xf0002180, "st.d.usr.wt", "xd,1,2") - _MC88110 (0xf0002380, "st.d.usr.wt", "xd,1[2]") - _MC88110 (0xf4002080, "st.d.wt", "d,1,2") - _MC88110 (0xf4002280, "st.d.wt", "d,1[2]") - _MC88110 (0xf0002080, "st.d.wt", "xd,1,2") - _MC88110 (0xf0002280, "st.d.wt", "xd,1[2]") - _MC88xxx (0xf4002a00, "st.h", "d,1[2]") - _MC88xxx (0xf4002800, "st.h", "d,1,2") - _MC88xxx (0x28000000, "st.h", "d,1,I") - _MC88xxx (0xf4002900, "st.h.usr", "d,1,2") - _MC88xxx (0xf4002b00, "st.h.usr", "d,1[2]") - _MC88110 (0xf4002980, "st.h.usr.wt", "d,1,2") - _MC88110 (0xf4002b80, "st.h.usr.wt", "d,1[2]") - _MC88110 (0xf4002880, "st.h.wt", "d,1,2") - _MC88110 (0xf4002a80, "st.h.wt", "d,1[2]") - _MC88xxx (0xf4002500, "st.usr", "d,1,2") - _MC88xxx (0xf4002700, "st.usr", "d,1[2]") - _MC88110 (0xf0002500, "st.usr", "xd,1,2") - _MC88110 (0xf0002700, "st.usr", "xd,1[2]") - _MC88110 (0xf4002580, "st.usr.wt", "d,1,2") - _MC88110 (0xf4002780, "st.usr.wt", "d,1[2]") - _MC88110 (0xf0002580, "st.usr.wt", "xd,1,2") - _MC88110 (0xf0002780, "st.usr.wt", "xd,1[2]") - _MC88110 (0xf4002480, "st.wt", "d,1,2") - _MC88110 (0xf4002680, "st.wt", "d,1[2]") - _MC88110 (0xf0002480, "st.wt", "xd,1,2") - _MC88110 (0xf0002680, "st.wt", "xd,1[2]") - _MC88110 (0xf0002a00, "st.x", "xd,1[2]") - _MC88110 (0xf0002800, "st.x", "xd,1,2") - _MC88110 (0x38000000, "st.x", "xd,1,I") - _MC88110 (0xf0002900, "st.x.usr", "xd,1,2") - _MC88110 (0xf0002b00, "st.x.usr", "xd,1[2]") - _MC88110 (0xf0002980, "st.x.usr.wt", "xd,1,2") - _MC88110 (0xf0002b80, "st.x.usr.wt", "xd,1[2]") - _MC88110 (0xf0002880, "st.x.wt", "xd,1,2") - _MC88110 (0xf0002a80, "st.x.wt", "xd,1[2]") - _MC88xxx (0x80008000, "stcr", "3,c") - _MC88xxx (0xf4007400, "sub", "d,1,2") - _MC88xxx (0x74000000, "sub", "d,1,I") - _MC88xxx (0xf4007600, "sub.ci", "d,1,2") - _MC88xxx (0xf4007700, "sub.cio", "d,1,2") - _MC88xxx (0xf4007500, "sub.co", "d,1,2") - _MC88xxx (0xf4006400, "subu", "d,1,2") - _MC88xxx (0x64000000, "subu", "d,1,I") - _MC88xxx (0xf4006600, "subu.ci", "d,1,2") - _MC88xxx (0xf4006700, "subu.cio", "d,1,2") - _MC88xxx (0xf4006500, "subu.co", "d,1,2") - _MC88xxx (0xf000d000, "tb0", "B,1,V") - _MC88xxx (0xf000d800, "tb1", "B,1,V") - _MC88xxx (0xf400f800, "tbnd", "1,2") - _MC88xxx (0xf8000000, "tbnd", "1,I") - _MC88xxx (0xf000e800, "tcnd", "M,1,V") - _MC88xxx (0x84005880, "trnc.sd", "d,2") - _MC88110 (0x8400d880, "trnc.sd", "d,x2") - _MC88xxx (0x84005800, "trnc.ss", "d,2") - _MC88110 (0x8400d800, "trnc.ss", "d,x2") - _MC88110 (0x8400d900, "trnc.sx", "d,x2") - _MC88xxx (0x8000c000, "xcr", "d,3,c") - _MC88xxx (0xf4000600, "xmem", "d,1[2]") - _MC88xxx (0xf4000400, "xmem", "d,1,2") - _MC88100 (0x04000000, "xmem", "?d,1,I") - _MC88xxx (0xf4000200, "xmem.bu", "d,1[2]") - _MC88xxx (0xf4000000, "xmem.bu", "d,1,2") - _MC88100 (0x00000000, "xmem.bu", "?d,1,I") - _MC88xxx (0xf4000300, "xmem.bu.usr", "d,1[2]") - _MC88xxx (0xf4000100, "xmem.bu.usr", "d,1,2") - _MC88100 (0x00000100, "xmem.bu.usr", "?d,1,I") - _MC88xxx (0xf4000700, "xmem.usr", "d,1[2]") - _MC88xxx (0xf4000500, "xmem.usr", "d,1,2") - _MC88100 (0x04000100, "xmem.usr", "?d,1,I") - _MC88xxx (0xf4005000, "xor", "d,1,2") - _MC88xxx (0x50000000, "xor", "d,1,I") - _MC88xxx (0xf4005400, "xor.c", "d,1,2") - _MC88xxx (0x54000000, "xor.u", "d,1,I") - _MC88xxx (0x00000000, "", 0) -}; - -#define NUMOPCODES ((sizeof m88k_opcodes)/(sizeof m88k_opcodes[0])) diff --git a/gas/config/obj-aout.c b/gas/config/obj-aout.c index eb71397..e99e63d 100644 --- a/gas/config/obj-aout.c +++ b/gas/config/obj-aout.c @@ -22,51 +22,10 @@ #define OBJ_HEADER "obj-aout.h" #include "as.h" -#ifdef BFD_ASSEMBLER #undef NO_RELOC #include "aout/aout64.h" -#endif #include "obstack.h" -#ifndef BFD_ASSEMBLER -/* in: segT out: N_TYPE bits. */ -const short seg_N_TYPE[] = -{ - N_ABS, - N_TEXT, - N_DATA, - N_BSS, - N_UNDF, /* Unknown. */ - N_UNDF, /* Error. */ - N_UNDF, /* Expression. */ - 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, -}; -#endif - -#ifdef BFD_ASSEMBLER - void obj_aout_frob_symbol (symbolS *sym, int *punt ATTRIBUTE_UNUSED) { @@ -176,137 +135,6 @@ obj_aout_frob_file_before_fix (void) assert (x); } -#else /* ! BFD_ASSEMBLER */ - -/* Relocation. */ - -/** Crawl along a fixS chain. Emit the segment's relocations. */ - -void -obj_emit_relocations (char **where, - fixS *fixP, /* Fixup chain for this segment. */ - relax_addressT segment_address_in_file) -{ - for (; fixP; fixP = fixP->fx_next) - if (fixP->fx_done == 0) - { - symbolS *sym; - - sym = fixP->fx_addsy; - while (sym->sy_value.X_op == O_symbol - && (! S_IS_DEFINED (sym) || S_IS_COMMON (sym))) - sym = sym->sy_value.X_add_symbol; - fixP->fx_addsy = sym; - - if (! sym->sy_resolved && ! S_IS_DEFINED (sym)) - { - char *file; - unsigned int line; - - if (expr_symbol_where (sym, &file, &line)) - as_bad_where (file, line, _("unresolved relocation")); - else - as_bad (_("bad relocation: symbol `%s' not in symbol table"), - S_GET_NAME (sym)); - } - - tc_aout_fix_to_chars (*where, fixP, segment_address_in_file); - *where += md_reloc_size; - } -} - -#ifndef obj_header_append -/* Aout file generation & utilities. */ - -/* An AOUT header on disk is laid out in target byte order. */ - -void -obj_header_append (char **where, object_headers *headers) -{ - char *p; - - tc_headers_hook (headers); - -#ifdef __A_OUT_GNU_H__ -#define SIZEOF_HEADER(PIECE) (sizeof (((struct exec_bytes *) 0)->PIECE)) -#else -#define SIZEOF_HEADER(PIECE) 4 -#endif -#define DO(PIECE) \ - md_number_to_chars (p, headers->header.PIECE, SIZEOF_HEADER (PIECE)); \ - p += SIZEOF_HEADER (PIECE); - - p = *where; - DO (a_info); - DO (a_text); - DO (a_data); - DO (a_bss); - DO (a_syms); - DO (a_entry); - DO (a_trsize); - DO (a_drsize); - *where = p; -#undef DO -#undef SIZEOF_HEADER -} -#endif /* ! defined (obj_header_append) */ - -void -obj_symbol_to_chars (char **where, symbolS *symbolP) -{ - char *p = *where; - md_number_to_chars (p, S_GET_OFFSET (symbolP), 4); - p += 4; - /* Can't use S_GET_TYPE here as it masks. */ - *p++ = symbolP->sy_symbol.n_type; - *p++ = symbolP->sy_symbol.n_other; - md_number_to_chars (p, S_GET_DESC (symbolP), 2); - p += 2; - md_number_to_chars (p, S_GET_VALUE (symbolP), 4); - p += 4; - *where = p; -} - -void -obj_emit_symbols (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); - - /* Adjust the type of a weak symbol. */ - if (S_GET_WEAK (symbolP)) - { - switch (S_GET_TYPE (symbolP)) - { - case N_UNDF: S_SET_TYPE (symbolP, N_WEAKU); break; - case N_ABS: S_SET_TYPE (symbolP, N_WEAKA); break; - case N_TEXT: S_SET_TYPE (symbolP, N_WEAKT); break; - case N_DATA: S_SET_TYPE (symbolP, N_WEAKD); break; - case N_BSS: S_SET_TYPE (symbolP, N_WEAKB); break; - default: as_bad (_("%s: bad type for weak symbol"), temp); break; - } - } - - obj_symbol_to_chars (where, symbolP); - S_SET_NAME (symbolP, temp); - } -} - -#endif /* ! BFD_ASSEMBLER */ - static void obj_aout_line (int ignore ATTRIBUTE_UNUSED) { @@ -381,136 +209,6 @@ obj_aout_type (int ignore ATTRIBUTE_UNUSED) s_ignore (0); } -#ifndef BFD_ASSEMBLER - -void -obj_crawl_symbol_chain (object_headers *headers) -{ - symbolS *symbolP; - symbolS **symbolPP; - int symbol_number = 0; - - tc_crawl_symbol_chain (headers); - - symbolPP = &symbol_rootP; /*->last symbol chain link. */ - while ((symbolP = *symbolPP) != NULL) - { - if (symbolP->sy_mri_common) - { - if (S_IS_EXTERNAL (symbolP)) - as_bad (_("%s: global symbols not supported in common sections"), - S_GET_NAME (symbolP)); - *symbolPP = symbol_next (symbolP); - continue; - } - - if (flag_readonly_data_in_text && (S_GET_SEGMENT (symbolP) == SEG_DATA)) - { - S_SET_SEGMENT (symbolP, SEG_TEXT); - } - - resolve_symbol_value (symbolP); - - /* Skip symbols which were equated to undefined or common - symbols. Also skip defined uncommon symbols which can - be resolved since in this case they should have been - resolved to a non-symbolic constant. */ - if (symbolP->sy_value.X_op == O_symbol - && (! S_IS_DEFINED (symbolP) - || S_IS_COMMON (symbolP) - || symbol_resolved_p (symbolP))) - { - *symbolPP = symbol_next (symbolP); - continue; - } - - /* 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) - || !S_IS_DEFINED (symbolP) - || S_IS_EXTERNAL (symbolP) - || (S_GET_NAME (symbolP)[0] != '\001' - && (flag_keep_locals || !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 = &symbolP->sy_next; - } - else - { - if (S_IS_EXTERNAL (symbolP) || !S_IS_DEFINED (symbolP)) - /* This warning should never get triggered any more. - Well, maybe if you're doing twisted things with - register names... */ - as_bad (_("Local symbol %s never defined."), - decode_local_label_name (S_GET_NAME (symbolP))); - - /* Unhook it from the chain */ - *symbolPP = symbol_next (symbolP); - } - } - - H_SET_SYMBOL_TABLE_SIZE (headers, symbol_number); -} - -/* Find strings by crawling along symbol table chain. */ - -void -obj_emit_strings (char **where) -{ - symbolS *symbolP; - - md_number_to_chars (*where, string_byte_count, 4); - *where += 4; - - 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)); -} - -#ifndef AOUT_VERSION -#define AOUT_VERSION 0 -#endif - -void -obj_pre_write_hook (object_headers *headers) -{ - H_SET_DYNAMIC (headers, 0); - H_SET_VERSION (headers, AOUT_VERSION); - H_SET_MACHTYPE (headers, AOUT_MACHTYPE); - tc_aout_pre_write_hook (headers); -} - -#endif /* ! BFD_ASSEMBLER */ - -#ifdef BFD_ASSEMBLER - /* Support for an AOUT emulation. */ static void @@ -614,7 +312,6 @@ const struct format_ops aout_format_ops = 0, /* read_begin_hook. */ 0 /* symbol_new_hook. */ }; -#endif /* BFD_ASSEMBLER */ const pseudo_typeS aout_pseudo_table[] = { diff --git a/gas/config/obj-aout.h b/gas/config/obj-aout.h index d5383d1..4acc420 100644 --- a/gas/config/obj-aout.h +++ b/gas/config/obj-aout.h @@ -24,33 +24,10 @@ #include "targ-cpu.h" -#ifdef BFD_ASSEMBLER - #include "bfd/libaout.h" #define OUTPUT_FLAVOR bfd_target_aout_flavour -#else /* ! BFD_ASSEMBLER */ - -#ifndef VMS -#include "aout_gnu.h" /* Needed to define struct nlist. Sigh. */ -#else -#include "a_out.h" -#endif - -#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 */ - -#endif /* ! BFD_ASSEMBLER */ - extern const pseudo_typeS aout_pseudo_table[]; #ifndef obj_pop_insert @@ -63,8 +40,6 @@ typedef struct nlist obj_symbol_type; /* Symbol table entry. */ /* Symbol table macros and constants */ -#ifdef BFD_ASSEMBLER - #define S_SET_OTHER(S,V) \ (aout_symbol (symbol_get_bfdsym (S))->other = (V)) #define S_SET_TYPE(S,T) \ @@ -88,163 +63,6 @@ extern void obj_aout_frob_file_before_fix (void); #define obj_sec_sym_ok_for_reloc(SEC) 1 -#else - -/* We use the sy_obj field to record whether a symbol is weak. */ -#define OBJ_SYMFIELD_TYPE char - -/* Macros to extract information from a symbol table entry. - This syntactic 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_DESC (s) != 0) - -#define S_IS_COMMON(s) \ - (S_GET_TYPE (s) == N_UNDF && S_GET_VALUE (s) != 0) - -/* Return true for symbols that should not be reduced to section - symbols or eliminated from expressions, because they may be - overridden by the linker. */ -#define S_FORCE_RELOC(s, strict) \ - (!SEG_NORMAL (S_GET_SEGMENT (s))) - -#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. */ -#define S_IS_LOCAL(s) \ - ((S_GET_NAME (s) \ - && !S_IS_DEBUG (s) \ - && (strchr (S_GET_NAME (s), '\001') != NULL \ - || strchr (S_GET_NAME (s), '\002') != NULL \ - || (S_LOCAL_NAME(s) && !flag_keep_locals))) \ - || (flag_strip_local_absolute \ - && ! S_IS_EXTERNAL(s) \ - && S_GET_SEGMENT (s) == absolute_section)) -/* True if the symbol has been generated because of a .stabd directive. */ -#define S_IS_STABD(s) (S_GET_NAME(s) == NULL) - -/* Accessors. */ -/* 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) -/* Whether the symbol is weak. */ -#define S_GET_WEAK(s) ((s)->sy_obj) - -/* Modifiers. */ -/* 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_type field. */ -#define S_SET_TYPE(s,t) ((s)->sy_symbol.n_type = (t)) -/* 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)) -/* Mark the symbol as weak. This causes n_type to be adjusted when - the symbol is written out. */ -#define S_SET_WEAK(s) ((s)->sy_obj = 1) - -/* 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_TEXT_RELOCATION_SIZE (h) \ - + H_GET_DATA_RELOCATION_SIZE (h) \ - + H_GET_LINENO_SIZE (h) \ - + H_GET_SYMBOL_TABLE_SIZE (h) \ - + H_GET_STRING_SIZE (h)) - -#define H_GET_HEADER_SIZE(h) (EXEC_BYTES_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) * 12) - -#define H_SET_ENTRY_POINT(h,v) ((h)->header.a_entry = (v)) -#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v)) - -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) {;} - -struct fix; -extern void tc_aout_fix_to_chars (char *, struct fix *, relax_addressT); - -#endif - #define obj_read_begin_hook() {;} #define obj_symbol_new_hook(s) {;} diff --git a/gas/config/obj-bout.c b/gas/config/obj-bout.c deleted file mode 100644 index 2b35dd9..0000000 --- a/gas/config/obj-bout.c +++ /dev/null @@ -1,324 +0,0 @@ -/* b.out object file format - Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002, - 2003, 2005 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -#include "as.h" -#include "obstack.h" - -/* In: segT Out: N_TYPE bits. */ -const short seg_N_TYPE[] = -{ - N_ABS, - N_TEXT, - N_DATA, - N_BSS, - N_UNDF, /* Unknown. */ - N_UNDF, /* Error. */ - N_UNDF, /* Expression. */ - 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, -}; - -/* Relocation. */ - -/* Crawl along a fixS chain. Emit the segment's relocations. */ - -void -obj_emit_relocations (char **where, - fixS *fixP, /* Fixup chain for this segment. */ - relax_addressT segment_address_in_file) -{ - for (; fixP; fixP = fixP->fx_next) - { - if (fixP->fx_done == 0 - || fixP->fx_r_type != NO_RELOC) - { - symbolS *sym; - - sym = fixP->fx_addsy; - while (sym->sy_value.X_op == O_symbol - && (! S_IS_DEFINED (sym) || S_IS_COMMON (sym))) - sym = sym->sy_value.X_add_symbol; - fixP->fx_addsy = sym; - - tc_bout_fix_to_chars (*where, fixP, segment_address_in_file); - *where += md_reloc_size; - } - } -} - -/* Aout file generation & utilities . */ - -/* Convert a lvalue to machine dependent data. */ - -void -obj_header_append (char **where, object_headers *headers) -{ - /* Always leave in host byte order. */ - char *p; - - headers->header.a_talign = section_alignment[SEG_TEXT]; - - /* Force to at least 2. */ - if (headers->header.a_talign < 2) - headers->header.a_talign = 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)); - - headers->header.a_relaxable = linkrelax; - - p = *where; - host_number_to_chars (p, headers->header.a_magic, 4); - p += 4; - host_number_to_chars (p, headers->header.a_text, 4); - p += 4; - host_number_to_chars (p, headers->header.a_data, 4); - p += 4; - host_number_to_chars (p, headers->header.a_bss, 4); - p += 4; - host_number_to_chars (p, headers->header.a_syms, 4); - p += 4; - host_number_to_chars (p, headers->header.a_entry, 4); - p += 4; - host_number_to_chars (p, headers->header.a_trsize, 4); - p += 4; - host_number_to_chars (p, headers->header.a_drsize, 4); - p += 4; - host_number_to_chars (p, headers->header.a_tload, 4); - p += 4; - host_number_to_chars (p, headers->header.a_dload, 4); - p += 4; - *p++ = headers->header.a_talign; - *p++ = headers->header.a_dalign; - *p++ = headers->header.a_balign; - *p++ = headers->header.a_relaxable; - *where = p; -} - -void -obj_symbol_to_chars (char **where, symbolS *symbolP) -{ - char *p = *where; - - host_number_to_chars (p, S_GET_OFFSET (symbolP), 4); - p += 4; - /* Can't use S_GET_TYPE here as it masks. */ - *p++ = symbolP->sy_symbol.n_type; - *p++ = symbolP->sy_symbol.n_other; - host_number_to_chars (p, S_GET_DESC (symbolP), 2); - p += 2; - host_number_to_chars (p, S_GET_VALUE (symbolP), 4); - p += 4; - *where = p; -} - -void -obj_emit_symbols (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); - } -} - -void -obj_symbol_new_hook (symbolS *symbolP) -{ - S_SET_OTHER (symbolP, 0); - S_SET_DESC (symbolP, 0); -} - -static void -obj_bout_line (int ignore ATTRIBUTE_UNUSED) -{ - /* Assume delimiter is part of expression. */ - /* BSD4.2 as fails with delightful bug, so we are not being - incompatible here. */ - new_logical_line (NULL, (int) (get_absolute_expression ())); - demand_empty_rest_of_line (); -} - -void -obj_read_begin_hook (void) -{ -} - -void -obj_crawl_symbol_chain (object_headers *headers) -{ - symbolS **symbolPP; - symbolS *symbolP; - int symbol_number = 0; - - tc_crawl_symbol_chain (headers); - - symbolPP = &symbol_rootP; /* -> last symbol chain link. */ - while ((symbolP = *symbolPP) != NULL) - { - if (flag_readonly_data_in_text && (S_GET_SEGMENT (symbolP) == SEG_DATA)) - { - S_SET_SEGMENT (symbolP, SEG_TEXT); - } - - resolve_symbol_value (symbolP); - - /* Skip symbols which were equated to undefined or common - symbols. */ - if (symbolP->sy_value.X_op == O_symbol - && (! S_IS_DEFINED (symbolP) || S_IS_COMMON (symbolP))) - { - *symbolPP = symbol_next (symbolP); - continue; - } - - /* 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 - || (S_GET_NAME (symbolP)[0] != '\001' - && (flag_keep_locals || !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 = &(symbolP->sy_next); - } - else - { - if (S_IS_EXTERNAL (symbolP) || !S_IS_DEFINED (symbolP)) - as_bad (_("Local symbol %s never defined"), - S_GET_NAME (symbolP)); - - /* Unhook it from the chain. */ - *symbolPP = symbol_next (symbolP); - } - } - - H_SET_SYMBOL_TABLE_SIZE (headers, symbol_number); -} - -/* Find strings by crawling along symbol table chain. */ - -void -obj_emit_strings (char **where) -{ - symbolS *symbolP; - - md_number_to_chars (*where, string_byte_count, 4); - *where += 4; - - 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)); -} - -const pseudo_typeS obj_pseudo_table[] = -{ - {"line", obj_bout_line, 0}, /* Source code line number. */ - - /* 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, NULL, 0} -}; - diff --git a/gas/config/obj-bout.h b/gas/config/obj-bout.h deleted file mode 100644 index 36e5754..0000000 --- a/gas/config/obj-bout.h +++ /dev/null @@ -1,310 +0,0 @@ -/* b.out object file format - Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, - 2002, 2003, 2005 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, 51 Franklin Street - Fifth Floor, 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. - ==> This is no longer true using BFD. We can generate any byte order - for the header, and read any byte order. Preference would be to - use little-endian byte order throughout, regardless of host. <== - - 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 - -#define OUTPUT_FLAVOR bfd_target_aout_flavour - -#include "targ-cpu.h" - -#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. */ - -#ifndef DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE -#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE BMAGIC -#endif - -/* 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 a_relaxable; /* Contains enough info to relax. */ -}; - -#define EXEC_BYTES_SIZE (10 * 4 + 4 * 1) - -#define N_BADMAG(x) (((x).a_magic) != BMAGIC) -#define N_TXTOFF(x) EXEC_BYTES_SIZE -#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 syntactic 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)) - -/* Return true for symbols that should not be reduced to section - symbols or eliminated from expressions, because they may be - overridden by the linker. */ -#define S_FORCE_RELOC(s, strict) \ - (!SEG_NORMAL (S_GET_SEGMENT (s))) - -#define S_IS_COMMON(s) \ - (S_GET_TYPE (s) == N_UNDF && S_GET_VALUE (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. */ -#define S_IS_LOCAL(s) \ - ((S_GET_NAME (s) \ - && !S_IS_DEBUG (s) \ - && (strchr (S_GET_NAME (s), '\001') != NULL \ - || strchr (S_GET_NAME (s), '\002') != NULL \ - || (S_LOCAL_NAME(s) && !flag_keep_locals))) \ - || (flag_strip_local_absolute \ - && !S_IS_EXTERNAL(s) \ - && S_GET_SEGMENT(s) == absolute_section)) -/* True if the symbol has been generated because of a .stabd directive. */ -#define S_IS_STABD(s) (S_GET_NAME(s) == NULL) - -/* Accessors. */ -/* 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. */ -/* 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)) -/* Set the n_type value. */ -#define S_SET_TYPE(s,v) ((s)->sy_symbol.n_type = (v)) - -/* File header macro and type definition. */ - -#define H_GET_FILE_SIZE(h) (EXEC_BYTES_SIZE \ - + 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) EXEC_BYTES_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_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) * 12) - -#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. */ - -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) {;} -#define obj_pre_write_hook(a) {;} - -#if WORDS_BIGENDIAN -#define host_number_to_chars number_to_chars_bigendian -#else -#define host_number_to_chars number_to_chars_littleendian -#endif - -struct fix; - -extern void tc_aout_fix_to_chars (char *, struct fix *, relax_addressT); -extern void tc_bout_fix_to_chars (char *, struct fix *, relax_addressT); - -#define AOUT_STABS diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c index 6054726..98b901b 100644 --- a/gas/config/obj-coff.c +++ b/gas/config/obj-coff.c @@ -38,9 +38,9 @@ #define KEEP_RELOC_INFO #endif -/* The BFD_ASSEMBLER version of obj_coff_section will use this macro to set - a new section's attributes when a directive has no valid flags or the - "w" flag is used. This default should be appropriate for most. */ +/* obj_coff_section will use this macro to set a new section's + attributes when a directive has no valid flags or the "w" flag is + used. This default should be appropriate for most. */ #ifndef TC_COFF_SECTION_DEFAULT_ATTRIBUTES #define TC_COFF_SECTION_DEFAULT_ATTRIBUTES (SEC_LOAD | SEC_DATA) #endif @@ -151,9 +151,7 @@ tag_find_or_make (char *name) 0, &zero_address_frag); tag_insert (S_GET_NAME (symbolP), symbolP); -#ifdef BFD_ASSEMBLER symbol_table_insert (symbolP); -#endif } return symbolP; @@ -171,8 +169,6 @@ obj_coff_bss (int ignore ATTRIBUTE_UNUSED) s_lcomm (0); } -#ifdef BFD_ASSEMBLER - #define GET_FILENAME_STRING(X) \ ((char *) (&((X)->sy_symbol.ost_auxent->x_file.x_n.x_offset))[1]) @@ -1087,10 +1083,7 @@ obj_coff_weak (int ignore ATTRIBUTE_UNUSED) symbolP = symbol_find_or_make (name); *input_line_pointer = c; SKIP_WHITESPACE (); - -#if defined BFD_ASSEMBLER || defined S_SET_WEAK S_SET_WEAK (symbolP); -#endif #ifdef TE_PE /* See _Microsoft Portable Executable and Common Object @@ -1127,10 +1120,8 @@ void coff_obj_read_begin_hook (void) { /* These had better be the same. Usually 18 bytes. */ -#ifndef BFD_HEADERS know (sizeof (SYMENT) == sizeof (AUXENT)); know (SYMESZ == AUXESZ); -#endif tag_init (); } @@ -1703,2711 +1694,6 @@ symbol_dump (void) #endif /* DEBUG */ -#else /* not BFD_ASSEMBLER */ - -#include "frags.h" -/* This is needed because we include internal bfd things. */ -#include <time.h> - -#include "libbfd.h" -#include "libcoff.h" - -/* The NOP_OPCODE is for the alignment fill value. Fill with nop so - that we can stick sections together without causing trouble. */ -#ifndef NOP_OPCODE -#define NOP_OPCODE 0x00 -#endif - -/* The zeroes if symbol name is longer than 8 chars */ -#define S_SET_ZEROES(s,v) ((s)->sy_symbol.ost_entry.n_zeroes = (v)) - -#define MIN(a,b) ((a) < (b)? (a) : (b)) - -/* This vector is used to turn a gas internal segment number into a - section number suitable for insertion into a coff symbol table. - This must correspond to seg_info_off_by_4. */ - -const short seg_N_TYPE[] = -{ /* in: segT out: N_TYPE bits */ - C_ABS_SECTION, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - C_UNDEF_SECTION, /* SEG_UNKNOWN */ - C_UNDEF_SECTION, /* SEG_GOOF */ - C_UNDEF_SECTION, /* SEG_EXPR */ - C_DEBUG_SECTION, /* SEG_DEBUG */ - C_NTV_SECTION, /* SEG_NTV */ - C_PTV_SECTION, /* SEG_PTV */ - C_REGISTER_SECTION, /* SEG_REGISTER */ -}; - -int function_lineoff = -1; /* Offset in line#s where the last function - started (the odd entry for line #0) */ - -/* Structure used to keep the filenames which - are too long around so that we can stick them - into the string table. */ -struct filename_list -{ - const char *filename; - struct filename_list *next; -}; - -static struct filename_list *filename_list_head; -static struct filename_list *filename_list_tail; - -static symbolS *last_line_symbol; - -/* Add 4 to the real value to get the index and compensate the - negatives. This vector is used by S_GET_SEGMENT to turn a coff - section number into a segment number. */ - -bfd *abfd; -static symbolS *previous_file_symbol; -static int line_base; - -/* When not using BFD_ASSEMBLER, we permit up to 40 sections. - - This array maps a COFF section number into a gas section number. - Because COFF uses negative section numbers, you must add 4 to the - COFF section number when indexing into this array; this is done via - the SEG_INFO_FROM_SECTION_NUMBER macro. This must correspond to - seg_N_TYPE. */ - -static const segT seg_info_off_by_4[] = -{ - SEG_PTV, - SEG_NTV, - SEG_DEBUG, - SEG_ABSOLUTE, - SEG_UNKNOWN, - SEG_E0, SEG_E1, SEG_E2, SEG_E3, SEG_E4, - SEG_E5, SEG_E6, SEG_E7, SEG_E8, SEG_E9, - SEG_E10, SEG_E11, SEG_E12, SEG_E13, SEG_E14, - SEG_E15, SEG_E16, SEG_E17, SEG_E18, SEG_E19, - SEG_E20, SEG_E21, SEG_E22, SEG_E23, SEG_E24, - SEG_E25, SEG_E26, SEG_E27, SEG_E28, SEG_E29, - SEG_E30, SEG_E31, SEG_E32, SEG_E33, SEG_E34, - SEG_E35, SEG_E36, SEG_E37, SEG_E38, SEG_E39, - (segT) 40, - (segT) 41, - (segT) 42, - (segT) 43, - (segT) 44, - (segT) 45, - (segT) 0, - (segT) 0, - (segT) 0, - SEG_REGISTER -}; - -#define SEG_INFO_FROM_SECTION_NUMBER(x) (seg_info_off_by_4[(x)+4]) - -static relax_addressT -relax_align (relax_addressT address, long alignment) -{ - relax_addressT mask; - relax_addressT new_address; - - mask = ~((~0) << alignment); - new_address = (address + mask) & (~mask); - - return new_address - address; -} - -segT -s_get_segment (symbolS * x) -{ - return SEG_INFO_FROM_SECTION_NUMBER (x->sy_symbol.ost_entry.n_scnum); -} - -/* Calculate the size of the frag chain and fill in the section header - to contain all of it, also fill in the addr of the sections. */ - -static unsigned int -size_section (bfd *abfd ATTRIBUTE_UNUSED, unsigned int idx) -{ - unsigned int size = 0; - fragS *frag = segment_info[idx].frchainP->frch_root; - - while (frag) - { - size = frag->fr_address; - if (frag->fr_address != size) - { - fprintf (stderr, _("Out of step\n")); - size = frag->fr_address; - } - - switch (frag->fr_type) - { -#ifdef TC_COFF_SIZEMACHDEP - case rs_machine_dependent: - size += TC_COFF_SIZEMACHDEP (frag); - break; -#endif - case rs_space: - case rs_fill: - case rs_org: - size += frag->fr_fix; - size += frag->fr_offset * frag->fr_var; - break; - case rs_align: - case rs_align_code: - case rs_align_test: - { - addressT off; - - size += frag->fr_fix; - off = relax_align (size, frag->fr_offset); - if (frag->fr_subtype != 0 && off > frag->fr_subtype) - off = 0; - size += off; - } - break; - default: - BAD_CASE (frag->fr_type); - break; - } - frag = frag->fr_next; - } - segment_info[idx].scnhdr.s_size = size; - return size; -} - -static unsigned int -count_entries_in_chain (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) - { - if (fixup_ptr->fx_done == 0 && TC_COUNT_RELOC (fixup_ptr)) - { -#if defined(TC_A29K) || defined(TC_OR32) - if (fixup_ptr->fx_r_type == RELOC_CONSTH) - nrelocs += 2; - else - nrelocs++; -#else - nrelocs++; -#endif - } - - fixup_ptr = fixup_ptr->fx_next; - } - return nrelocs; -} - -#ifdef TE_AUX - -/* AUX's ld expects relocations to be sorted. */ - -static int -compare_external_relocs (const void * x, const void * y) -{ - struct external_reloc *a = (struct external_reloc *) x; - struct external_reloc *b = (struct external_reloc *) y; - bfd_vma aadr = bfd_getb32 (a->r_vaddr); - bfd_vma badr = bfd_getb32 (b->r_vaddr); - - return (aadr < badr ? -1 : badr < aadr ? 1 : 0); -} - -#endif - -/* Output all the relocations for a section. */ - -static void -do_relocs_for (bfd * abfd, object_headers * h, unsigned long *file_cursor) -{ - unsigned int nrelocs; - unsigned int idx; - unsigned long reloc_start = *file_cursor; - - for (idx = SEG_E0; idx < SEG_LAST; idx++) - { - if (segment_info[idx].scnhdr.s_name[0]) - { - struct external_reloc *ext_ptr; - struct external_reloc *external_reloc_vec; - unsigned int external_reloc_size; - unsigned int base = segment_info[idx].scnhdr.s_paddr; - fixS *fix_ptr = segment_info[idx].fix_root; - - nrelocs = count_entries_in_chain (idx); - - if (nrelocs) - /* Bypass this stuff if no relocs. This also incidentally - avoids a SCO bug, where free(malloc(0)) tends to crash. */ - { - external_reloc_size = nrelocs * RELSZ; - external_reloc_vec = malloc (external_reloc_size); - - ext_ptr = external_reloc_vec; - - /* Fill in the internal coff style reloc struct from the - internal fix list. */ - while (fix_ptr) - { - struct internal_reloc intr; - - /* Only output some of the relocations. */ - if (fix_ptr->fx_done == 0 && TC_COUNT_RELOC (fix_ptr)) - { -#ifdef TC_RELOC_MANGLE - TC_RELOC_MANGLE (&segment_info[idx], fix_ptr, &intr, - base); -#else - symbolS *dot; - symbolS *symbol_ptr = fix_ptr->fx_addsy; - - intr.r_type = TC_COFF_FIX2RTYPE (fix_ptr); - intr.r_vaddr = - base + fix_ptr->fx_frag->fr_address + fix_ptr->fx_where; - -#ifdef TC_KEEP_FX_OFFSET - intr.r_offset = fix_ptr->fx_offset; -#else - intr.r_offset = 0; -#endif - - while (symbol_ptr->sy_value.X_op == O_symbol - && (! S_IS_DEFINED (symbol_ptr) - || S_IS_COMMON (symbol_ptr))) - { - symbolS *n; - - /* We must avoid looping, as that can occur - with a badly written program. */ - n = symbol_ptr->sy_value.X_add_symbol; - if (n == symbol_ptr) - break; - symbol_ptr = n; - } - - /* Turn the segment of the symbol into an offset. */ - if (symbol_ptr) - { - resolve_symbol_value (symbol_ptr); - if (! symbol_ptr->sy_resolved) - { - char *file; - unsigned int line; - - if (expr_symbol_where (symbol_ptr, &file, &line)) - as_bad_where (file, line, - _("unresolved relocation")); - else - as_bad (_("bad relocation: symbol `%s' not in symbol table"), - S_GET_NAME (symbol_ptr)); - } - - dot = segment_info[S_GET_SEGMENT (symbol_ptr)].dot; - if (dot) - intr.r_symndx = dot->sy_number; - else - intr.r_symndx = symbol_ptr->sy_number; - } - else - intr.r_symndx = -1; -#endif - (void) bfd_coff_swap_reloc_out (abfd, &intr, ext_ptr); - ext_ptr++; -#if defined(TC_A29K) - /* The 29k has a special kludge for the high 16 bit - reloc. Two relocations are emitted, R_IHIHALF, - and R_IHCONST. The second one doesn't contain a - symbol, but uses the value for offset. */ - if (intr.r_type == R_IHIHALF) - { - /* Now emit the second bit. */ - intr.r_type = R_IHCONST; - intr.r_symndx = fix_ptr->fx_addnumber; - (void) bfd_coff_swap_reloc_out (abfd, &intr, ext_ptr); - ext_ptr++; - } -#endif -#if defined(TC_OR32) - /* The or32 has a special kludge for the high 16 bit - reloc. Two relocations are emitted, R_IHIHALF, - and R_IHCONST. The second one doesn't contain a - symbol, but uses the value for offset. */ - if (intr.r_type == R_IHIHALF) - { - /* Now emit the second bit. */ - intr.r_type = R_IHCONST; - intr.r_symndx = fix_ptr->fx_addnumber; - (void) bfd_coff_swap_reloc_out (abfd, & intr, ext_ptr); - ext_ptr ++; - } -#endif - } - - fix_ptr = fix_ptr->fx_next; - } -#ifdef TE_AUX - /* Sort the reloc table. */ - qsort ((void *) external_reloc_vec, nrelocs, - sizeof (struct external_reloc), compare_external_relocs); -#endif - /* Write out the reloc table. */ - bfd_bwrite ((void *) external_reloc_vec, - (bfd_size_type) external_reloc_size, abfd); - free (external_reloc_vec); - - /* Fill in section header info. */ - segment_info[idx].scnhdr.s_relptr = *file_cursor; - *file_cursor += external_reloc_size; - segment_info[idx].scnhdr.s_nreloc = nrelocs; - } - else - { - /* No relocs. */ - segment_info[idx].scnhdr.s_relptr = 0; - } - } - } - - /* Set relocation_size field in file headers. */ - H_SET_RELOCATION_SIZE (h, *file_cursor - reloc_start, 0); -} - -/* Run through a frag chain and write out the data to go with it, fill - in the scnhdrs with the info on the file positions. */ - -static void -fill_section (bfd * abfd, - object_headers *h ATTRIBUTE_UNUSED, - unsigned long *file_cursor) -{ - unsigned int i; - unsigned int paddr = 0; - - for (i = SEG_E0; i < SEG_UNKNOWN; i++) - { - unsigned int offset = 0; - struct internal_scnhdr *s = &(segment_info[i].scnhdr); - - PROGRESS (1); - - if (s->s_name[0]) - { - fragS *frag = segment_info[i].frchainP->frch_root; - char *buffer = NULL; - - if (s->s_size == 0) - s->s_scnptr = 0; - else - { - buffer = xmalloc (s->s_size); - s->s_scnptr = *file_cursor; - } - know (s->s_paddr == paddr); - - if (streq (s->s_name, ".text")) - s->s_flags |= STYP_TEXT; - else if (streq (s->s_name, ".data")) - s->s_flags |= STYP_DATA; - else if (streq (s->s_name, ".bss")) - { - s->s_scnptr = 0; - s->s_flags |= STYP_BSS; - - /* @@ Should make the i386 and a29k coff targets define - COFF_NOLOAD_PROBLEM, and have only one test here. */ -#ifndef TC_I386 -#ifndef TC_A29K -#ifndef TC_OR32 -#ifndef COFF_NOLOAD_PROBLEM - /* Apparently the SVR3 linker (and exec syscall) and UDI - mondfe progrem are confused by noload sections. */ - s->s_flags |= STYP_NOLOAD; -#endif -#endif -#endif -#endif - } - else if (streq (s->s_name, ".lit")) - s->s_flags = STYP_LIT | STYP_TEXT; - else if (streq (s->s_name, ".init")) - s->s_flags |= STYP_TEXT; - else if (streq (s->s_name, ".fini")) - s->s_flags |= STYP_TEXT; - else if (strneq (s->s_name, ".comment", 8)) - s->s_flags |= STYP_INFO; - - while (frag) - { - unsigned int fill_size; - - switch (frag->fr_type) - { - case rs_machine_dependent: - if (frag->fr_fix) - { - memcpy (buffer + frag->fr_address, - frag->fr_literal, - (unsigned int) frag->fr_fix); - offset += frag->fr_fix; - } - - break; - case rs_space: - case rs_fill: - case rs_align: - case rs_align_code: - case rs_align_test: - case rs_org: - if (frag->fr_fix) - { - memcpy (buffer + frag->fr_address, - frag->fr_literal, - (unsigned int) frag->fr_fix); - offset += frag->fr_fix; - } - - fill_size = frag->fr_var; - if (fill_size && frag->fr_offset > 0) - { - unsigned int count; - unsigned int off = frag->fr_fix; - - for (count = frag->fr_offset; count; count--) - { - if (fill_size + frag->fr_address + off <= s->s_size) - { - memcpy (buffer + frag->fr_address + off, - frag->fr_literal + frag->fr_fix, - fill_size); - off += fill_size; - offset += fill_size; - } - } - } - break; - case rs_broken_word: - break; - default: - abort (); - } - frag = frag->fr_next; - } - - if (s->s_size != 0) - { - if (s->s_scnptr != 0) - { - bfd_bwrite (buffer, s->s_size, abfd); - *file_cursor += s->s_size; - } - free (buffer); - } - paddr += s->s_size; - } - } -} - -/* Coff file generation & utilities. */ - -static void -coff_header_append (bfd * abfd, object_headers * h) -{ - unsigned int i; - char buffer[1000]; - char buffero[1000]; -#ifdef COFF_LONG_SECTION_NAMES - unsigned long string_size = 4; -#endif - - bfd_seek (abfd, 0, 0); - -#ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER - H_SET_MAGIC_NUMBER (h, COFF_MAGIC); - H_SET_VERSION_STAMP (h, 0); - H_SET_ENTRY_POINT (h, 0); - H_SET_TEXT_START (h, segment_info[SEG_E0].frchainP->frch_root->fr_address); - H_SET_DATA_START (h, segment_info[SEG_E1].frchainP->frch_root->fr_address); - H_SET_SIZEOF_OPTIONAL_HEADER (h, bfd_coff_swap_aouthdr_out (abfd, &h->aouthdr, - buffero)); -#else /* defined (OBJ_COFF_OMIT_OPTIONAL_HEADER) */ - H_SET_SIZEOF_OPTIONAL_HEADER (h, 0); -#endif /* defined (OBJ_COFF_OMIT_OPTIONAL_HEADER) */ - - i = bfd_coff_swap_filehdr_out (abfd, &h->filehdr, buffer); - - bfd_bwrite (buffer, (bfd_size_type) i, abfd); - bfd_bwrite (buffero, (bfd_size_type) H_GET_SIZEOF_OPTIONAL_HEADER (h), abfd); - - for (i = SEG_E0; i < SEG_LAST; i++) - { - if (segment_info[i].scnhdr.s_name[0]) - { - unsigned int size; - -#ifdef COFF_LONG_SECTION_NAMES - /* Support long section names as found in PE. This code - must coordinate with that in write_object_file and - w_strings. */ - if (strlen (segment_info[i].name) > SCNNMLEN) - { - memset (segment_info[i].scnhdr.s_name, 0, SCNNMLEN); - sprintf (segment_info[i].scnhdr.s_name, "/%lu", string_size); - string_size += strlen (segment_info[i].name) + 1; - } -#endif - size = bfd_coff_swap_scnhdr_out (abfd, - &(segment_info[i].scnhdr), - buffer); - if (size == 0) - as_bad (_("bfd_coff_swap_scnhdr_out failed")); - bfd_bwrite (buffer, (bfd_size_type) size, abfd); - } - } -} - -static char * -symbol_to_chars (bfd * abfd, char * where, symbolS * symbolP) -{ - unsigned int numaux = symbolP->sy_symbol.ost_entry.n_numaux; - unsigned int i; - valueT val; - - /* Turn any symbols with register attributes into abs symbols. */ - if (S_GET_SEGMENT (symbolP) == reg_section) - S_SET_SEGMENT (symbolP, absolute_section); - - /* At the same time, relocate all symbols to their output value. */ -#ifndef TE_PE - val = (segment_info[S_GET_SEGMENT (symbolP)].scnhdr.s_paddr - + S_GET_VALUE (symbolP)); -#else - val = S_GET_VALUE (symbolP); -#endif - - S_SET_VALUE (symbolP, val); - - symbolP->sy_symbol.ost_entry.n_value = val; - - where += bfd_coff_swap_sym_out (abfd, &symbolP->sy_symbol.ost_entry, - where); - - for (i = 0; i < numaux; i++) - { - where += bfd_coff_swap_aux_out (abfd, - &symbolP->sy_symbol.ost_auxent[i], - S_GET_DATA_TYPE (symbolP), - S_GET_STORAGE_CLASS (symbolP), - i, numaux, where); - } - - return where; -} - -void -coff_obj_symbol_new_hook (symbolS *symbolP) -{ - char underscore = 0; /* Symbol has leading _ */ - - /* Effective symbol. */ - /* Store the pointer in the offset. */ - S_SET_ZEROES (symbolP, 0L); - S_SET_DATA_TYPE (symbolP, T_NULL); - S_SET_STORAGE_CLASS (symbolP, 0); - S_SET_NUMBER_AUXILIARY (symbolP, 0); - /* Additional information. */ - symbolP->sy_symbol.ost_flags = 0; - /* Auxiliary entries. */ - memset ((char *) &symbolP->sy_symbol.ost_auxent[0], 0, AUXESZ); - - if (S_IS_STRING (symbolP)) - SF_SET_STRING (symbolP); - if (!underscore && S_IS_LOCAL (symbolP)) - SF_SET_LOCAL (symbolP); -} - -static int -c_line_new (symbolS * symbol, long paddr, int line_number, fragS * frag) -{ - struct lineno_list *new_line = xmalloc (sizeof (* new_line)); - - segment_info_type *s = segment_info + now_seg; - new_line->line.l_lnno = line_number; - - if (line_number == 0) - { - last_line_symbol = symbol; - new_line->line.l_addr.l_symndx = (long) symbol; - } - else - { - new_line->line.l_addr.l_paddr = paddr; - } - - new_line->frag = (char *) frag; - new_line->next = NULL; - - if (s->lineno_list_head == NULL) - s->lineno_list_head = new_line; - else - s->lineno_list_tail->next = new_line; - - s->lineno_list_tail = new_line; - return LINESZ * s->scnhdr.s_nlnno++; -} - -/* Handle .ln directives. */ - -static void -obj_coff_ln (int appline) -{ - int l; - - if (! appline && def_symbol_in_progress != NULL) - { - /* Wrong context. */ - as_warn (_(".ln pseudo-op inside .def/.endef: ignored.")); - demand_empty_rest_of_line (); - return; - } - - l = get_absolute_expression (); - c_line_new (0, frag_now_fix (), l, frag_now); - - if (appline) - new_logical_line ((char *) NULL, l - 1); - -#ifndef NO_LISTING - { - extern int listing; - - if (listing) - { - if (! appline) - l += line_base - 1; - listing_source_line ((unsigned int) l); - } - } -#endif - demand_empty_rest_of_line (); -} - -/* Handle .def directives. - - One might ask : why can't we symbol_new if the symbol does not - already exist and fill it with debug information. Because of - the C_EFCN special symbol. It would clobber the value of the - function symbol before we have a chance to notice that it is - a C_EFCN. And a second reason is that the code is more clear this - way. (at least I think it is :-). */ - -#define SKIP_SEMI_COLON() while (*input_line_pointer++ != ';') -#define SKIP_WHITESPACES() while (*input_line_pointer == ' ' || \ - *input_line_pointer == '\t') \ - input_line_pointer++; - -static void -obj_coff_def (int what ATTRIBUTE_UNUSED) -{ - char name_end; /* Char after the end of name. */ - char *symbol_name; /* Name of the debug symbol. */ - char *symbol_name_copy; /* Temporary copy of the name. */ - unsigned int symbol_name_length; - - if (def_symbol_in_progress != NULL) - { - as_warn (_(".def pseudo-op used inside of .def/.endef: ignored.")); - demand_empty_rest_of_line (); - return; - } - - SKIP_WHITESPACES (); - - def_symbol_in_progress = obstack_alloc (¬es, sizeof (*def_symbol_in_progress)); - memset (def_symbol_in_progress, 0, sizeof (*def_symbol_in_progress)); - - symbol_name = input_line_pointer; - name_end = get_symbol_end (); - symbol_name_length = strlen (symbol_name); - symbol_name_copy = xmalloc (symbol_name_length + 1); - strcpy (symbol_name_copy, symbol_name); -#ifdef tc_canonicalize_symbol_name - symbol_name_copy = tc_canonicalize_symbol_name (symbol_name_copy); -#endif - - /* Initialize the new symbol. */ - S_SET_NAME (def_symbol_in_progress, symbol_name_copy); - /* free(symbol_name_copy); */ - def_symbol_in_progress->sy_name_offset = (unsigned long) ~0; - def_symbol_in_progress->sy_number = ~0; - def_symbol_in_progress->sy_frag = &zero_address_frag; - S_SET_VALUE (def_symbol_in_progress, 0); - - if (S_IS_STRING (def_symbol_in_progress)) - SF_SET_STRING (def_symbol_in_progress); - - *input_line_pointer = name_end; - - demand_empty_rest_of_line (); -} - -static void -c_symbol_merge (symbolS *debug, symbolS *normal) -{ - S_SET_DATA_TYPE (normal, S_GET_DATA_TYPE (debug)); - S_SET_STORAGE_CLASS (normal, S_GET_STORAGE_CLASS (debug)); - - if (S_GET_NUMBER_AUXILIARY (debug) > S_GET_NUMBER_AUXILIARY (normal)) - S_SET_NUMBER_AUXILIARY (normal, S_GET_NUMBER_AUXILIARY (debug)); - - if (S_GET_NUMBER_AUXILIARY (debug) > 0) - memcpy ((char *) &normal->sy_symbol.ost_auxent[0], - (char *) &debug->sy_symbol.ost_auxent[0], - (unsigned int) (S_GET_NUMBER_AUXILIARY (debug) * AUXESZ)); - - /* Move the debug flags. */ - SF_SET_DEBUG_FIELD (normal, SF_GET_DEBUG_FIELD (debug)); -} - -static unsigned int dim_index; - -static void -obj_coff_endef (int ignore ATTRIBUTE_UNUSED) -{ - symbolS *symbolP = 0; - - dim_index = 0; - if (def_symbol_in_progress == NULL) - { - as_warn (_(".endef pseudo-op used outside of .def/.endef: ignored.")); - demand_empty_rest_of_line (); - return; - } - - /* Set the section number according to storage class. */ - switch (S_GET_STORAGE_CLASS (def_symbol_in_progress)) - { - case C_STRTAG: - case C_ENTAG: - case C_UNTAG: - SF_SET_TAG (def_symbol_in_progress); - /* Fall through. */ - - case C_FILE: - case C_TPDEF: - SF_SET_DEBUG (def_symbol_in_progress); - S_SET_SEGMENT (def_symbol_in_progress, SEG_DEBUG); - break; - - case C_EFCN: - /* Do not emit this symbol. */ - SF_SET_LOCAL (def_symbol_in_progress); - /* Fall through. */ - - case C_BLOCK: - /* Will need processing before writing. */ - SF_SET_PROCESS (def_symbol_in_progress); - /* Fall through. */ - - case C_FCN: - S_SET_SEGMENT (def_symbol_in_progress, SEG_E0); - - if (streq (S_GET_NAME (def_symbol_in_progress), ".bf")) - { - if (function_lineoff < 0) - fprintf (stderr, _("`.bf' symbol without preceding function\n")); - - SA_GET_SYM_LNNOPTR (last_line_symbol) = function_lineoff; - - SF_SET_PROCESS (last_line_symbol); - SF_SET_ADJ_LNNOPTR (last_line_symbol); - SF_SET_PROCESS (def_symbol_in_progress); - function_lineoff = -1; - } - - /* Value is always set to . */ - def_symbol_in_progress->sy_frag = frag_now; - S_SET_VALUE (def_symbol_in_progress, (valueT) frag_now_fix ()); - break; - -#ifdef C_AUTOARG - case C_AUTOARG: -#endif /* C_AUTOARG */ - case C_AUTO: - case C_REG: - case C_MOS: - case C_MOE: - case C_MOU: - case C_ARG: - case C_REGPARM: - case C_FIELD: - case C_EOS: - SF_SET_DEBUG (def_symbol_in_progress); - S_SET_SEGMENT (def_symbol_in_progress, absolute_section); - break; - - case C_EXT: - case C_WEAKEXT: -#ifdef TE_PE - case C_NT_WEAK: -#endif - case C_STAT: - case C_LABEL: - /* Valid but set somewhere else (s_comm, s_lcomm, colon). */ - break; - - case C_USTATIC: - case C_EXTDEF: - case C_ULABEL: - as_warn (_("unexpected storage class %d"), S_GET_STORAGE_CLASS (def_symbol_in_progress)); - break; - } - - /* Now that we have built a debug symbol, try to find if we should - merge with an existing symbol or not. If a symbol is C_EFCN or - absolute_section or untagged SEG_DEBUG it never merges. We also - don't merge labels, which are in a different namespace, nor - symbols which have not yet been defined since they are typically - unique, nor do we merge tags with non-tags. */ - - /* Two cases for functions. Either debug followed by definition or - definition followed by debug. For definition first, we will - merge the debug symbol into the definition. For debug first, the - lineno entry MUST point to the definition function or else it - will point off into space when crawl_symbols() merges the debug - symbol into the real symbol. Therefor, let's presume the debug - symbol is a real function reference. */ - - /* FIXME-SOON If for some reason the definition label/symbol is - never seen, this will probably leave an undefined symbol at link - time. */ - - if (S_GET_STORAGE_CLASS (def_symbol_in_progress) == C_EFCN - || S_GET_STORAGE_CLASS (def_symbol_in_progress) == C_LABEL - || (S_GET_SEGMENT (def_symbol_in_progress) == SEG_DEBUG - && !SF_GET_TAG (def_symbol_in_progress)) - || S_GET_SEGMENT (def_symbol_in_progress) == absolute_section - || def_symbol_in_progress->sy_value.X_op != O_constant - || (symbolP = symbol_find (S_GET_NAME (def_symbol_in_progress))) == NULL - || (SF_GET_TAG (def_symbol_in_progress) != SF_GET_TAG (symbolP))) - { - symbol_append (def_symbol_in_progress, symbol_lastP, &symbol_rootP, - &symbol_lastP); - } - else - { - /* This symbol already exists, merge the newly created symbol - into the old one. This is not mandatory. The linker can - handle duplicate symbols correctly. But I guess that it save - a *lot* of space if the assembly file defines a lot of - symbols. [loic] */ - - /* The debug entry (def_symbol_in_progress) is merged into the - previous definition. */ - - c_symbol_merge (def_symbol_in_progress, symbolP); - /* FIXME-SOON Should *def_symbol_in_progress be free'd? xoxorich. */ - def_symbol_in_progress = symbolP; - - if (SF_GET_FUNCTION (def_symbol_in_progress) - || SF_GET_TAG (def_symbol_in_progress) - || S_GET_STORAGE_CLASS (def_symbol_in_progress) == C_STAT) - { - /* For functions, and tags, and static symbols, the symbol - *must* be where the debug symbol appears. Move the - existing symbol to the current place. */ - /* If it already is at the end of the symbol list, do nothing. */ - if (def_symbol_in_progress != symbol_lastP) - { - symbol_remove (def_symbol_in_progress, &symbol_rootP, - &symbol_lastP); - symbol_append (def_symbol_in_progress, symbol_lastP, - &symbol_rootP, &symbol_lastP); - } - } - } - - if (SF_GET_TAG (def_symbol_in_progress)) - { - symbolS *oldtag; - - oldtag = symbol_find (S_GET_NAME (def_symbol_in_progress)); - if (oldtag == NULL || ! SF_GET_TAG (oldtag)) - tag_insert (S_GET_NAME (def_symbol_in_progress), - def_symbol_in_progress); - } - - if (SF_GET_FUNCTION (def_symbol_in_progress)) - { - know (sizeof (def_symbol_in_progress) <= sizeof (long)); - function_lineoff - = c_line_new (def_symbol_in_progress, 0, 0, &zero_address_frag); - - SF_SET_PROCESS (def_symbol_in_progress); - - if (symbolP == NULL) - /* That is, if this is the first time we've seen the function. */ - symbol_table_insert (def_symbol_in_progress); - } - - def_symbol_in_progress = NULL; - demand_empty_rest_of_line (); -} - -static void -obj_coff_dim (int ignore ATTRIBUTE_UNUSED) -{ - int dim_index; - - if (def_symbol_in_progress == NULL) - { - as_warn (_(".dim pseudo-op used outside of .def/.endef: ignored.")); - demand_empty_rest_of_line (); - return; - } - - S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1); - - for (dim_index = 0; dim_index < DIMNUM; dim_index++) - { - SKIP_WHITESPACES (); - SA_SET_SYM_DIMEN (def_symbol_in_progress, dim_index, - get_absolute_expression ()); - - switch (*input_line_pointer) - { - case ',': - input_line_pointer++; - break; - - default: - as_warn (_("badly formed .dim directive ignored")); - /* Fall through. */ - - case '\n': - case ';': - dim_index = DIMNUM; - break; - } - } - - demand_empty_rest_of_line (); -} - -static void -obj_coff_line (int ignore ATTRIBUTE_UNUSED) -{ - int this_base; - const char *name; - - if (def_symbol_in_progress == NULL) - { - obj_coff_ln (0); - return; - } - - name = S_GET_NAME (def_symbol_in_progress); - this_base = get_absolute_expression (); - - /* Only .bf symbols indicate the use of a new base line number; the - line numbers associated with .ef, .bb, .eb are relative to the - start of the containing function. */ - if (streq (".bf", name)) - { - line_base = this_base; - -#ifndef NO_LISTING - { - extern int listing; - if (listing) - listing_source_line ((unsigned int) line_base); - } -#endif - } - - S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1); - SA_SET_SYM_LNNO (def_symbol_in_progress, this_base); - - demand_empty_rest_of_line (); -} - -static void -obj_coff_size (int ignore ATTRIBUTE_UNUSED) -{ - if (def_symbol_in_progress == NULL) - { - as_warn (_(".size pseudo-op used outside of .def/.endef ignored.")); - demand_empty_rest_of_line (); - return; - } - - S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1); - SA_SET_SYM_SIZE (def_symbol_in_progress, get_absolute_expression ()); - demand_empty_rest_of_line (); -} - -static void -obj_coff_scl (int ignore ATTRIBUTE_UNUSED) -{ - if (def_symbol_in_progress == NULL) - { - as_warn (_(".scl pseudo-op used outside of .def/.endef ignored.")); - demand_empty_rest_of_line (); - return; - } - - S_SET_STORAGE_CLASS (def_symbol_in_progress, get_absolute_expression ()); - demand_empty_rest_of_line (); -} - -static void -obj_coff_tag (int ignore ATTRIBUTE_UNUSED) -{ - char *symbol_name; - char name_end; - - if (def_symbol_in_progress == NULL) - { - as_warn (_(".tag pseudo-op used outside of .def/.endef ignored.")); - demand_empty_rest_of_line (); - return; - } - - S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1); - symbol_name = input_line_pointer; - name_end = get_symbol_end (); -#ifdef tc_canonicalize_symbol_name - symbol_name = tc_canonicalize_symbol_name (symbol_name); -#endif - - /* Assume that the symbol referred to by .tag is always defined. - This was a bad assumption. I've added find_or_make. xoxorich. */ - SA_SET_SYM_TAGNDX (def_symbol_in_progress, - (long) tag_find_or_make (symbol_name)); - if (SA_GET_SYM_TAGNDX (def_symbol_in_progress) == 0L) - as_warn (_("tag not found for .tag %s"), symbol_name); - - SF_SET_TAGGED (def_symbol_in_progress); - *input_line_pointer = name_end; - - demand_empty_rest_of_line (); -} - -static void -obj_coff_type (int ignore ATTRIBUTE_UNUSED) -{ - if (def_symbol_in_progress == NULL) - { - as_warn (_(".type pseudo-op used outside of .def/.endef ignored.")); - demand_empty_rest_of_line (); - return; - } - - S_SET_DATA_TYPE (def_symbol_in_progress, get_absolute_expression ()); - - if (ISFCN (S_GET_DATA_TYPE (def_symbol_in_progress)) && - S_GET_STORAGE_CLASS (def_symbol_in_progress) != C_TPDEF) - SF_SET_FUNCTION (def_symbol_in_progress); - - demand_empty_rest_of_line (); -} - -static void -obj_coff_val (int ignore ATTRIBUTE_UNUSED) -{ - if (def_symbol_in_progress == NULL) - { - as_warn (_(".val pseudo-op used outside of .def/.endef ignored.")); - demand_empty_rest_of_line (); - return; - } - - if (is_name_beginner (*input_line_pointer)) - { - char *symbol_name = input_line_pointer; - char name_end = get_symbol_end (); - -#ifdef tc_canonicalize_symbol_name - symbol_name = tc_canonicalize_symbol_name (symbol_name); -#endif - - if (streq (symbol_name, ".")) - { - def_symbol_in_progress->sy_frag = frag_now; - S_SET_VALUE (def_symbol_in_progress, (valueT) frag_now_fix ()); - /* If the .val is != from the .def (e.g. statics). */ - } - else if (! streq (S_GET_NAME (def_symbol_in_progress), symbol_name)) - { - def_symbol_in_progress->sy_value.X_op = O_symbol; - def_symbol_in_progress->sy_value.X_add_symbol = - symbol_find_or_make (symbol_name); - def_symbol_in_progress->sy_value.X_op_symbol = NULL; - def_symbol_in_progress->sy_value.X_add_number = 0; - - /* If the segment is undefined when the forward reference is - resolved, then copy the segment id from the forward - symbol. */ - SF_SET_GET_SEGMENT (def_symbol_in_progress); - - /* FIXME: gcc can generate address expressions here in - unusual cases (search for "obscure" in sdbout.c). We - just ignore the offset here, thus generating incorrect - debugging information. We ignore the rest of the line - just below. */ - } - /* Otherwise, it is the name of a non debug symbol and - its value will be calculated later. */ - *input_line_pointer = name_end; - - /* FIXME: this is to avoid an error message in the - FIXME case mentioned just above. */ - while (! is_end_of_line[(unsigned char) *input_line_pointer]) - ++input_line_pointer; - } - else - { - S_SET_VALUE (def_symbol_in_progress, - (valueT) get_absolute_expression ()); - } - - demand_empty_rest_of_line (); -} - -#ifdef TE_PE - -/* Handle the .linkonce pseudo-op. This is parsed by s_linkonce in - read.c, which then calls this object file format specific routine. */ - -void -obj_coff_pe_handle_link_once (enum linkonce_type type) -{ - seg_info (now_seg)->scnhdr.s_flags |= IMAGE_SCN_LNK_COMDAT; - - /* We store the type in the seg_info structure, and use it to set up - the auxiliary entry for the section symbol in c_section_symbol. */ - seg_info (now_seg)->linkonce = type; -} - -#endif /* TE_PE */ - -void -coff_obj_read_begin_hook (void) -{ - /* These had better be the same. Usually 18 bytes. */ -#ifndef BFD_HEADERS - know (sizeof (SYMENT) == sizeof (AUXENT)); - know (SYMESZ == AUXESZ); -#endif - tag_init (); -} - -/* This function runs through the symbol table and puts all the - externals onto another chain. */ - -/* The chain of globals. */ -symbolS *symbol_globalP; -symbolS *symbol_global_lastP; - -/* The chain of externals. */ -symbolS *symbol_externP; -symbolS *symbol_extern_lastP; - -stack *block_stack; -symbolS *last_functionP; -static symbolS *last_bfP; -symbolS *last_tagP; - -static unsigned int -yank_symbols (void) -{ - symbolS *symbolP; - unsigned int symbol_number = 0; - unsigned int last_file_symno = 0; - struct filename_list *filename_list_scan = filename_list_head; - - for (symbolP = symbol_rootP; - symbolP; - symbolP = symbolP ? symbol_next (symbolP) : symbol_rootP) - { - if (symbolP->sy_mri_common) - { - if (S_GET_STORAGE_CLASS (symbolP) == C_EXT -#ifdef TE_PE - || S_GET_STORAGE_CLASS (symbolP) == C_NT_WEAK -#endif - || S_GET_STORAGE_CLASS (symbolP) == C_WEAKEXT) - as_bad (_("%s: global symbols not supported in common sections"), - S_GET_NAME (symbolP)); - symbol_remove (symbolP, &symbol_rootP, &symbol_lastP); - continue; - } - - if (!SF_GET_DEBUG (symbolP)) - { - /* Debug symbols do not need all this rubbish. */ - symbolS *real_symbolP; - - /* L* and C_EFCN symbols never merge. */ - if (!SF_GET_LOCAL (symbolP) - && !SF_GET_STATICS (symbolP) - && S_GET_STORAGE_CLASS (symbolP) != C_LABEL - && symbolP->sy_value.X_op == O_constant - && (real_symbolP = symbol_find (S_GET_NAME (symbolP))) - && real_symbolP != symbolP) - { - /* FIXME-SOON: where do dups come from? - Maybe tag references before definitions? xoxorich. */ - /* Move the debug data from the debug symbol to the - real symbol. Do NOT do the opposite (i.e. move from - real symbol to debug symbol and remove real symbol from the - list.) Because some pointers refer to the real symbol - whereas no pointers refer to the debug symbol. */ - c_symbol_merge (symbolP, real_symbolP); - /* Replace the current symbol by the real one. */ - /* The symbols will never be the last or the first - because : 1st symbol is .file and 3 last symbols are - .text, .data, .bss. */ - symbol_remove (real_symbolP, &symbol_rootP, &symbol_lastP); - symbol_insert (real_symbolP, symbolP, &symbol_rootP, &symbol_lastP); - symbol_remove (symbolP, &symbol_rootP, &symbol_lastP); - symbolP = real_symbolP; - } - - if (flag_readonly_data_in_text && (S_GET_SEGMENT (symbolP) == SEG_E1)) - S_SET_SEGMENT (symbolP, SEG_E0); - - resolve_symbol_value (symbolP); - - if (S_GET_STORAGE_CLASS (symbolP) == C_NULL) - { - if (!S_IS_DEFINED (symbolP) && !SF_GET_LOCAL (symbolP)) - S_SET_EXTERNAL (symbolP); - - else if (S_GET_SEGMENT (symbolP) == SEG_E0) - S_SET_STORAGE_CLASS (symbolP, C_LABEL); - - else - S_SET_STORAGE_CLASS (symbolP, C_STAT); - } - - /* Mainly to speed up if not -g. */ - if (SF_GET_PROCESS (symbolP)) - { - /* Handle the nested blocks auxiliary info. */ - if (S_GET_STORAGE_CLASS (symbolP) == C_BLOCK) - { - if (streq (S_GET_NAME (symbolP), ".bb")) - stack_push (block_stack, (char *) &symbolP); - else - { - /* .eb */ - symbolS *begin_symbolP; - - begin_symbolP = *(symbolS **) stack_pop (block_stack); - if (begin_symbolP == NULL) - as_warn (_("mismatched .eb")); - else - SA_SET_SYM_ENDNDX (begin_symbolP, symbol_number + 2); - } - } - - /* If we are able to identify the type of a function, and we - are out of a function (last_functionP == 0) then, the - function symbol will be associated with an auxiliary - entry. */ - if (last_functionP == NULL && SF_GET_FUNCTION (symbolP)) - { - last_functionP = symbolP; - - if (S_GET_NUMBER_AUXILIARY (symbolP) < 1) - S_SET_NUMBER_AUXILIARY (symbolP, 1); - } - - if (S_GET_STORAGE_CLASS (symbolP) == C_FCN) - { - if (streq (S_GET_NAME (symbolP), ".bf")) - { - if (last_bfP != NULL) - SA_SET_SYM_ENDNDX (last_bfP, symbol_number); - last_bfP = symbolP; - } - } - else if (S_GET_STORAGE_CLASS (symbolP) == C_EFCN) - { - /* I don't even know if this is needed for sdb. But - the standard assembler generates it, so... */ - if (last_functionP == NULL) - as_fatal (_("C_EFCN symbol out of scope")); - SA_SET_SYM_FSIZE (last_functionP, - (long) (S_GET_VALUE (symbolP) - - S_GET_VALUE (last_functionP))); - SA_SET_SYM_ENDNDX (last_functionP, symbol_number); - last_functionP = NULL; - } - } - } - else if (SF_GET_TAG (symbolP)) - /* First descriptor of a structure must point to - the first slot after the structure description. */ - last_tagP = symbolP; - - else if (S_GET_STORAGE_CLASS (symbolP) == C_EOS) - /* +2 take in account the current symbol. */ - SA_SET_SYM_ENDNDX (last_tagP, symbol_number + 2); - - else if (S_GET_STORAGE_CLASS (symbolP) == C_FILE) - { - /* If the filename was too long to fit in the - auxent, put it in the string table. */ - if (SA_GET_FILE_FNAME_ZEROS (symbolP) == 0 - && SA_GET_FILE_FNAME_OFFSET (symbolP) != 0) - { - SA_SET_FILE_FNAME_OFFSET (symbolP, string_byte_count); - string_byte_count += strlen (filename_list_scan->filename) + 1; - filename_list_scan = filename_list_scan->next; - } - if (S_GET_VALUE (symbolP)) - { - S_SET_VALUE (symbolP, last_file_symno); - last_file_symno = symbol_number; - } - } - -#ifdef tc_frob_coff_symbol - tc_frob_coff_symbol (symbolP); -#endif - - /* We must put the external symbols apart. The loader - does not bomb if we do not. But the references in - the endndx field for a .bb symbol are not corrected - if an external symbol is removed between .bb and .be. - I.e in the following case : - [20] .bb endndx = 22 - [21] foo external - [22] .be - ld will move the symbol 21 to the end of the list but - endndx will still be 22 instead of 21. */ - - if (SF_GET_LOCAL (symbolP)) - /* Remove C_EFCN and LOCAL (L...) symbols. */ - /* Next pointer remains valid. */ - symbol_remove (symbolP, &symbol_rootP, &symbol_lastP); - - else if (symbolP->sy_value.X_op == O_symbol - && (! S_IS_DEFINED (symbolP) || S_IS_COMMON (symbolP))) - /* Skip symbols which were equated to undefined or common - symbols. */ - symbol_remove (symbolP, &symbol_rootP, &symbol_lastP); - - else if (!S_IS_DEFINED (symbolP) - && !S_IS_DEBUG (symbolP) - && !SF_GET_STATICS (symbolP) - && (S_GET_STORAGE_CLASS (symbolP) == C_EXT -#ifdef TE_PE - || S_GET_STORAGE_CLASS (symbolP) == C_NT_WEAK -#endif - || S_GET_STORAGE_CLASS (symbolP) == C_WEAKEXT)) - { - /* If external, Remove from the list. */ - symbolS *hold = symbol_previous (symbolP); - - symbol_remove (symbolP, &symbol_rootP, &symbol_lastP); - symbol_clear_list_pointers (symbolP); - symbol_append (symbolP, symbol_extern_lastP, &symbol_externP, &symbol_extern_lastP); - symbolP = hold; - } - else if (! S_IS_DEBUG (symbolP) - && ! SF_GET_STATICS (symbolP) - && ! SF_GET_FUNCTION (symbolP) - && (S_GET_STORAGE_CLASS (symbolP) == C_EXT -#ifdef TE_PE - || S_GET_STORAGE_CLASS (symbolP) == C_NT_WEAK -#endif - || S_GET_STORAGE_CLASS (symbolP) == C_NT_WEAK)) - { - symbolS *hold = symbol_previous (symbolP); - - /* The O'Reilly COFF book says that defined global symbols - come at the end of the symbol table, just before - undefined global symbols. */ - symbol_remove (symbolP, &symbol_rootP, &symbol_lastP); - symbol_clear_list_pointers (symbolP); - symbol_append (symbolP, symbol_global_lastP, &symbol_globalP, - &symbol_global_lastP); - symbolP = hold; - } - else - { - if (SF_GET_STRING (symbolP)) - { - symbolP->sy_name_offset = string_byte_count; - string_byte_count += strlen (S_GET_NAME (symbolP)) + 1; - } - else - symbolP->sy_name_offset = 0; - - symbolP->sy_number = symbol_number; - symbol_number += 1 + S_GET_NUMBER_AUXILIARY (symbolP); - } - } - - return symbol_number; -} - -static unsigned int -glue_symbols (symbolS **head, symbolS **tail) -{ - unsigned int symbol_number = 0; - - while (*head != NULL) - { - symbolS *tmp = *head; - - /* Append. */ - symbol_remove (tmp, head, tail); - symbol_append (tmp, symbol_lastP, &symbol_rootP, &symbol_lastP); - - /* Process. */ - if (SF_GET_STRING (tmp)) - { - tmp->sy_name_offset = string_byte_count; - string_byte_count += strlen (S_GET_NAME (tmp)) + 1; - } - else - /* Fix "long" names. */ - tmp->sy_name_offset = 0; - - tmp->sy_number = symbol_number; - symbol_number += 1 + S_GET_NUMBER_AUXILIARY (tmp); - } - - return symbol_number; -} - -static unsigned int -tie_tags (void) -{ - unsigned int symbol_number = 0; - symbolS *symbolP; - - for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP)) - { - symbolP->sy_number = symbol_number; - - if (SF_GET_TAGGED (symbolP)) - { - SA_SET_SYM_TAGNDX - (symbolP, - ((symbolS *) SA_GET_SYM_TAGNDX (symbolP))->sy_number); - } - - symbol_number += 1 + S_GET_NUMBER_AUXILIARY (symbolP); - } - - return symbol_number; -} - - -/* Build a 'section static' symbol. */ - -static symbolS * -c_section_symbol (char *name, int idx) -{ - symbolS *symbolP; - - symbolP = symbol_find (name); - if (symbolP == NULL) - symbolP = symbol_new (name, idx, 0, &zero_address_frag); - else - { - /* Mmmm. I just love violating interfaces. Makes me feel...dirty. */ - S_SET_SEGMENT (symbolP, idx); - symbolP->sy_frag = &zero_address_frag; - } - - S_SET_STORAGE_CLASS (symbolP, C_STAT); - S_SET_NUMBER_AUXILIARY (symbolP, 1); - - SF_SET_STATICS (symbolP); - -#ifdef TE_DELTA - /* manfred@s-direktnet.de: section symbols *must* have the LOCAL bit cleared, - which is set by the new definition of LOCAL_LABEL in tc-m68k.h. */ - SF_CLEAR_LOCAL (symbolP); -#endif -#ifdef TE_PE - /* If the .linkonce pseudo-op was used for this section, we must - store the information in the auxiliary entry for the section - symbol. */ - if (segment_info[idx].linkonce != LINKONCE_UNSET) - { - int type; - - switch (segment_info[idx].linkonce) - { - default: - abort (); - case LINKONCE_DISCARD: - type = IMAGE_COMDAT_SELECT_ANY; - break; - case LINKONCE_ONE_ONLY: - type = IMAGE_COMDAT_SELECT_NODUPLICATES; - break; - case LINKONCE_SAME_SIZE: - type = IMAGE_COMDAT_SELECT_SAME_SIZE; - break; - case LINKONCE_SAME_CONTENTS: - type = IMAGE_COMDAT_SELECT_EXACT_MATCH; - break; - } - - SYM_AUXENT (symbolP)->x_scn.x_comdat = type; - } -#endif /* TE_PE */ - - return symbolP; -} - -static void -crawl_symbols (object_headers *h, bfd *abfd ATTRIBUTE_UNUSED) -{ - unsigned int i; - - /* Initialize the stack used to keep track of the matching .bb .be. */ - block_stack = stack_init (512, sizeof (symbolS *)); - - /* The symbol list should be ordered according to the following sequence - order : - . .file symbol - . debug entries for functions - . fake symbols for the sections, including .text .data and .bss - . defined symbols - . undefined symbols - But this is not mandatory. The only important point is to put the - undefined symbols at the end of the list. */ - - /* Is there a .file symbol ? If not insert one at the beginning. */ - if (symbol_rootP == NULL - || S_GET_STORAGE_CLASS (symbol_rootP) != C_FILE) - c_dot_file_symbol ("fake", 0); - - /* Build up static symbols for the sections, they are filled in later. */ - for (i = SEG_E0; i < SEG_LAST; i++) - if (segment_info[i].scnhdr.s_name[0]) - segment_info[i].dot = c_section_symbol ((char *) segment_info[i].name, - i - SEG_E0 + 1); - - /* Take all the externals out and put them into another chain. */ - H_SET_SYMBOL_TABLE_SIZE (h, yank_symbols ()); - /* Take the externals and glue them onto the end. */ - H_SET_SYMBOL_TABLE_SIZE (h, - (H_GET_SYMBOL_COUNT (h) - + glue_symbols (&symbol_globalP, - &symbol_global_lastP) - + glue_symbols (&symbol_externP, - &symbol_extern_lastP))); - - H_SET_SYMBOL_TABLE_SIZE (h, tie_tags ()); - know (symbol_globalP == NULL); - know (symbol_global_lastP == NULL); - know (symbol_externP == NULL); - know (symbol_extern_lastP == NULL); -} - -/* Find strings by crawling along symbol table chain. */ - -static void -w_strings (char *where) -{ - symbolS *symbolP; - struct filename_list *filename_list_scan = filename_list_head; - - /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK. */ - md_number_to_chars (where, (valueT) string_byte_count, 4); - where += 4; - -#ifdef COFF_LONG_SECTION_NAMES - /* Support long section names as found in PE. This code must - coordinate with that in coff_header_append and write_object_file. */ - { - unsigned int i; - - for (i = SEG_E0; i < SEG_LAST; i++) - { - if (segment_info[i].scnhdr.s_name[0] - && strlen (segment_info[i].name) > SCNNMLEN) - { - unsigned int size; - - size = strlen (segment_info[i].name) + 1; - memcpy (where, segment_info[i].name, size); - where += size; - } - } - } -#endif /* COFF_LONG_SECTION_NAMES */ - - for (symbolP = symbol_rootP; - symbolP; - symbolP = symbol_next (symbolP)) - { - unsigned int size; - - if (SF_GET_STRING (symbolP)) - { - size = strlen (S_GET_NAME (symbolP)) + 1; - memcpy (where, S_GET_NAME (symbolP), size); - where += size; - } - if (S_GET_STORAGE_CLASS (symbolP) == C_FILE - && SA_GET_FILE_FNAME_ZEROS (symbolP) == 0 - && SA_GET_FILE_FNAME_OFFSET (symbolP) != 0) - { - size = strlen (filename_list_scan->filename) + 1; - memcpy (where, filename_list_scan->filename, size); - filename_list_scan = filename_list_scan ->next; - where += size; - } - } -} - -static void -do_linenos_for (bfd * abfd, - object_headers * h, - unsigned long *file_cursor) -{ - unsigned int idx; - unsigned long start = *file_cursor; - - for (idx = SEG_E0; idx < SEG_LAST; idx++) - { - segment_info_type *s = segment_info + idx; - - if (s->scnhdr.s_nlnno != 0) - { - struct lineno_list *line_ptr; - struct external_lineno *buffer = xmalloc (s->scnhdr.s_nlnno * LINESZ); - struct external_lineno *dst = buffer; - - /* Run through the table we've built and turn it into its external - form, take this chance to remove duplicates. */ - - for (line_ptr = s->lineno_list_head; - line_ptr != (struct lineno_list *) NULL; - line_ptr = line_ptr->next) - { - if (line_ptr->line.l_lnno == 0) - { - /* Turn a pointer to a symbol into the symbols' index, - provided that it has been initialised. */ - if (line_ptr->line.l_addr.l_symndx) - line_ptr->line.l_addr.l_symndx = - ((symbolS *) line_ptr->line.l_addr.l_symndx)->sy_number; - } - else - line_ptr->line.l_addr.l_paddr += ((struct frag *) (line_ptr->frag))->fr_address; - - (void) bfd_coff_swap_lineno_out (abfd, &(line_ptr->line), dst); - dst++; - } - - s->scnhdr.s_lnnoptr = *file_cursor; - - bfd_bwrite (buffer, (bfd_size_type) s->scnhdr.s_nlnno * LINESZ, abfd); - free (buffer); - - *file_cursor += s->scnhdr.s_nlnno * LINESZ; - } - } - - H_SET_LINENO_SIZE (h, *file_cursor - start); -} - -/* Now we run through the list of frag chains in a segment and - make all the subsegment frags appear at the end of the - list, as if the seg 0 was extra long. */ - -static void -remove_subsegs (void) -{ - unsigned int i; - - for (i = SEG_E0; i < SEG_UNKNOWN; i++) - { - frchainS *head = segment_info[i].frchainP; - fragS dummy; - fragS *prev_frag = &dummy; - - while (head && head->frch_seg == i) - { - prev_frag->fr_next = head->frch_root; - prev_frag = head->frch_last; - head = head->frch_next; - } - prev_frag->fr_next = 0; - } -} - -unsigned long machine; -int coff_flags; - -#ifndef SUB_SEGMENT_ALIGN -#ifdef HANDLE_ALIGN -/* The last subsegment gets an alignment corresponding to the alignment - of the section. This allows proper nop-filling at the end of - code-bearing sections. */ -#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) \ - (!(FRCHAIN)->frch_next || (FRCHAIN)->frch_next->frch_seg != (SEG) \ - ? get_recorded_alignment (SEG) : 0) -#else -#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 1 -#endif -#endif - -static void -w_symbols (bfd * abfd, char *where, symbolS * symbol_rootP) -{ - symbolS *symbolP; - unsigned int i; - - /* First fill in those values we have only just worked out. */ - for (i = SEG_E0; i < SEG_LAST; i++) - { - symbolP = segment_info[i].dot; - if (symbolP) - { - SA_SET_SCN_SCNLEN (symbolP, segment_info[i].scnhdr.s_size); - SA_SET_SCN_NRELOC (symbolP, segment_info[i].scnhdr.s_nreloc); - SA_SET_SCN_NLINNO (symbolP, segment_info[i].scnhdr.s_nlnno); - } - } - - /* 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; - - /* We can't fix the lnnoptr field in yank_symbols with the other - adjustments, because we have to wait until we know where they - go in the file. */ - if (SF_GET_ADJ_LNNOPTR (symbolP)) - SA_GET_SYM_LNNOPTR (symbolP) += - segment_info[S_GET_SEGMENT (symbolP)].scnhdr.s_lnnoptr; - - tc_coff_symbol_emit_hook (symbolP); - - temp = S_GET_NAME (symbolP); - if (SF_GET_STRING (symbolP)) - { - S_SET_OFFSET (symbolP, symbolP->sy_name_offset); - S_SET_ZEROES (symbolP, 0); - } - else - { - memset (symbolP->sy_symbol.ost_entry.n_name, 0, SYMNMLEN); - strncpy (symbolP->sy_symbol.ost_entry.n_name, temp, SYMNMLEN); - } - where = symbol_to_chars (abfd, where, symbolP); - S_SET_NAME (symbolP, temp); - } -} - -static void -fixup_mdeps (fragS *frags, - object_headers *h ATTRIBUTE_UNUSED, - segT this_segment) -{ - subseg_change (this_segment, 0); - - while (frags) - { - switch (frags->fr_type) - { - case rs_align: - case rs_align_code: - case rs_align_test: - case rs_org: -#ifdef HANDLE_ALIGN - HANDLE_ALIGN (frags); -#endif - frags->fr_type = rs_fill; - frags->fr_offset = - ((frags->fr_next->fr_address - frags->fr_address - frags->fr_fix) - / frags->fr_var); - break; - case rs_machine_dependent: - md_convert_frag (h, this_segment, frags); - frag_wane (frags); - break; - default: - ; - } - frags = frags->fr_next; - } -} - -#ifndef TC_FORCE_RELOCATION -#define TC_FORCE_RELOCATION(fix) 0 -#endif - -static void -fixup_segment (segment_info_type * segP, segT this_segment_type) -{ - fixS * fixP; - symbolS *add_symbolP; - symbolS *sub_symbolP; - long add_number; - int size; - char *place; - long where; - char pcrel; - fragS *fragP; - segT add_symbol_segment = absolute_section; - - for (fixP = segP->fix_root; fixP; fixP = fixP->fx_next) - { - fragP = fixP->fx_frag; - know (fragP); - where = fixP->fx_where; - place = fragP->fr_literal + where; - size = fixP->fx_size; - add_symbolP = fixP->fx_addsy; - sub_symbolP = fixP->fx_subsy; - add_number = fixP->fx_offset; - pcrel = fixP->fx_pcrel; - - /* We want function-relative stabs to work on systems which - may use a relaxing linker; thus we must handle the sym1-sym2 - fixups function-relative stabs generates. - - Of course, if you actually enable relaxing in the linker, the - line and block scoping information is going to be incorrect - in some cases. The only way to really fix this is to support - a reloc involving the difference of two symbols. */ - if (linkrelax - && (!sub_symbolP || pcrel)) - continue; - -#ifdef TC_I960 - if (fixP->fx_tcbit && SF_GET_CALLNAME (add_symbolP)) - { - /* Relocation should be done via the associated 'bal' entry - point symbol. */ - if (!SF_GET_BALNAME (tc_get_bal_of_call (add_symbolP))) - { - as_bad_where (fixP->fx_file, fixP->fx_line, - _("No 'bal' entry point for leafproc %s"), - S_GET_NAME (add_symbolP)); - continue; - } - fixP->fx_addsy = add_symbolP = tc_get_bal_of_call (add_symbolP); - } -#endif - - /* Make sure the symbols have been resolved; this may not have - happened if these are expression symbols. */ - if (add_symbolP != NULL && ! add_symbolP->sy_resolved) - resolve_symbol_value (add_symbolP); - - if (add_symbolP != NULL) - { - /* If this fixup is against a symbol which has been equated - to another symbol, convert it to the other symbol. */ - if (add_symbolP->sy_value.X_op == O_symbol - && (! S_IS_DEFINED (add_symbolP) - || S_IS_COMMON (add_symbolP))) - { - while (add_symbolP->sy_value.X_op == O_symbol - && (! S_IS_DEFINED (add_symbolP) - || S_IS_COMMON (add_symbolP))) - { - symbolS *n; - - /* We must avoid looping, as that can occur with a - badly written program. */ - n = add_symbolP->sy_value.X_add_symbol; - if (n == add_symbolP) - break; - add_number += add_symbolP->sy_value.X_add_number; - add_symbolP = n; - } - fixP->fx_addsy = add_symbolP; - fixP->fx_offset = add_number; - } - } - - if (sub_symbolP != NULL && ! sub_symbolP->sy_resolved) - resolve_symbol_value (sub_symbolP); - - if (add_symbolP != NULL - && add_symbolP->sy_mri_common) - { - add_number += S_GET_VALUE (add_symbolP); - fixP->fx_offset = add_number; - add_symbolP = fixP->fx_addsy = add_symbolP->sy_value.X_add_symbol; - } - - if (add_symbolP) - add_symbol_segment = S_GET_SEGMENT (add_symbolP); - - if (sub_symbolP) - { - if (add_symbolP == NULL || add_symbol_segment == absolute_section) - { - if (add_symbolP != NULL) - { - add_number += S_GET_VALUE (add_symbolP); - add_symbolP = NULL; - fixP->fx_addsy = NULL; - } - - /* It's just -sym. */ - if (S_GET_SEGMENT (sub_symbolP) == absolute_section) - { - add_number -= S_GET_VALUE (sub_symbolP); - fixP->fx_subsy = 0; - fixP->fx_done = 1; - } - else - { -#ifndef TC_M68K - as_bad_where (fixP->fx_file, fixP->fx_line, - _("Negative of non-absolute symbol %s"), - S_GET_NAME (sub_symbolP)); -#endif - add_number -= S_GET_VALUE (sub_symbolP); - } /* not absolute */ - - /* If sub_symbol is in the same segment that add_symbol - and add_symbol is either in DATA, TEXT, BSS or ABSOLUTE. */ - } - else if (S_GET_SEGMENT (sub_symbolP) == add_symbol_segment - && SEG_NORMAL (add_symbol_segment)) - { - /* Difference of 2 symbols from same segment. Can't - make difference of 2 undefineds: 'value' means - something different for N_UNDF. */ -#ifdef TC_I960 - /* Makes no sense to use the difference of 2 arbitrary symbols - as the target of a call instruction. */ - if (fixP->fx_tcbit) - as_bad_where (fixP->fx_file, fixP->fx_line, - _("callj to difference of 2 symbols")); -#endif /* TC_I960 */ - add_number += S_GET_VALUE (add_symbolP) - - S_GET_VALUE (sub_symbolP); - add_symbolP = NULL; - - if (!TC_FORCE_RELOCATION (fixP)) - { - fixP->fx_addsy = NULL; - fixP->fx_subsy = NULL; - fixP->fx_done = 1; -#ifdef TC_M68K /* FIXME: Is this right? */ - pcrel = 0; - fixP->fx_pcrel = 0; -#endif - } - } - else - { - /* Different segments in subtraction. */ - know (!(S_IS_EXTERNAL (sub_symbolP) && (S_GET_SEGMENT (sub_symbolP) == absolute_section))); - - if ((S_GET_SEGMENT (sub_symbolP) == absolute_section)) - add_number -= S_GET_VALUE (sub_symbolP); - -#ifdef DIFF_EXPR_OK - else if (S_GET_SEGMENT (sub_symbolP) == this_segment_type) - { - /* Make it pc-relative. */ - add_number += (md_pcrel_from (fixP) - - S_GET_VALUE (sub_symbolP)); - pcrel = 1; - fixP->fx_pcrel = 1; - sub_symbolP = 0; - fixP->fx_subsy = 0; - } -#endif - else - { - as_bad_where (fixP->fx_file, fixP->fx_line, - _("Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %ld."), - segment_name (S_GET_SEGMENT (sub_symbolP)), - S_GET_NAME (sub_symbolP), - (long) (fragP->fr_address + where)); - } - } - } - - if (add_symbolP) - { - if (add_symbol_segment == this_segment_type && pcrel) - { - /* This fixup was made when the symbol's segment was - SEG_UNKNOWN, but it is now in the local segment. - So we know how to do the address without relocation. */ -#ifdef TC_I960 - /* reloc_callj() may replace a 'call' with a 'calls' or a 'bal', - in which cases it modifies *fixP as appropriate. In the case - of a 'calls', no further work is required, and *fixP has been - set up to make the rest of the code below a no-op. */ - reloc_callj (fixP); -#endif - - add_number += S_GET_VALUE (add_symbolP); - add_number -= md_pcrel_from (fixP); - - /* We used to do - add_number -= segP->scnhdr.s_vaddr; - if defined (TC_I386) || defined (TE_LYNX). I now - think that was an error propagated from the case when - we are going to emit the relocation. If we are not - going to emit the relocation, then we just want to - set add_number to the difference between the symbols. - This is a case that would only arise when there is a - PC relative reference from a section other than .text - to a symbol defined in the same section, and the - reference is not relaxed. Since jump instructions on - the i386 are relaxed, this could only arise with a - call instruction. */ - - /* Lie. Don't want further pcrel processing. */ - pcrel = 0; - if (!TC_FORCE_RELOCATION (fixP)) - { - fixP->fx_addsy = NULL; - fixP->fx_done = 1; - } - } - else - { - switch (add_symbol_segment) - { - case absolute_section: -#ifdef TC_I960 - /* See comment about reloc_callj() above. */ - reloc_callj (fixP); -#endif /* TC_I960 */ - add_number += S_GET_VALUE (add_symbolP); - add_symbolP = NULL; - - if (!TC_FORCE_RELOCATION (fixP)) - { - fixP->fx_addsy = NULL; - fixP->fx_done = 1; - } - break; - default: - -#if defined(TC_A29K) || (defined(TE_PE) && defined(TC_I386)) || defined(TC_M88K) || defined(TC_OR32) - /* This really should be handled in the linker, but - backward compatibility forbids. */ - add_number += S_GET_VALUE (add_symbolP); -#else - add_number += S_GET_VALUE (add_symbolP) + - segment_info[S_GET_SEGMENT (add_symbolP)].scnhdr.s_paddr; -#endif - break; - - case SEG_UNKNOWN: -#ifdef TC_I960 - if ((int) fixP->fx_bit_fixP == 13) - { - /* This is a COBR instruction. They have only a - 13-bit displacement and are only to be used - for local branches: flag as error, don't generate - relocation. */ - as_bad_where (fixP->fx_file, fixP->fx_line, - _("can't use COBR format with external label")); - fixP->fx_addsy = NULL; - fixP->fx_done = 1; - continue; - } -#endif /* TC_I960 */ -#if ((defined (TC_I386) || defined (TE_LYNX) || defined (TE_AUX)) && !defined(TE_PE)) || defined (COFF_COMMON_ADDEND) - /* 386 COFF uses a peculiar format in which the - value of a common symbol is stored in the .text - segment (I've checked this on SVR3.2 and SCO - 3.2.2) Ian Taylor <ian@cygnus.com>. */ - /* This is also true for 68k COFF on sysv machines - (Checked on Motorola sysv68 R3V6 and R3V7.1, and also on - UNIX System V/M68000, Release 1.0 from ATT/Bell Labs) - Philippe De Muyter <phdm@info.ucl.ac.be>. */ - if (S_IS_COMMON (add_symbolP)) - add_number += S_GET_VALUE (add_symbolP); -#endif - break; - - } - } - } - - if (pcrel) - { -#if !defined(TC_M88K) && !(defined(TE_PE) && defined(TC_I386)) && !defined(TC_A29K) && !defined(TC_OR32) - /* This adjustment is not correct on the m88k, for which the - linker does all the computation. */ - add_number -= md_pcrel_from (fixP); -#endif - if (add_symbolP == 0) - fixP->fx_addsy = &abs_symbol; -#if defined (TC_I386) || defined (TE_LYNX) || defined (TC_I960) || defined (TC_M68K) - /* On the 386 we must adjust by the segment vaddr as well. - Ian Taylor. - - I changed the i960 to work this way as well. This is - compatible with the current GNU linker behaviour. I do - not know what other i960 COFF assemblers do. This is not - a common case: normally, only assembler code will contain - a PC relative reloc, and only branches which do not - originate in the .text section will have a non-zero - address. - - I changed the m68k to work this way as well. This will - break existing PC relative relocs from sections which do - not start at address 0, but it will make ld -r work. - Ian Taylor, 4 Oct 96. */ - - add_number -= segP->scnhdr.s_vaddr; -#endif - } - - md_apply_fix (fixP, (valueT *) & add_number, this_segment_type); - - if (!fixP->fx_bit_fixP && ! fixP->fx_no_overflow) - { -#ifndef TC_M88K - /* The m88k uses the offset field of the reloc to get around - this problem. */ - if ((size == 1 - && ((add_number & ~0xFF) - || (fixP->fx_signed && (add_number & 0x80))) - && ((add_number & ~0xFF) != (-1 & ~0xFF) - || (add_number & 0x80) == 0)) - || (size == 2 - && ((add_number & ~0xFFFF) - || (fixP->fx_signed && (add_number & 0x8000))) - && ((add_number & ~0xFFFF) != (-1 & ~0xFFFF) - || (add_number & 0x8000) == 0))) - { - as_bad_where (fixP->fx_file, fixP->fx_line, - _("Value of %ld too large for field of %d bytes at 0x%lx"), - (long) add_number, size, - (unsigned long) (fragP->fr_address + where)); - } -#endif -#ifdef WARN_SIGNED_OVERFLOW_WORD - /* Warn if a .word value is too large when treated as a - signed number. We already know it is not too negative. - This is to catch over-large switches generated by gcc on - the 68k. */ - if (!flag_signed_overflow_ok - && size == 2 - && add_number > 0x7fff) - as_bad_where (fixP->fx_file, fixP->fx_line, - _("Signed .word overflow; switch may be too large; %ld at 0x%lx"), - (long) add_number, - (unsigned long) (fragP->fr_address + where)); -#endif - } - } -} - -/* Fill in the counts in the first entry in a .stab section. */ - -static void -adjust_stab_section (bfd *abfd, segT seg) -{ - segT stabstrseg = SEG_UNKNOWN; - const char *secname, *name2; - char *name; - char *p = NULL; - int i, strsz = 0, nsyms; - fragS *frag = segment_info[seg].frchainP->frch_root; - - /* Look for the associated string table section. */ - - secname = segment_info[seg].name; - name = alloca (strlen (secname) + 4); - strcpy (name, secname); - strcat (name, "str"); - - for (i = SEG_E0; i < SEG_UNKNOWN; i++) - { - name2 = segment_info[i].name; - if (name2 != NULL && strneq (name2, name, 8)) - { - stabstrseg = i; - break; - } - } - - /* If we found the section, get its size. */ - if (stabstrseg != SEG_UNKNOWN) - strsz = size_section (abfd, stabstrseg); - - nsyms = size_section (abfd, seg) / 12 - 1; - - /* Look for the first frag of sufficient size for the initial stab - symbol, and collect a pointer to it. */ - while (frag && frag->fr_fix < 12) - frag = frag->fr_next; - assert (frag != 0); - p = frag->fr_literal; - assert (p != 0); - - /* Write in the number of stab symbols and the size of the string - table. */ - bfd_h_put_16 (abfd, (bfd_vma) nsyms, (bfd_byte *) p + 6); - bfd_h_put_32 (abfd, (bfd_vma) strsz, (bfd_byte *) p + 8); -} - -void -write_object_file (void) -{ - int i; - const char *name; - struct frchain *frchain_ptr; - object_headers headers; - unsigned long file_cursor; - bfd *abfd; - unsigned int addr; - abfd = bfd_openw (out_file_name, TARGET_FORMAT); - - if (abfd == 0) - { - as_perror (_("FATAL: Can't create %s"), out_file_name); - exit (EXIT_FAILURE); - } - bfd_set_format (abfd, bfd_object); - bfd_set_arch_mach (abfd, BFD_ARCH, machine); - - string_byte_count = 4; - - /* 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. */ - for (frchain_ptr = frchain_root; - frchain_ptr != (struct frchain *) NULL; - frchain_ptr = frchain_ptr->frch_next) - { - int alignment; - - subseg_set (frchain_ptr->frch_seg, frchain_ptr->frch_subseg); - - alignment = SUB_SEGMENT_ALIGN (now_seg, frchain_ptr); - -#ifdef md_do_align - md_do_align (alignment, NULL, 0, 0, alignment_done); -#endif - if (subseg_text_p (now_seg)) - frag_align_code (alignment, 0); - else - frag_align (alignment, 0, 0); - -#ifdef md_do_align - alignment_done: -#endif - - frag_wane (frag_now); - frag_now->fr_fix = 0; - know (frag_now->fr_next == NULL); - } - - remove_subsegs (); - - for (i = SEG_E0; i < SEG_UNKNOWN; i++) - relax_segment (segment_info[i].frchainP->frch_root, i); - - /* Relaxation has completed. Freeze all syms. */ - finalize_syms = 1; - - H_SET_NUMBER_OF_SECTIONS (&headers, 0); - - /* Find out how big the sections are, and set the addresses. */ - addr = 0; - for (i = SEG_E0; i < SEG_UNKNOWN; i++) - { - long size; - - segment_info[i].scnhdr.s_paddr = addr; - segment_info[i].scnhdr.s_vaddr = addr; - - if (segment_info[i].scnhdr.s_name[0]) - { - H_SET_NUMBER_OF_SECTIONS (&headers, - H_GET_NUMBER_OF_SECTIONS (&headers) + 1); - -#ifdef COFF_LONG_SECTION_NAMES - /* Support long section names as found in PE. This code - must coordinate with that in coff_header_append and - w_strings. */ - { - unsigned int len; - - len = strlen (segment_info[i].name); - if (len > SCNNMLEN) - string_byte_count += len + 1; - } -#endif /* COFF_LONG_SECTION_NAMES */ - } - - size = size_section (abfd, (unsigned int) i); - addr += size; - - /* I think the section alignment is only used on the i960; the - i960 needs it, and it should do no harm on other targets. */ -#ifdef ALIGNMENT_IN_S_FLAGS - segment_info[i].scnhdr.s_flags |= (section_alignment[i] & 0xF) << 8; -#else - segment_info[i].scnhdr.s_align = 1 << section_alignment[i]; -#endif - - if (i == SEG_E0) - H_SET_TEXT_SIZE (&headers, size); - else if (i == SEG_E1) - H_SET_DATA_SIZE (&headers, size); - else if (i == SEG_E2) - H_SET_BSS_SIZE (&headers, size); - } - - /* Turn the gas native symbol table shape into a coff symbol table. */ - crawl_symbols (&headers, abfd); - - if (string_byte_count == 4) - string_byte_count = 0; - - H_SET_STRING_SIZE (&headers, string_byte_count); - -#ifdef tc_frob_file - tc_frob_file (); -#endif - - for (i = SEG_E0; i < SEG_UNKNOWN; i++) - { - fixup_mdeps (segment_info[i].frchainP->frch_root, &headers, i); - fixup_segment (&segment_info[i], i); - } - - /* Look for ".stab" segments and fill in their initial symbols - correctly. */ - for (i = SEG_E0; i < SEG_UNKNOWN; i++) - { - name = segment_info[i].name; - - if (name != NULL - && strneq (".stab", name, 5) - && ! strneq (".stabstr", name, 8)) - adjust_stab_section (abfd, i); - } - - file_cursor = H_GET_TEXT_FILE_OFFSET (&headers); - - bfd_seek (abfd, (file_ptr) file_cursor, 0); - - /* Plant the data. */ - fill_section (abfd, &headers, &file_cursor); - - do_relocs_for (abfd, &headers, &file_cursor); - - do_linenos_for (abfd, &headers, &file_cursor); - - H_SET_FILE_MAGIC_NUMBER (&headers, COFF_MAGIC); -#ifndef OBJ_COFF_OMIT_TIMESTAMP - H_SET_TIME_STAMP (&headers, (long) time (NULL)); -#else - H_SET_TIME_STAMP (&headers, 0); -#endif -#ifdef TC_COFF_SET_MACHINE - TC_COFF_SET_MACHINE (&headers); -#endif - -#ifndef COFF_FLAGS -#define COFF_FLAGS 0 -#endif - -#ifdef KEEP_RELOC_INFO - H_SET_FLAGS (&headers, ((H_GET_LINENO_SIZE (&headers) ? 0 : F_LNNO) | - COFF_FLAGS | coff_flags)); -#else - H_SET_FLAGS (&headers, ((H_GET_LINENO_SIZE (&headers) ? 0 : F_LNNO) | - (H_GET_RELOCATION_SIZE (&headers) ? 0 : F_RELFLG) | - COFF_FLAGS | coff_flags)); -#endif - - { - unsigned int symtable_size = H_GET_SYMBOL_TABLE_SIZE (&headers); - char *buffer1 = xmalloc (symtable_size + string_byte_count + 1); - - H_SET_SYMBOL_TABLE_POINTER (&headers, bfd_tell (abfd)); - w_symbols (abfd, buffer1, symbol_rootP); - if (string_byte_count > 0) - w_strings (buffer1 + symtable_size); - bfd_bwrite (buffer1, (bfd_size_type) symtable_size + string_byte_count, - abfd); - free (buffer1); - } - - coff_header_append (abfd, &headers); - - { - extern bfd *stdoutput; - stdoutput = abfd; - } -} - -/* Add a new segment. This is called from subseg_new via the - obj_new_segment macro. */ - -segT -obj_coff_add_segment (const char *name) -{ - unsigned int i; - -#ifndef COFF_LONG_SECTION_NAMES - char buf[SCNNMLEN + 1]; - - strncpy (buf, name, SCNNMLEN); - buf[SCNNMLEN] = '\0'; - name = buf; -#endif - - for (i = SEG_E0; i < SEG_LAST && segment_info[i].scnhdr.s_name[0]; i++) - if (streq (name, segment_info[i].name)) - return (segT) i; - - if (i == SEG_LAST) - { - as_bad (_("Too many new sections; can't add \"%s\""), name); - return now_seg; - } - - /* Add a new section. */ - strncpy (segment_info[i].scnhdr.s_name, name, - sizeof (segment_info[i].scnhdr.s_name)); - segment_info[i].scnhdr.s_flags = STYP_REG; - segment_info[i].name = xstrdup (name); - - return (segT) i; -} - -/* Implement the .section pseudo op: - .section name {, "flags"} - ^ ^ - | +--- optional flags: 'b' for bss - | 'i' for info - +-- section name 'l' for lib - 'n' for noload - 'o' for over - 'w' for data - 'd' (apparently m88k for data) - 'x' for text - 'r' for read-only data - But if the argument is not a quoted string, treat it as a - subsegment number. */ - -void -obj_coff_section (int ignore ATTRIBUTE_UNUSED) -{ - /* Strip out the section name. */ - char *section_name, *name; - char c; - unsigned int exp; - long flags; - - if (flag_mri) - { - char type; - - s_mri_sect (&type); - flags = 0; - if (type == 'C') - flags = STYP_TEXT; - else if (type == 'D') - flags = STYP_DATA; - segment_info[now_seg].scnhdr.s_flags |= flags; - - return; - } - - section_name = input_line_pointer; - c = get_symbol_end (); - - name = xmalloc (input_line_pointer - section_name + 1); - strcpy (name, section_name); - - *input_line_pointer = c; - - exp = 0; - flags = 0; - - SKIP_WHITESPACE (); - if (*input_line_pointer == ',') - { - ++input_line_pointer; - SKIP_WHITESPACE (); - - if (*input_line_pointer != '"') - exp = get_absolute_expression (); - else - { - ++input_line_pointer; - while (*input_line_pointer != '"' - && ! is_end_of_line[(unsigned char) *input_line_pointer]) - { - switch (*input_line_pointer) - { - case 'b': flags |= STYP_BSS; break; - case 'i': flags |= STYP_INFO; break; - case 'l': flags |= STYP_LIB; break; - case 'n': flags |= STYP_NOLOAD; break; - case 'o': flags |= STYP_OVER; break; - case 'd': - case 'w': flags |= STYP_DATA; break; - case 'x': flags |= STYP_TEXT; break; - case 'r': flags |= STYP_LIT; break; - default: - as_warn (_("unknown section attribute '%c'"), - *input_line_pointer); - break; - } - ++input_line_pointer; - } - if (*input_line_pointer == '"') - ++input_line_pointer; - } - } - - subseg_new (name, (subsegT) exp); - - segment_info[now_seg].scnhdr.s_flags |= flags; - - demand_empty_rest_of_line (); -} - -static void -obj_coff_text (int ignore ATTRIBUTE_UNUSED) -{ - subseg_new (".text", get_absolute_expression ()); -} - -static void -obj_coff_data (int ignore ATTRIBUTE_UNUSED) -{ - if (flag_readonly_data_in_text) - subseg_new (".text", get_absolute_expression () + 1000); - else - subseg_new (".data", get_absolute_expression ()); -} - -static void -obj_coff_ident (int ignore ATTRIBUTE_UNUSED) -{ - segT current_seg = now_seg; /* Save current seg. */ - subsegT current_subseg = now_subseg; - - subseg_new (".comment", 0); /* .comment seg. */ - stringer (1); /* Read string. */ - subseg_set (current_seg, current_subseg); /* Restore current seg. */ -} - -void -c_dot_file_symbol (const char *filename, int appfile ATTRIBUTE_UNUSED) -{ - symbolS *symbolP; - - symbolP = symbol_new (".file", SEG_DEBUG, 0, & zero_address_frag); - - S_SET_STORAGE_CLASS (symbolP, C_FILE); - S_SET_NUMBER_AUXILIARY (symbolP, 1); - - if (strlen (filename) > FILNMLEN) - { - /* Filename is too long to fit into an auxent, - we stick it into the string table instead. We keep - a linked list of the filenames we find so we can emit - them later. */ - struct filename_list *f = xmalloc (sizeof (* f)); - - f->filename = filename; - f->next = 0; - - SA_SET_FILE_FNAME_ZEROS (symbolP, 0); - SA_SET_FILE_FNAME_OFFSET (symbolP, 1); - - if (filename_list_tail) - filename_list_tail->next = f; - else - filename_list_head = f; - filename_list_tail = f; - } - else - SA_SET_FILE_FNAME (symbolP, filename); - -#ifndef NO_LISTING - { - extern int listing; - if (listing) - listing_source_file (filename); - } -#endif - - SF_SET_DEBUG (symbolP); - S_SET_VALUE (symbolP, (valueT) previous_file_symbol); - - previous_file_symbol = symbolP; - - /* Make sure that the symbol is first on the symbol chain. */ - if (symbol_rootP != symbolP) - { - symbol_remove (symbolP, &symbol_rootP, &symbol_lastP); - symbol_insert (symbolP, symbol_rootP, &symbol_rootP, &symbol_lastP); - } -} - -static void -obj_coff_lcomm (int ignore ATTRIBUTE_UNUSED) -{ - s_lcomm (0); - return; -} - -/* The first entry in a .stab section is special. */ - -void -obj_coff_init_stab_section (segT seg) -{ - char *file; - char *p; - char *stabstr_name; - unsigned int stroff; - - /* Make space for this first symbol. */ - p = frag_more (12); - /* Zero it out. */ - memset (p, 0, 12); - as_where (&file, (unsigned int *) NULL); - stabstr_name = alloca (strlen (segment_info[seg].name) + 4); - strcpy (stabstr_name, segment_info[seg].name); - strcat (stabstr_name, "str"); - stroff = get_stab_string_offset (file, stabstr_name); - know (stroff == 1); - md_number_to_chars (p, stroff, 4); -} - -#endif /* not BFD_ASSEMBLER */ - const pseudo_typeS coff_pseudo_table[] = { {"ABORT", s_abort, 0}, @@ -4432,24 +1718,16 @@ const pseudo_typeS coff_pseudo_table[] = {"type", obj_coff_type, 0}, {"val", obj_coff_val, 0}, {"version", s_ignore, 0}, -#ifdef BFD_ASSEMBLER {"loc", obj_coff_loc, 0}, {"optim", s_ignore, 0}, /* For sun386i cc (?) */ {"weak", obj_coff_weak, 0}, -#else - {"data", obj_coff_data, 0}, - {"lcomm", obj_coff_lcomm, 0}, - {"text", obj_coff_text, 0}, - {"use", obj_coff_section, 0}, -#endif -#if defined TC_M88K || defined TC_TIC4X - /* The m88k and tic4x uses sdef instead of def. */ +#if defined TC_TIC4X + /* The tic4x uses sdef instead of def. */ {"sdef", obj_coff_def, 0}, #endif {NULL, NULL, 0} }; -#ifdef BFD_ASSEMBLER /* Support for a COFF emulation. */ @@ -4498,5 +1776,3 @@ const struct format_ops coff_format_ops = coff_obj_read_begin_hook, coff_obj_symbol_new_hook }; - -#endif diff --git a/gas/config/obj-coff.h b/gas/config/obj-coff.h index 4d6434d..c6b4e63 100644 --- a/gas/config/obj-coff.h +++ b/gas/config/obj-coff.h @@ -25,16 +25,6 @@ #define OBJ_COFF 1 -#ifndef BFD_ASSEMBLER - -#define WORKING_DOT_WORD -#define WARN_SIGNED_OVERFLOW_WORD -#define OBJ_COFF_OMIT_OPTIONAL_HEADER -#define BFD_HEADERS -#define BFD - -#endif - #include "targ-cpu.h" #include "bfd.h" @@ -85,11 +75,6 @@ #endif #endif -#ifdef TC_A29K -#include "coff/a29k.h" -#define TARGET_FORMAT "coff-a29k-big" -#endif - #ifdef TC_OR32 #include "coff/or32.h" #define TARGET_FORMAT "coff-or32-big" @@ -147,16 +132,6 @@ #define TARGET_FORMAT "pe-mips" #endif -#ifdef TC_M88K -#include "coff/m88k.h" -#define TARGET_FORMAT "coff-m88kbcs" -#endif - -#ifdef TC_W65 -#include "coff/w65.h" -#define TARGET_FORMAT "coff-w65" -#endif - #ifdef TC_TIC30 #include "coff/tic30.h" #define TARGET_FORMAT "coff-tic30" @@ -172,12 +147,6 @@ #define TARGET_FORMAT "coff1-c54x" #endif -#ifdef TC_TIC80 -#include "coff/tic80.h" -#define TARGET_FORMAT "coff-tic80" -#define ALIGNMENT_IN_S_FLAGS 1 -#endif - #ifdef TC_MCORE #include "coff/mcore.h" #ifndef TARGET_FORMAT @@ -190,11 +159,6 @@ #define USE_UNIQUE 1 #endif -/* Targets may also set this. Also, if BFD_ASSEMBLER is defined, this - will already have been defined. */ -#undef SYMBOLS_NEED_BACKPOINTERS -#define SYMBOLS_NEED_BACKPOINTERS 1 - #ifndef OBJ_COFF_MAX_AUXENTRIES #define OBJ_COFF_MAX_AUXENTRIES 1 #endif @@ -202,44 +166,6 @@ #define obj_symbol_new_hook coff_obj_symbol_new_hook #define obj_read_begin_hook coff_obj_read_begin_hook -/* This file really contains two implementations of the COFF back end. - They are in the process of being merged, but this is only a - preliminary, mechanical merging. Many definitions that are - identical between the two are still found in both versions. - - The first version, with BFD_ASSEMBLER defined, uses high-level BFD - interfaces and data structures. The second version, with - BFD_ASSEMBLER not defined, also uses BFD, but mostly for swapping - data structures and for doing the actual I/O. The latter defines - the preprocessor symbols BFD and BFD_HEADERS. Try not to let this - confuse you. - - These two are in the process of being merged, and eventually the - BFD_ASSEMBLER version should take over completely. Release timing - issues and namespace problems convinced me to merge the two - together in this fashion, a little sooner than I would have liked. - The real merge should be much better done by the time the next - release comes out. - - For now, the structure of this file is: - <common> - #ifdef BFD_ASSEMBLER - <one version> - #else - <other version> - #endif - <common> - Unfortunately, the common portions are very small at the moment, - and many declarations or definitions are duplicated. The structure - of obj-coff.c is similar. - - See doc/internals.texi for a brief discussion of the history, if - you care. - - Ken Raeburn, 5 May 1994. */ - -#ifdef BFD_ASSEMBLER - #include "bfd/libcoff.h" #define OUTPUT_FLAVOR bfd_target_coff_flavour @@ -414,422 +340,6 @@ hey ! Where is the C_LEAFSTAT definition ? i960 - coff support is depending on i #endif /* no C_LEAFSTAT */ #endif /* TC_I960 */ -#else /* not BFD_ASSEMBLER */ - -#if defined TC_A29K || defined TC_OR32 -/* Allow translate from aout relocs to coff relocs. */ -#define NO_RELOC 20 -#define RELOC_32 1 -#define RELOC_8 2 -#define RELOC_CONST 3 -#define RELOC_CONSTH 4 -#define RELOC_JUMPTARG 5 -#define RELOC_BASE22 6 -#define RELOC_HI22 7 -#define RELOC_LO10 8 -#define RELOC_BASE13 9 -#define RELOC_WDISP22 10 -#define RELOC_WDISP30 11 -#endif - -extern const segT N_TYPE_seg[]; - -/* Magic number of paged executable. */ -#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE 0x8300 - -/* SYMBOL TABLE */ - -/* Symbol table entry data type. */ - -typedef struct -{ - /* Basic symbol. */ - struct internal_syment ost_entry; - /* Auxiliary entry. */ - union internal_auxent ost_auxent[OBJ_COFF_MAX_AUXENTRIES]; - /* obj_coff internal use only flags. */ - unsigned int ost_flags; -} obj_symbol_type; - -/* Symbol table macros and constants. */ - -/* Possible and useful 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 50 - -/* Macros to extract information from a symbol table entry. - This syntactic 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_GET_VALUE (s) > 0) \ - || ((s)->sy_symbol.ost_entry.n_scnum == C_ABS_SECTION)) - -/* Return true for symbols that should not be reduced to section - symbols or eliminated from expressions, because they may be - overridden by the linker. */ -#define S_FORCE_RELOC(s, strict) \ - (!SEG_NORMAL (S_GET_SEGMENT (s)) || (strict && S_IS_WEAK (s))) - -/* 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 includes ^A is a gas internal pseudo symbol. */ -#define S_IS_LOCAL(s) \ - ((s)->sy_symbol.ost_entry.n_scnum == C_REGISTER_SECTION \ - || (S_LOCAL_NAME(s) && ! flag_keep_locals && ! S_IS_DEBUG (s)) \ - || strchr (S_GET_NAME (s), '\001') != NULL \ - || strchr (S_GET_NAME (s), '\002') != NULL \ - || (flag_strip_local_absolute \ - && !S_IS_EXTERNAL (s) \ - && (s)->sy_symbol.ost_entry.n_scnum == C_ABS_SECTION)) - -/* 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_GET_VALUE (s) != 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) - -/* True if a symbol is defined as weak. */ -#ifdef TE_PE -#define S_IS_WEAK(s) \ - ( (s)->sy_symbol.ost_entry.n_sclass == C_NT_WEAK \ - || (s)->sy_symbol.ost_entry.n_sclass == C_WEAKEXT) -#else -#define S_IS_WEAK(s) \ - ((s)->sy_symbol.ost_entry.n_sclass == C_WEAKEXT) -#endif - -/* 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 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 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) \ - do \ - { \ - S_SET_STORAGE_CLASS (s, C_EXT); \ - SF_CLEAR_LOCAL (s); \ - } \ - while (0) - -/* Auxiliary entry macros. SA_ stands for symbol auxiliary. */ -/* Omit the tv related fields. */ -/* Accessors. */ -#define SYM_AUXENT(S) (&(S)->sy_symbol.ost_auxent[0]) - -#define SA_GET_SYM_TAGNDX(s) (SYM_AUXENT (s)->x_sym.x_tagndx.l) -#define SA_GET_SYM_LNNO(s) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_lnno) -#define SA_GET_SYM_SIZE(s) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_size) -#define SA_GET_SYM_FSIZE(s) (SYM_AUXENT (s)->x_sym.x_misc.x_fsize) -#define SA_GET_SYM_LNNOPTR(s) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_lnnoptr) -#define SA_GET_SYM_ENDNDX(s) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_endndx.l) -#define SA_GET_SYM_DIMEN(s,i) (SYM_AUXENT (s)->x_sym.x_fcnary.x_ary.x_dimen[(i)]) -#define SA_GET_FILE_FNAME(s) (SYM_AUXENT (s)->x_file.x_fname) -#define SA_GET_FILE_FNAME_OFFSET(s) (SYM_AUXENT (s)->x_file.x_n.x_offset) -#define SA_GET_FILE_FNAME_ZEROS(s) (SYM_AUXENT (s)->x_file.x_n.x_zeroes) -#define SA_GET_SCN_SCNLEN(s) (SYM_AUXENT (s)->x_scn.x_scnlen) -#define SA_GET_SCN_NRELOC(s) (SYM_AUXENT (s)->x_scn.x_nreloc) -#define SA_GET_SCN_NLINNO(s) (SYM_AUXENT (s)->x_scn.x_nlinno) - -/* Modifiers. */ -#define SA_SET_SYM_TAGNDX(s,v) (SYM_AUXENT (s)->x_sym.x_tagndx.l = (v)) -#define SA_SET_SYM_LNNO(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_lnno = (v)) -#define SA_SET_SYM_SIZE(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_size = (v)) -#define SA_SET_SYM_FSIZE(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_fsize = (v)) -#define SA_SET_SYM_LNNOPTR(s,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_lnnoptr = (v)) -#define SA_SET_SYM_ENDNDX(s,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_endndx.l = (v)) -#define SA_SET_SYM_DIMEN(s,i,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_ary.x_dimen[(i)] = (v)) -#define SA_SET_FILE_FNAME(s,v) strncpy (SYM_AUXENT (s)->x_file.x_fname,(v),FILNMLEN) -#define SA_SET_FILE_FNAME_OFFSET(s,v) (SYM_AUXENT (s)->x_file.x_n.x_offset = (v)) -#define SA_SET_FILE_FNAME_ZEROS(s,v) (SYM_AUXENT (s)->x_file.x_n.x_zeroes = (v)) -#define SA_SET_SCN_SCNLEN(s,v) (SYM_AUXENT (s)->x_scn.x_scnlen = (v)) -#define SA_SET_SCN_NRELOC(s,v) (SYM_AUXENT (s)->x_scn.x_nreloc = (v)) -#define SA_SET_SCN_NLINNO(s,v) (SYM_AUXENT (s)->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. */ -#define SF_ADJ_LNNOPTR 0x00400000 /* Has a lnnoptr. */ -/* All other bits are unused. */ - -/* Accessors. */ -#define SF_GET(s) ((s)->sy_symbol.ost_flags) -#define SF_GET_NORMAL_FIELD(s) (SF_GET (s) & SF_NORMAL_MASK) -#define SF_GET_DEBUG_FIELD(s) (SF_GET (s) & SF_DEBUG_MASK) -#define SF_GET_FILE(s) (SF_GET (s) & SF_FILE) -#define SF_GET_STATICS(s) (SF_GET (s) & SF_STATICS) -#define SF_GET_DEFINED(s) (SF_GET (s) & SF_DEFINED) -#define SF_GET_STRING(s) (SF_GET (s) & SF_STRING) -#define SF_GET_LOCAL(s) (SF_GET (s) & SF_LOCAL) -#define SF_GET_FUNCTION(s) (SF_GET (s) & SF_FUNCTION) -#define SF_GET_PROCESS(s) (SF_GET (s) & SF_PROCESS) -#define SF_GET_DEBUG(s) (SF_GET (s) & SF_DEBUG) -#define SF_GET_TAGGED(s) (SF_GET (s) & SF_TAGGED) -#define SF_GET_TAG(s) (SF_GET (s) & SF_TAG) -#define SF_GET_GET_SEGMENT(s) (SF_GET (s) & SF_GET_SEGMENT) -#define SF_GET_ADJ_LNNOPTR(s) (SF_GET (s) & SF_ADJ_LNNOPTR) -#define SF_GET_I960(s) (SF_GET (s) & SF_I960_MASK) /* Used by i960. */ -#define SF_GET_BALNAME(s) (SF_GET (s) & SF_BALNAME) /* Used by i960. */ -#define SF_GET_CALLNAME(s) (SF_GET (s) & SF_CALLNAME) /* Used by i960. */ -#define SF_GET_IS_SYSPROC(s) (SF_GET (s) & SF_IS_SYSPROC) /* Used by i960. */ -#define SF_GET_SYSPROC(s) (SF_GET (s) & SF_SYSPROC) /* Used by i960. */ - -/* Modifiers. */ -#define SF_SET(s,v) (SF_GET (s) = (v)) -#define SF_SET_NORMAL_FIELD(s,v)(SF_GET (s) |= ((v) & SF_NORMAL_MASK)) -#define SF_SET_DEBUG_FIELD(s,v) (SF_GET (s) |= ((v) & SF_DEBUG_MASK)) -#define SF_SET_FILE(s) (SF_GET (s) |= SF_FILE) -#define SF_SET_STATICS(s) (SF_GET (s) |= SF_STATICS) -#define SF_SET_DEFINED(s) (SF_GET (s) |= SF_DEFINED) -#define SF_SET_STRING(s) (SF_GET (s) |= SF_STRING) -#define SF_SET_LOCAL(s) (SF_GET (s) |= SF_LOCAL) -#define SF_CLEAR_LOCAL(s) (SF_GET (s) &= ~SF_LOCAL) -#define SF_SET_FUNCTION(s) (SF_GET (s) |= SF_FUNCTION) -#define SF_SET_PROCESS(s) (SF_GET (s) |= SF_PROCESS) -#define SF_SET_DEBUG(s) (SF_GET (s) |= SF_DEBUG) -#define SF_SET_TAGGED(s) (SF_GET (s) |= SF_TAGGED) -#define SF_SET_TAG(s) (SF_GET (s) |= SF_TAG) -#define SF_SET_GET_SEGMENT(s) (SF_GET (s) |= SF_GET_SEGMENT) -#define SF_SET_ADJ_LNNOPTR(s) (SF_GET (s) |= SF_ADJ_LNNOPTR) -#define SF_SET_I960(s,v) (SF_GET (s) |= ((v) & SF_I960_MASK)) /* Used by i960. */ -#define SF_SET_BALNAME(s) (SF_GET (s) |= SF_BALNAME) /* Used by i960. */ -#define SF_SET_CALLNAME(s) (SF_GET (s) |= SF_CALLNAME) /* Used by i960. */ -#define SF_SET_IS_SYSPROC(s) (SF_GET (s) |= SF_IS_SYSPROC) /* Used by i960. */ -#define SF_SET_SYSPROC(s,v) (SF_GET (s) |= ((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 - -#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) (H_GET_TEXT_FILE_OFFSET (h) \ - + H_GET_TEXT_SIZE (h)) - -#define H_GET_BSS_FILE_OFFSET(h) 0 - -#define H_GET_RELOCATION_FILE_OFFSET(h) \ - (long) (H_GET_DATA_FILE_OFFSET (h) \ - + H_GET_DATA_SIZE (h)) - -#define H_GET_LINENO_FILE_OFFSET(h) \ - (long) (H_GET_RELOCATION_FILE_OFFSET (h) \ - + H_GET_RELOCATION_SIZE (h)) - -#define H_GET_SYMBOL_TABLE_FILE_OFFSET(h) \ - (long) (H_GET_LINENO_FILE_OFFSET (h) \ - + H_GET_LINENO_SIZE (h)) - -#define H_GET_FILE_SIZE(h) \ - (long) (H_GET_SYMBOL_TABLE_FILE_OFFSET (h) \ - + H_GET_SYMBOL_TABLE_SIZE (h) \ - + (h)->string_table_size) - -/* 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 convenience. */ -#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. */ - -typedef struct -{ - struct internal_aouthdr aouthdr; /* a.out header. */ - struct internal_filehdr filehdr; /* File header, not machine dep. */ - 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. */ -}; - -#define obj_segment_name(i) (segment_info[(int) (i)].scnhdr.s_name) - -#define obj_add_segment(s) obj_coff_add_segment (s) - -/* 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 */ - -extern struct internal_scnhdr data_section_header; -extern struct internal_scnhdr text_section_header; - -/* Forward the segment of a forwarded symbol. */ -#define OBJ_COPY_SYMBOL_ATTRIBUTES(dest,src) \ - (SF_GET_GET_SEGMENT (dest) \ - ? (S_SET_SEGMENT (dest, S_GET_SEGMENT (src)), 0) \ - : 0) - -#ifdef TE_PE -#define obj_handle_link_once(t) obj_coff_pe_handle_link_once (t) -#endif - -#endif /* not BFD_ASSEMBLER */ - extern const pseudo_typeS coff_pseudo_table[]; #ifndef obj_pop_insert @@ -861,7 +371,6 @@ extern const pseudo_typeS coff_pseudo_table[]; #define obj_app_file(name, app) c_dot_file_symbol (name, app) -#ifdef BFD_ASSEMBLER extern int S_SET_DATA_TYPE (symbolS *, int); extern int S_SET_STORAGE_CLASS (symbolS *, int); extern int S_GET_STORAGE_CLASS (symbolS *); @@ -873,9 +382,6 @@ extern void coff_adjust_symtab (void); extern void coff_frob_section (segT); extern void coff_adjust_section_syms (bfd *, asection *, void *); extern void coff_frob_file_after_relocs (void); -#else -extern void obj_extra_stuff (object_headers *); -#endif extern void coff_obj_symbol_new_hook (symbolS *); extern void coff_obj_read_begin_hook (void); extern void obj_coff_section (int); diff --git a/gas/config/obj-evax.h b/gas/config/obj-evax.h index 39ac7a1..413a837 100644 --- a/gas/config/obj-evax.h +++ b/gas/config/obj-evax.h @@ -1,5 +1,5 @@ /* This file is obj-evax.h - Copyright 1996, 2000 Free Software Foundation, Inc. + Copyright 1996, 2000, 2005 Free Software Foundation, Inc. Contributed by Klaus Kämpf (kkaempf@progis.de) of proGIS Software, Aachen, Germany. @@ -31,9 +31,7 @@ /* include whatever target cpu is appropriate. */ #include "targ-cpu.h" -#ifdef BFD_ASSEMBLER #define OUTPUT_FLAVOR bfd_target_evax_flavour -#endif /* * SYMBOLS @@ -58,8 +56,6 @@ obj_symbol_type; /* should be the format's symbol structure */ typedef void *object_headers; -#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. */ #define obj_symbol_new_hook(s) {;} diff --git a/gas/config/obj-hp300.c b/gas/config/obj-hp300.c deleted file mode 100644 index c6fdf1e..0000000 --- a/gas/config/obj-hp300.c +++ /dev/null @@ -1,54 +0,0 @@ -/* This file is obj-hp300.h - Copyright 1993, 2000, 2005 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -#include "config/obj-aout.c" - -/* Aout file generation & utilities */ -void -hp300_header_append (where, headers) - char **where; - object_headers *headers; -{ - tc_headers_hook (headers); - -#define DO(FIELD) \ - { \ - md_number_to_chars (*where, headers->header.FIELD, \ - sizeof (((struct exec_bytes *) 0)->FIELD)); \ - *where += sizeof (((struct exec_bytes *) 0)->FIELD); \ - } - - DO (a_info); - DO (a_spare1); - DO (a_spare2); - DO (a_text); - DO (a_data); - DO (a_bss); - DO (a_trsize); - DO (a_drsize); - DO (a_spare3); - DO (a_spare4); - DO (a_spare5); - DO (a_entry); - DO (a_spare6); - DO (a_spare7); - DO (a_syms); - DO (a_spare8); -} diff --git a/gas/config/obj-hp300.h b/gas/config/obj-hp300.h deleted file mode 100644 index 5cd178a..0000000 --- a/gas/config/obj-hp300.h +++ /dev/null @@ -1,72 +0,0 @@ -/* This file is obj-hp300.h - Copyright 1993, 2000, 2005 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -#define __STRUCT_EXEC_OVERRIDE__ - -struct exec_bytes -{ - unsigned char a_info[4]; /* a_machtype/a_magic */ - unsigned char a_spare1[4]; - unsigned char a_spare2[4]; - unsigned char a_text[4]; /* length of text, in bytes */ - unsigned char a_data[4]; /* length of data, in bytes */ - unsigned char a_bss[4]; /* length of uninitialized data area for file, in bytes */ - unsigned char a_trsize[4]; /* length of relocation info for text, in bytes */ - unsigned char a_drsize[4]; /* length of relocation info for data, in bytes */ - unsigned char a_spare3[4]; /* HP = pascal interface size */ - unsigned char a_spare4[4]; /* HP = symbol table size */ - unsigned char a_spare5[4]; /* HP = debug name table size */ - unsigned char a_entry[4]; /* start address */ - unsigned char a_spare6[4]; /* HP = source line table size */ - unsigned char a_spare7[4]; /* HP = value table size */ - unsigned char a_syms[4]; /* length of symbol table data in file, in bytes */ - unsigned char a_spare8[4]; -}; - -/* How big the "struct exec" is on disk */ -#define EXEC_BYTES_SIZE (16 * 4) - -struct exec -{ - unsigned long a_info; - unsigned long a_spare1; - unsigned long a_spare2; - unsigned long a_text; - unsigned long a_data; - unsigned long a_bss; - unsigned long a_trsize; - unsigned long a_drsize; - unsigned long a_spare3; - unsigned long a_spare4; - unsigned long a_spare5; - unsigned long a_entry; - unsigned long a_spare6; - unsigned long a_spare7; - unsigned long a_syms; - unsigned long a_spare8; -}; - -#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (OMAGIC) -#define AOUT_VERSION 0x02 -#define AOUT_MACHTYPE 0x0c -#define OMAGIC 0x106 - -#define obj_header_append hp300_header_append -#include "config/obj-aout.h" diff --git a/gas/config/obj-ieee.h b/gas/config/obj-ieee.h index 4446e38..2965429 100644 --- a/gas/config/obj-ieee.h +++ b/gas/config/obj-ieee.h @@ -19,8 +19,6 @@ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#define BFD 1 - #include "bfd.h" typedef struct @@ -43,8 +41,6 @@ typedef struct } object_headers; -#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE 1 - int lineno_rootP; #define IEEE_STYLE diff --git a/gas/config/tc-a29k.c b/gas/config/tc-a29k.c deleted file mode 100644 index 26b02ca..0000000 --- a/gas/config/tc-a29k.c +++ /dev/null @@ -1,1187 +0,0 @@ -/* tc-a29k.c -- Assemble for the AMD 29000. - Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1998, 2000, 2001, - 2002, 2005 - 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -/* John Gilmore has reorganized this module somewhat, to make it easier - to convert it to new machines' assemblers as desired. There was too - much bloody rewriting required before. There still probably is. */ - -#include "as.h" -#include "safe-ctype.h" - -#include "opcode/a29k.h" - -/* Make it easier to clone this machine desc into another one. */ -#define machine_opcode a29k_opcode -#define machine_opcodes a29k_opcodes -#define machine_ip a29k_ip -#define machine_it a29k_it - -#define IMMEDIATE_BIT 0x01000000 /* Turns RB into Immediate. */ -#define ABSOLUTE_BIT 0x01000000 /* Turns PC-relative to Absolute. */ -#define CE_BIT 0x00800000 /* Coprocessor enable in LOAD. */ -#define UI_BIT 0x00000080 /* Unsigned integer in CONVERT. */ - -/* handle of the OPCODE hash table. */ -static struct hash_control *op_hash = NULL; - -struct machine_it -{ - char *error; - unsigned long opcode; - struct nlist *nlistp; - expressionS exp; - int pcrel; - int reloc_offset; /* Offset of reloc within insn. */ - int reloc; -} -the_insn; - -#if defined(BFD_HEADERS) -#ifdef RELSZ -const int md_reloc_size = RELSZ; /* Coff headers. */ -#else -const int md_reloc_size = 12; /* Something else headers. */ -#endif -#else -const int md_reloc_size = 12; /* Not bfdized. */ -#endif - -/* This array holds the chars that always start a comment. If the - pre-processor is disabled, these aren't very useful. */ -const char comment_chars[] = ";"; - -/* This array holds the chars that only start a comment at the beginning of - a line. If the line seems to have the form '# 123 filename' - .line and .file directives will appear in the pre-processed output. */ -/* Note that input_file.c hand checks for '#' at the beginning of the - first line of the input file. This is because the compiler outputs - #NO_APP at the beginning of its output. */ -/* Also note that comments like this one will always work. */ -const char line_comment_chars[] = "#"; - -/* We needed an unused char for line separation to work around the - lack of macros, using sed and such. */ -const char line_separator_chars[] = "@"; - -/* Chars that can be used to separate mant from exp in floating point nums. */ -const char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant. - As in 0f12.456 - or 0d1.2345e12. */ -const char FLT_CHARS[] = "rRsSfFdDxXpP"; - -/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be - changed in read.c. Ideally it shouldn't have to know about it at - all, but nothing is ideal around here. */ - -/* anull bit - causes the branch delay slot instructions to not be executed. */ -#define ANNUL (1 << 29) - -#ifndef OBJ_COFF - -static void -s_use (int ignore) -{ - if (strncmp (input_line_pointer, ".text", 5) == 0) - { - input_line_pointer += 5; - s_text (0); - return; - } - if (strncmp (input_line_pointer, ".data", 5) == 0) - { - input_line_pointer += 5; - s_data (0); - return; - } - if (strncmp (input_line_pointer, ".data1", 6) == 0) - { - input_line_pointer += 6; - s_data1 (); - return; - } - /* Literals can't go in the text segment because you can't read from - instruction memory on some 29k's. So, into initialized data. */ - if (strncmp (input_line_pointer, ".lit", 4) == 0) - { - input_line_pointer += 4; - subseg_set (SEG_DATA, 200); - demand_empty_rest_of_line (); - return; - } - - as_bad (_("Unknown segment type")); - demand_empty_rest_of_line (); -} - -static void -s_data1 (void) -{ - subseg_set (SEG_DATA, 1); - demand_empty_rest_of_line (); -} - -#endif /* OBJ_COFF */ - -/* Install symbol definition that maps REGNAME to REGNO. - FIXME-SOON: These are not recognized in mixed case. */ - -static void -insert_sreg (char *regname, int regnum) -{ - /* FIXME-SOON, put something in these syms so they won't be output - to the symbol table of the resulting object file. */ - - /* Must be large enough to hold the names of the special registers. */ - char buf[80]; - int i; - - symbol_table_insert (symbol_new (regname, SEG_REGISTER, (valueT) regnum, - &zero_address_frag)); - for (i = 0; regname[i]; i++) - buf[i] = TOUPPER (regname[i]); - buf[i] = '\0'; - - symbol_table_insert (symbol_new (buf, SEG_REGISTER, (valueT) regnum, - &zero_address_frag)); -} - -/* Install symbol definitions for assorted special registers. - See ASM29K Ref page 2-9. */ - -static void -define_some_regs (void) -{ -#define SREG 256 - - /* Protected special-purpose register names. */ - insert_sreg ("vab", SREG + 0); - insert_sreg ("ops", SREG + 1); - insert_sreg ("cps", SREG + 2); - insert_sreg ("cfg", SREG + 3); - insert_sreg ("cha", SREG + 4); - insert_sreg ("chd", SREG + 5); - insert_sreg ("chc", SREG + 6); - insert_sreg ("rbp", SREG + 7); - insert_sreg ("tmc", SREG + 8); - insert_sreg ("tmr", SREG + 9); - insert_sreg ("pc0", SREG + 10); - insert_sreg ("pc1", SREG + 11); - insert_sreg ("pc2", SREG + 12); - insert_sreg ("mmu", SREG + 13); - insert_sreg ("lru", SREG + 14); - - /* Additional protected special-purpose registers for the 29050. */ - insert_sreg ("rsn", SREG + 15); - insert_sreg ("rma0", SREG + 16); - insert_sreg ("rmc0", SREG + 17); - insert_sreg ("rma1", SREG + 18); - insert_sreg ("rmc1", SREG + 19); - insert_sreg ("spc0", SREG + 20); - insert_sreg ("spc1", SREG + 21); - insert_sreg ("spc2", SREG + 22); - insert_sreg ("iba0", SREG + 23); - insert_sreg ("ibc0", SREG + 24); - insert_sreg ("iba1", SREG + 25); - insert_sreg ("ibc1", SREG + 26); - - /* Additional registers for the 29040. */ - insert_sreg ("dba", SREG + 27); - insert_sreg ("dbc", SREG + 28); - insert_sreg ("cir", SREG + 29); - insert_sreg ("cdr", SREG + 30); - - /* Unprotected special-purpose register names. */ - insert_sreg ("ipc", SREG + 128); - insert_sreg ("ipa", SREG + 129); - insert_sreg ("ipb", SREG + 130); - insert_sreg ("q", SREG + 131); - insert_sreg ("alu", SREG + 132); - insert_sreg ("bp", SREG + 133); - insert_sreg ("fc", SREG + 134); - insert_sreg ("cr", SREG + 135); - insert_sreg ("fpe", SREG + 160); - insert_sreg ("inte", SREG + 161); - insert_sreg ("fps", SREG + 162); - /* "", SREG+163); Reserved */ - insert_sreg ("exop", SREG + 164); -} - -/* This function is called once, at assembler startup time. It should - set up all the tables, etc., that the MD part of the assembler will - need. */ - -void -md_begin (void) -{ - const char *retval = NULL; - int lose = 0; - int skipnext = 0; - unsigned int i; - char *strend, *strend2; - - /* Hash up all the opcodes for fast use later. */ - - op_hash = hash_new (); - - for (i = 0; i < num_opcodes; i++) - { - const char *name = machine_opcodes[i].name; - - if (skipnext) - { - skipnext = 0; - continue; - } - - /* Hack to avoid multiple opcode entries. We pre-locate all the - variations (b/i field and P/A field) and handle them. */ - if (!strcmp (name, machine_opcodes[i + 1].name)) - { - if ((machine_opcodes[i].opcode & 0x01000000) != 0 - || (machine_opcodes[i + 1].opcode & 0x01000000) == 0 - || ((machine_opcodes[i].opcode | 0x01000000) - != machine_opcodes[i + 1].opcode)) - goto bad_table; - - strend = machine_opcodes[i].args + strlen (machine_opcodes[i].args) - 1; - strend2 = machine_opcodes[i + 1].args + strlen (machine_opcodes[i + 1].args) - 1; - - switch (*strend) - { - case 'b': - if (*strend2 != 'i') - goto bad_table; - break; - - case 'P': - if (*strend2 != 'A') - goto bad_table; - break; - - default: - bad_table: - fprintf (stderr, "internal error: can't handle opcode %s\n", - name); - lose = 1; - } - - /* OK, this is an i/b or A/P pair. We skip the - higher-valued one, and let the code for operand checking - handle OR-ing in the bit. */ - skipnext = 1; - } - - retval = hash_insert (op_hash, name, (void *) &machine_opcodes[i]); - if (retval != NULL) - { - fprintf (stderr, "internal error: can't hash `%s': %s\n", - machine_opcodes[i].name, retval); - lose = 1; - } - } - - if (lose) - as_fatal (_("Broken assembler. No assembly attempted.")); - - define_some_regs (); -} - -static char * -parse_operand (char *s, expressionS *operandp, int opt) -{ - char *save = input_line_pointer; - char *new; - - input_line_pointer = s; - expression (operandp); - if (operandp->X_op == O_absent && ! opt) - as_bad (_("missing operand")); - new = input_line_pointer; - input_line_pointer = save; - return new; -} - -/* Instruction parsing. Takes a string containing the opcode. - Operands are at input_line_pointer. Output is in the_insn. - Warnings or errors are generated. */ - -static void -machine_ip (char *str) -{ - char *s; - const char *args; - struct machine_opcode *insn; - char *argsStart; - unsigned long opcode; - expressionS the_operand; - expressionS *operand = &the_operand; - unsigned int reg; - - /* Must handle `div0' opcode. */ - s = str; - if (ISALPHA (*s)) - for (; ISALNUM (*s); ++s) - *s = TOLOWER (*s); - - switch (*s) - { - case '\0': - break; - - case ' ': /* FIXME-SOMEDAY more whitespace. */ - *s++ = '\0'; - break; - - default: - as_bad (_("Unknown opcode: `%s'"), str); - return; - } - if ((insn = (struct machine_opcode *) hash_find (op_hash, str)) == NULL) - { - as_bad (_("Unknown opcode `%s'."), str); - return; - } - argsStart = s; - opcode = insn->opcode; - memset (&the_insn, '\0', sizeof (the_insn)); - the_insn.reloc = NO_RELOC; - - /* Build the opcode, checking as we go to make sure that the - operands match. - - If an operand matches, we modify the_insn or opcode appropriately, - and do a "continue". If an operand fails to match, we "break". */ - if (insn->args[0] != '\0') - /* Prime the pump. */ - s = parse_operand (s, operand, insn->args[0] == 'I'); - - for (args = insn->args;; ++args) - { - switch (*args) - { - case '\0': - if (*s == '\0') - { - /* We are truly done. */ - the_insn.opcode = opcode; - return; - } - as_bad (_("Too many operands: %s"), s); - break; - - case ',': - if (*s++ == ',') - { - /* Parse next operand. */ - s = parse_operand (s, operand, args[1] == 'I'); - continue; - } - break; - - case 'v': - /* Trap numbers (immediate field). */ - if (operand->X_op == O_constant) - { - if (operand->X_add_number < 256) - opcode |= (operand->X_add_number << 16); - else - as_bad (_("Immediate value of %ld is too large"), - (long) operand->X_add_number); - continue; - } - the_insn.reloc = RELOC_8; - /* BIG-ENDIAN Byte 1 of insn. */ - the_insn.reloc_offset = 1; - the_insn.exp = *operand; - continue; - - case 'b': /* A general register or 8-bit immediate. */ - case 'i': - /* We treat the two cases identically since we mashed - them together in the opcode table. */ - if (operand->X_op == O_register) - goto general_reg; - - /* Make sure the 'i' case really exists. */ - if ((insn->opcode | IMMEDIATE_BIT) != (insn + 1)->opcode) - break; - - opcode |= IMMEDIATE_BIT; - if (operand->X_op == O_constant) - { - if (operand->X_add_number < 256) - opcode |= operand->X_add_number; - else - as_bad (_("Immediate value of %ld is too large"), - (long) operand->X_add_number); - continue; - } - the_insn.reloc = RELOC_8; - the_insn.reloc_offset = 3; /* BIG-ENDIAN Byte 3 of insn. */ - the_insn.exp = *operand; - continue; - - case 'a': /* Next operand must be a register. */ - case 'c': - general_reg: - /* lrNNN or grNNN or %%expr or a user-def register name. */ - if (operand->X_op != O_register) - break; - know (operand->X_add_symbol == 0); - know (operand->X_op_symbol == 0); - reg = operand->X_add_number; - if (reg >= SREG) - break; - - /* Got the register, now figure out where it goes in the - opcode. */ - switch (*args) - { - case 'a': - opcode |= reg << 8; - continue; - - case 'b': - case 'i': - opcode |= reg; - continue; - - case 'c': - opcode |= reg << 16; - continue; - } - as_fatal (_("failed sanity check.")); - break; - - case 'x': /* 16 bit constant, zero-extended. */ - case 'X': /* 16 bit constant, one-extended. */ - if (operand->X_op == O_constant) - { - opcode |= (operand->X_add_number & 0xFF) << 0 - | ((operand->X_add_number & 0xFF00) << 8); - continue; - } - the_insn.reloc = RELOC_CONST; - the_insn.exp = *operand; - continue; - - case 'h': - if (operand->X_op == O_constant) - { - opcode |= (operand->X_add_number & 0x00FF0000) >> 16 - | (((unsigned long) operand->X_add_number - /* Avoid sign ext. */ & 0xFF000000) >> 8); - continue; - } - the_insn.reloc = RELOC_CONSTH; - the_insn.exp = *operand; - continue; - - case 'P': /* PC-relative jump address. */ - case 'A': /* Absolute jump address. */ - /* These two are treated together since we folded the - opcode table entries together. */ - if (operand->X_op == O_constant) - { - /* Make sure the 'A' case really exists. */ - if ((insn->opcode | ABSOLUTE_BIT) != (insn + 1)->opcode) - break; - - { - bfd_vma v, mask; - - mask = 0x1ffff; - v = operand->X_add_number & ~ mask; - if (v) - as_bad ("call/jmp target out of range"); - } - - opcode |= ABSOLUTE_BIT - | (operand->X_add_number & 0x0003FC00) << 6 - | ((operand->X_add_number & 0x000003FC) >> 2); - continue; - } - - the_insn.reloc = RELOC_JUMPTARG; - the_insn.exp = *operand; - the_insn.pcrel = 1; /* Assume PC-relative jump. */ - /* FIXME-SOON, Do we figure out whether abs later, after - know sym val? */ - continue; - - case 'e': /* Coprocessor enable bit for LOAD/STORE insn. */ - if (operand->X_op == O_constant) - { - if (operand->X_add_number == 0) - continue; - if (operand->X_add_number == 1) - { - opcode |= CE_BIT; - continue; - } - } - break; - - case 'n': /* Control bits for LOAD/STORE instructions. */ - if (operand->X_op == O_constant - && operand->X_add_number < 128) - { - opcode |= (operand->X_add_number << 16); - continue; - } - break; - - case 's': /* Special register number. */ - if (operand->X_op != O_register) - break; - if (operand->X_add_number < SREG) - break; - opcode |= (operand->X_add_number & 0xFF) << 8; - continue; - - case 'u': /* UI bit of CONVERT. */ - if (operand->X_op == O_constant) - { - if (operand->X_add_number == 0) - continue; - if (operand->X_add_number == 1) - { - opcode |= UI_BIT; - continue; - } - } - break; - - case 'r': /* RND bits of CONVERT. */ - if (operand->X_op == O_constant - && operand->X_add_number < 8) - { - opcode |= operand->X_add_number << 4; - continue; - } - break; - - case 'I': /* ID bits of INV and IRETINV. */ - /* This operand is optional. */ - if (operand->X_op == O_absent) - continue; - else if (operand->X_op == O_constant - && operand->X_add_number < 4) - { - opcode |= operand->X_add_number << 16; - continue; - } - break; - - case 'd': /* FD bits of CONVERT. */ - if (operand->X_op == O_constant - && operand->X_add_number < 4) - { - opcode |= operand->X_add_number << 2; - continue; - } - break; - - case 'f': /* FS bits of CONVERT. */ - if (operand->X_op == O_constant - && operand->X_add_number < 4) - { - opcode |= operand->X_add_number << 0; - continue; - } - break; - - case 'C': - if (operand->X_op == O_constant - && operand->X_add_number < 4) - { - opcode |= operand->X_add_number << 16; - continue; - } - break; - - case 'F': - if (operand->X_op == O_constant - && operand->X_add_number < 16) - { - opcode |= operand->X_add_number << 18; - continue; - } - break; - - default: - BAD_CASE (*args); - } - /* Types or values of args don't match. */ - as_bad ("Invalid operands"); - return; - } -} - -/* Assemble a single instruction. Its label has already been handled - by the generic front end. We just parse opcode and operands, and - produce the bytes of data and relocation. */ - -void -md_assemble (char *str) -{ - char *toP; - - know (str); - machine_ip (str); - toP = frag_more (4); - /* Put out the opcode. */ - md_number_to_chars (toP, the_insn.opcode, 4); - - /* Put out the symbol-dependent stuff. */ - if (the_insn.reloc != NO_RELOC) - fix_new_exp (frag_now, - (toP - frag_now->fr_literal + the_insn.reloc_offset), - 4, & the_insn.exp, the_insn.pcrel, the_insn.reloc); -} - -/* This is identical to the md_atof in m68k.c. I think this is right, - but I'm not sure. - - Turn a string in input_line_pointer into a floating point constant - of type TYPE, and store the appropriate bytes in *LITP. The number - of LITTLENUMS emitted is stored in *SIZEP. An error message is - returned, or NULL on OK. */ - -/* Equal to MAX_PRECISION in atof-ieee.c */ -#define MAX_LITTLENUMS 6 - -char * -md_atof (int type, char *litP, int *sizeP) -{ - int prec; - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - char *t; - - switch (type) - { - - case 'f': - case 'F': - case 's': - case 'S': - prec = 2; - break; - - case 'd': - case 'D': - case 'r': - case 'R': - prec = 4; - break; - - case 'x': - case 'X': - prec = 6; - break; - - case 'p': - case 'P': - prec = 6; - break; - - default: - *sizeP = 0; - return "Bad call to MD_ATOF()"; - } - t = atof_ieee (input_line_pointer, type, words); - if (t) - input_line_pointer = t; - *sizeP = prec * sizeof (LITTLENUM_TYPE); - for (wordP = words; prec--;) - { - md_number_to_chars (litP, (valueT) (*wordP++), sizeof (LITTLENUM_TYPE)); - litP += sizeof (LITTLENUM_TYPE); - } - return 0; -} - -/* Write out big-endian. */ - -void -md_number_to_chars (char *buf, valueT val, int n) -{ - number_to_chars_bigendian (buf, val, n); -} - -void -md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) -{ - valueT val = *valP; - char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; - - fixP->fx_addnumber = val; /* Remember value for emit_reloc. */ - - know (fixP->fx_size == 4); - know (fixP->fx_r_type < NO_RELOC); - - /* This is a hack. There should be a better way to handle this. */ - if (fixP->fx_r_type == RELOC_WDISP30 && fixP->fx_addsy) - val += fixP->fx_where + fixP->fx_frag->fr_address; - - switch (fixP->fx_r_type) - { - case RELOC_32: - buf[0] = val >> 24; - buf[1] = val >> 16; - buf[2] = val >> 8; - buf[3] = val; - break; - - case RELOC_8: - buf[0] = val; - break; - - case RELOC_WDISP30: - val = (val >> 2) + 1; - buf[0] |= (val >> 24) & 0x3f; - buf[1] = (val >> 16); - buf[2] = val >> 8; - buf[3] = val; - break; - - case RELOC_HI22: - buf[1] |= (val >> 26) & 0x3f; - buf[2] = val >> 18; - buf[3] = val >> 10; - break; - - case RELOC_LO10: - buf[2] |= (val >> 8) & 0x03; - buf[3] = val; - break; - - case RELOC_BASE13: - buf[2] |= (val >> 8) & 0x1f; - buf[3] = val; - break; - - case RELOC_WDISP22: - val = (val >> 2) + 1; - /* FALLTHROUGH */ - case RELOC_BASE22: - buf[1] |= (val >> 16) & 0x3f; - buf[2] = val >> 8; - buf[3] = val; - break; - - case RELOC_JUMPTARG: /* 00XX00XX pattern in a word. */ - if (!fixP->fx_done) - { - /* The linker tries to support both AMD and old GNU style - R_IREL relocs. That means that if the addend is exactly - the negative of the address within the section, the - linker will not handle it correctly. */ - if (fixP->fx_pcrel - && val != 0 - && val == - (fixP->fx_frag->fr_address + fixP->fx_where)) - as_bad_where - (fixP->fx_file, fixP->fx_line, - "the linker will not handle this relocation correctly"); - } - else if (fixP->fx_pcrel) - { - if (val + 0x20000 > 0x3ffff) - as_bad_where (fixP->fx_file, fixP->fx_line, - "call/jmp target out of range"); - } - else - /* This case was supposed to be handled in machine_ip. */ - abort (); - - buf[1] = val >> 10; /* Holds bits 0003FFFC of address. */ - buf[3] = val >> 2; - break; - - case RELOC_CONST: /* 00XX00XX pattern in a word. */ - buf[1] = val >> 8; /* Holds bits 0000XXXX. */ - buf[3] = val; - break; - - case RELOC_CONSTH: /* 00XX00XX pattern in a word. */ - buf[1] = val >> 24; /* Holds bits XXXX0000. */ - buf[3] = val >> 16; - break; - - case NO_RELOC: - default: - as_bad (_("bad relocation type: 0x%02x"), fixP->fx_r_type); - break; - } - - if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0) - fixP->fx_done = 1; -} - -#ifdef OBJ_COFF -short -tc_coff_fix2rtype (fixS *fixP) -{ - switch (fixP->fx_r_type) - { - case RELOC_32: return R_WORD; - case RELOC_8: return R_BYTE; - case RELOC_CONST: return R_ILOHALF; - case RELOC_CONSTH: return R_IHIHALF; - case RELOC_JUMPTARG: return R_IREL; - default: - printf (_("need %o3\n"), fixP->fx_r_type); - abort (); - } - - return 0; -} - -#endif /* OBJ_COFF */ - -/* Should never be called for 29k. */ - -void -md_convert_frag (object_headers *headers ATTRIBUTE_UNUSED, - segT seg ATTRIBUTE_UNUSED, - fragS *fragP ATTRIBUTE_UNUSED) -{ - as_fatal (_("a29k_convert_frag\n")); -} - -/* Should never be called for a29k. */ - -int -md_estimate_size_before_relax (fragS *fragP ATTRIBUTE_UNUSED, - segT segtype ATTRIBUTE_UNUSED) -{ - as_fatal (_("a29k_estimate_size_before_relax\n")); - return 0; -} - -/* Translate internal representation of relocation info to target format. - - On sparc/29k: first 4 bytes are normal unsigned long address, next three - bytes are index, most sig. byte first. Byte 7 is broken up with - bit 7 as external, bits 6 & 5 unused, and the lower - five bits as relocation type. Next 4 bytes are long addend. */ - -/* Thanx and a tip of the hat to Michael Bloom, mb@ttidca.tti.com. */ - -#ifdef OBJ_AOUT - -void -tc_aout_fix_to_chars (char *where, - fixS *fixP, - relax_addressT segment_address_in_file) -{ - long r_symbolnum; - - know (fixP->fx_r_type < NO_RELOC); - know (fixP->fx_addsy != NULL); - - md_number_to_chars (where, - fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file, - 4); - - r_symbolnum = (S_IS_DEFINED (fixP->fx_addsy) - ? S_GET_TYPE (fixP->fx_addsy) - : fixP->fx_addsy->sy_number); - - where[4] = (r_symbolnum >> 16) & 0x0ff; - where[5] = (r_symbolnum >> 8) & 0x0ff; - where[6] = r_symbolnum & 0x0ff; - where[7] = (((!S_IS_DEFINED (fixP->fx_addsy)) << 7) & 0x80) | (0 & 0x60) | (fixP->fx_r_type & 0x1F); - - /* Also easy. */ - md_number_to_chars (&where[8], fixP->fx_addnumber, 4); -} - -#endif /* OBJ_AOUT */ - -const char *md_shortopts = ""; - -struct option md_longopts[] = -{ - {NULL, no_argument, NULL, 0} -}; - -size_t md_longopts_size = sizeof (md_longopts); - -int -md_parse_option (int c ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED) -{ - return 0; -} - -void -md_show_usage (FILE *stream ATTRIBUTE_UNUSED) -{ -} - -/* This is called when a line is unrecognized. This is used to handle - definitions of a29k style local labels. */ - -int -a29k_unrecognized_line (int c) -{ - int lab; - char *s; - - if (c != '$' - || ! ISDIGIT (input_line_pointer[0])) - return 0; - - s = input_line_pointer; - - lab = 0; - while (ISDIGIT (*s)) - { - lab = lab * 10 + *s - '0'; - ++s; - } - - if (*s != ':') - { - /* Not a label definition. */ - return 0; - } - - if (dollar_label_defined (lab)) - { - as_bad (_("label \"$%d\" redefined"), lab); - return 0; - } - - define_dollar_label (lab); - colon (dollar_label_name (lab, 0)); - input_line_pointer = s + 1; - - return 1; -} - -/* Default the values of symbols known that should be "predefined". We - don't bother to predefine them unless you actually use one, since there - are a lot of them. */ - -symbolS * -md_undefined_symbol (char *name) -{ - long regnum; - char testbuf[5 + /*SLOP*/ 5]; - - if (name[0] == 'g' || name[0] == 'G' - || name[0] == 'l' || name[0] == 'L' - || name[0] == 's' || name[0] == 'S') - { - /* Perhaps a global or local register name. */ - if (name[1] == 'r' || name[1] == 'R') - { - long maxreg; - - /* Parse the number, make sure it has no extra zeroes or - trailing chars. */ - regnum = atol (&name[2]); - - if (name[0] == 's' || name[0] == 'S') - maxreg = 255; - else - maxreg = 127; - if (regnum > maxreg) - return NULL; - - sprintf (testbuf, "%ld", regnum); - if (strcmp (testbuf, &name[2]) != 0) - return NULL; /* gr007 or lr7foo or whatever. */ - - /* We have a wiener! Define and return a new symbol for it. */ - if (name[0] == 'l' || name[0] == 'L') - regnum += 128; - else if (name[0] == 's' || name[0] == 'S') - regnum += SREG; - return (symbol_new (name, SEG_REGISTER, (valueT) regnum, - &zero_address_frag)); - } - } - - return NULL; -} - -/* Parse an operand that is machine-specific. */ - -void -md_operand (expressionS *expressionP) -{ - if (input_line_pointer[0] == '%' && input_line_pointer[1] == '%') - { - /* We have a numeric register expression. No biggy. */ - input_line_pointer += 2; /* Skip %% */ - (void) expression (expressionP); - if (expressionP->X_op != O_constant - || expressionP->X_add_number > 255) - as_bad (_("Invalid expression after %%%%\n")); - expressionP->X_op = O_register; - } - else if (input_line_pointer[0] == '&') - { - /* We are taking the 'address' of a register...this one is not - in the manual, but it *is* in traps/fpsymbol.h! What they - seem to want is the register number, as an absolute number. */ - input_line_pointer++; /* Skip & */ - (void) expression (expressionP); - if (expressionP->X_op != O_register) - as_bad (_("Invalid register in & expression")); - else - expressionP->X_op = O_constant; - } - else if (input_line_pointer[0] == '$' - && ISDIGIT (input_line_pointer[1])) - { - long lab; - char *name; - symbolS *sym; - - /* This is a local label. */ - ++input_line_pointer; - lab = (long) get_absolute_expression (); - if (dollar_label_defined (lab)) - { - name = dollar_label_name (lab, 0); - sym = symbol_find (name); - } - else - { - name = dollar_label_name (lab, 1); - sym = symbol_find_or_make (name); - } - - expressionP->X_op = O_symbol; - expressionP->X_add_symbol = sym; - expressionP->X_add_number = 0; - } - else if (input_line_pointer[0] == '$') - { - char *s; - char type; - int fieldnum, fieldlimit; - LITTLENUM_TYPE floatbuf[8]; - - /* $float(), $doubleN(), or $extendN() convert floating values - to integers. */ - - s = input_line_pointer; - - ++s; - - fieldnum = 0; - if (strncmp (s, "double", sizeof "double" - 1) == 0) - { - s += sizeof "double" - 1; - type = 'd'; - fieldlimit = 2; - } - else if (strncmp (s, "float", sizeof "float" - 1) == 0) - { - s += sizeof "float" - 1; - type = 'f'; - fieldlimit = 1; - } - else if (strncmp (s, "extend", sizeof "extend" - 1) == 0) - { - s += sizeof "extend" - 1; - type = 'x'; - fieldlimit = 4; - } - else - return; - - if (ISDIGIT (*s)) - { - fieldnum = *s - '0'; - ++s; - } - - if (fieldnum >= fieldlimit) - return; - - SKIP_WHITESPACE (); - if (*s != '(') - return; - ++s; - SKIP_WHITESPACE (); - - s = atof_ieee (s, type, floatbuf); - if (s == NULL) - return; - s = s; - - SKIP_WHITESPACE (); - if (*s != ')') - return; - ++s; - SKIP_WHITESPACE (); - - input_line_pointer = s; - expressionP->X_op = O_constant; - expressionP->X_unsigned = 1; - expressionP->X_add_number = ((floatbuf[fieldnum * 2] - << LITTLENUM_NUMBER_OF_BITS) - + floatbuf[fieldnum * 2 + 1]); - } -} - -/* Round up a section size to the appropriate boundary. */ - -valueT -md_section_align (segT segment ATTRIBUTE_UNUSED, valueT size) -{ - return size; /* Byte alignment is fine. */ -} - -/* Exactly what point is a PC-relative offset relative TO? - On the 29000, they're relative to the address of the instruction, - which we have set up as the address of the fixup too. */ - -long -md_pcrel_from (fixS *fixP) -{ - return fixP->fx_where + fixP->fx_frag->fr_address; -} - -const pseudo_typeS -md_pseudo_table[] = -{ - {"align", s_align_bytes, 4}, - {"block", s_space, 0}, - {"cputype", s_ignore, 0}, /* CPU as 29000 or 29050. */ - {"reg", s_lsym, 0}, /* Register equate, same as equ. */ - {"space", s_ignore, 0}, /* Listing control. */ - {"sect", s_ignore, 0}, /* Creation of coff sections. */ -#ifndef OBJ_COFF - {"use", s_use, 0}, /* We can do this right with coff. */ -#endif - {"word", cons, 4}, - {NULL, 0, 0}, -}; diff --git a/gas/config/tc-a29k.h b/gas/config/tc-a29k.h deleted file mode 100644 index f5fc386..0000000 --- a/gas/config/tc-a29k.h +++ /dev/null @@ -1,53 +0,0 @@ -/* tc-a29k.h -- Assemble for the AMD 29000. - Copyright 1989, 1990, 1991, 1992, 1993, 1995, 1998, 2003, 2005 - 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -#define TC_A29K - -#define TARGET_BYTES_BIG_ENDIAN 1 - -#define WORKING_DOT_WORD - -#define LEX_DOLLAR 1 - -#define tc_unrecognized_line(c) a29k_unrecognized_line (c) -extern int a29k_unrecognized_line (int); - -#define tc_headers_hook(a) ; /* Not used. */ -#define tc_headers_hook(a) ; /* Not used. */ -#define tc_crawl_symbol_chain(a) ; /* Not used. */ -#define tc_coff_symbol_emit_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 attached. - on the h8, this is always true, since no fixup is done. */ -#define TC_COUNT_RELOC(x) (x->fx_addsy) -#define TC_CONS_RELOC RELOC_32 - -#define COFF_FLAGS F_AR32W -#define reloc_type int -#define NEED_FX_R_TYPE - -#define ZERO_BASED_SEGMENTS - diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index 6a587f3..7cd3db4 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -175,9 +175,6 @@ static int meabi_flags = EF_ARM_EABI_UNKNOWN; symbolS * GOT_symbol; #endif -/* Size of relocation record. */ -const int md_reloc_size = 8; - /* 0: assemble for ARM, 1: assemble for Thumb, 2: assemble for Thumb even though target CPU does not support thumb diff --git a/gas/config/tc-arm.h b/gas/config/tc-arm.h index e692f52..1def078 100644 --- a/gas/config/tc-arm.h +++ b/gas/config/tc-arm.h @@ -32,8 +32,6 @@ #define COFF_MAGIC ARMMAGIC #define TARGET_ARCH bfd_arch_arm -#define AOUT_MACHTYPE 0 - #define DIFF_EXPR_OK #ifdef LITTLE_ENDIAN @@ -121,7 +119,6 @@ struct fix; #define TC_START_LABEL(C,STR) (c == ':' || (c == '/' && arm_data_in_code ())) #define tc_canonicalize_symbol_name(str) arm_canonicalize_symbol_name (str); #define obj_adjust_symtab() arm_adjust_symtab () -#define tc_aout_pre_write_hook(x) {;} /* not used */ #define LISTING_HEADER "ARM GAS " diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c index 39e695f..3516001 100644 --- a/gas/config/tc-avr.c +++ b/gas/config/tc-avr.c @@ -1085,12 +1085,11 @@ md_apply_fix (fixP, valP, seg) } } -/* A `BFD_ASSEMBLER' GAS will call this to generate a reloc. GAS - will pass the resulting reloc to `bfd_install_relocation'. This - currently works poorly, as `bfd_install_relocation' often does the - wrong thing, and instances of `tc_gen_reloc' have been written to - work around the problems, which in turns makes it difficult to fix - `bfd_install_relocation'. */ +/* GAS will call this to generate a reloc, passing the resulting reloc + to `bfd_install_relocation'. This currently works poorly, as + `bfd_install_relocation' often does the wrong thing, and instances of + `tc_gen_reloc' have been written to work around the problems, which + in turns makes it difficult to fix `bfd_install_relocation'. */ /* If while processing a fixup, a reloc really needs to be created then it is done here. */ diff --git a/gas/config/tc-avr.h b/gas/config/tc-avr.h index d667ebb..75d923e 100644 --- a/gas/config/tc-avr.h +++ b/gas/config/tc-avr.h @@ -1,5 +1,5 @@ /* This file is tc-avr.h - Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc. Contributed by Denis Chertykov <denisc@overta.ru> @@ -20,10 +20,6 @@ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef BFD_ASSEMBLER - #error AVR support requires BFD_ASSEMBLER -#endif - /* By convention, you should define this macro in the `.h' file. For example, `tc-m68k.h' defines `TC_M68K'. You might have to use this if it is necessary to add CPU specific code to the object format diff --git a/gas/config/tc-crx.h b/gas/config/tc-crx.h index bc6c1f7..b1c3c65 100644 --- a/gas/config/tc-crx.h +++ b/gas/config/tc-crx.h @@ -31,10 +31,8 @@ #define TARGET_FORMAT "elf32-crx" #define TARGET_ARCH bfd_arch_crx -#define BFD_ARCH bfd_arch_crx #define WORKING_DOT_WORD -#define NEED_FX_R_TYPE #define LOCAL_LABEL_PREFIX '.' #define md_undefined_symbol(s) 0 diff --git a/gas/config/tc-d10v.h b/gas/config/tc-d10v.h index 4453bf6..f9a30b4 100644 --- a/gas/config/tc-d10v.h +++ b/gas/config/tc-d10v.h @@ -24,10 +24,6 @@ #define TARGET_BYTES_BIG_ENDIAN 0 -#ifndef BFD_ASSEMBLER - #error D10V support requires BFD_ASSEMBLER -#endif - /* The target BFD architecture. */ #define TARGET_ARCH bfd_arch_d10v diff --git a/gas/config/tc-d30v.h b/gas/config/tc-d30v.h index 4c80301..9a5e7cc 100644 --- a/gas/config/tc-d30v.h +++ b/gas/config/tc-d30v.h @@ -22,10 +22,6 @@ #define TC_D30V -#ifndef BFD_ASSEMBLER - #error D30V support requires BFD_ASSEMBLER -#endif - /* The target BFD architecture. */ #define TARGET_ARCH bfd_arch_d30v #define TARGET_FORMAT "elf32-d30v" diff --git a/gas/config/tc-dlx.h b/gas/config/tc-dlx.h index e675649..309f037 100644 --- a/gas/config/tc-dlx.h +++ b/gas/config/tc-dlx.h @@ -22,10 +22,6 @@ #define TC_DLX -#ifndef BFD_ASSEMBLER - #error DLX support requires BFD_ASSEMBLER -#endif - #ifndef __BFD_H_SEEN__ #include "bfd.h" #endif @@ -52,21 +48,9 @@ extern bfd_boolean md_dlx_fix_adjustable (struct fix *); #define tc_unrecognized_line(c) dlx_unrecognized_line (c) -#define tc_headers_hook(a) ; /* Not used. */ -#define tc_headers_hook(a) ; /* Not used. */ -#define tc_crawl_symbol_chain(a) ; /* Not used. */ #define tc_coff_symbol_emit_hook(a) ; /* Not used. */ -#define AOUT_MACHTYPE 101 -#define TC_COFF_FIX2RTYPE(fix_ptr) tc_coff_fix2rtype (fix_ptr) -#define BFD_ARCH bfd_arch_dlx #define COFF_MAGIC DLXMAGIC -/* Should the reloc be output ? - on the 29k, this is true only if there is a symbol attached. - on the h8, this is always true, since no fixup is done - on dlx, I have no idea!! but lets keep it here just for fun. */ -#define TC_COUNT_RELOC(x) (x->fx_addsy) -#define TC_CONS_RELOC BFD_RELOC_32_PCREL /* No shared lib support, so we don't need to ensure externally visible symbols can be overridden. */ @@ -77,8 +61,6 @@ extern bfd_boolean md_dlx_fix_adjustable (struct fix *); /* Values passed to md_apply_fix don't include the symbol value. */ #define MD_APPLY_SYM_VALUE(FIX) 0 -#define NEED_FX_R_TYPE - /* Zero Based Segment?? sound very dangerous to me! */ #define ZERO_BASED_SEGMENTS diff --git a/gas/config/tc-fr30.h b/gas/config/tc-fr30.h index edbddf7..a3a832a 100644 --- a/gas/config/tc-fr30.h +++ b/gas/config/tc-fr30.h @@ -21,11 +21,6 @@ #define TC_FR30 -#ifndef BFD_ASSEMBLER -/* Leading space so will compile with cc. */ - #error FR30 support requires BFD_ASSEMBLER -#endif - #define LISTING_HEADER "FR30 GAS " /* The target BFD architecture. */ diff --git a/gas/config/tc-frv.h b/gas/config/tc-frv.h index db4e366..ddf5c02 100644 --- a/gas/config/tc-frv.h +++ b/gas/config/tc-frv.h @@ -20,11 +20,6 @@ #define TC_FRV -#ifndef BFD_ASSEMBLER -/* leading space so will compile with cc */ - #error FRV support requires BFD_ASSEMBLER -#endif - #define LISTING_HEADER "FRV GAS " /* The target BFD architecture. */ diff --git a/gas/config/tc-h8300.c b/gas/config/tc-h8300.c index 8e926ad..7db600c 100644 --- a/gas/config/tc-h8300.c +++ b/gas/config/tc-h8300.c @@ -25,10 +25,7 @@ #include "as.h" #include "subsegs.h" #include "bfd.h" - -#ifdef BFD_ASSEMBLER #include "dwarf2dbg.h" -#endif #define DEFINE_TABLE #define h8_opcodes ops @@ -77,10 +74,8 @@ h8300hmode (int arg ATTRIBUTE_UNUSED) { Hmode = 1; Smode = 0; -#ifdef BFD_ASSEMBLER if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, bfd_mach_h8300h)) as_warn (_("could not set architecture and machine")); -#endif } static void @@ -88,10 +83,8 @@ h8300smode (int arg ATTRIBUTE_UNUSED) { Smode = 1; Hmode = 1; -#ifdef BFD_ASSEMBLER if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, bfd_mach_h8300s)) as_warn (_("could not set architecture and machine")); -#endif } static void @@ -100,10 +93,8 @@ h8300hnmode (int arg ATTRIBUTE_UNUSED) Hmode = 1; Smode = 0; Nmode = 1; -#ifdef BFD_ASSEMBLER if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, bfd_mach_h8300hn)) as_warn (_("could not set architecture and machine")); -#endif } static void @@ -112,10 +103,8 @@ h8300snmode (int arg ATTRIBUTE_UNUSED) Smode = 1; Hmode = 1; Nmode = 1; -#ifdef BFD_ASSEMBLER if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, bfd_mach_h8300sn)) as_warn (_("could not set architecture and machine")); -#endif } static void @@ -124,10 +113,8 @@ h8300sxmode (int arg ATTRIBUTE_UNUSED) Smode = 1; Hmode = 1; SXmode = 1; -#ifdef BFD_ASSEMBLER if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, bfd_mach_h8300sx)) as_warn (_("could not set architecture and machine")); -#endif } static void @@ -137,10 +124,8 @@ h8300sxnmode (int arg ATTRIBUTE_UNUSED) Hmode = 1; SXmode = 1; Nmode = 1; -#ifdef BFD_ASSEMBLER if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, bfd_mach_h8300sxn)) as_warn (_("could not set architecture and machine")); -#endif } static void @@ -184,8 +169,6 @@ const pseudo_typeS md_pseudo_table[] = {0, 0, 0} }; -const int md_reloc_size; - const char EXP_CHARS[] = "eE"; /* Chars that mean this number is a floating point constant @@ -208,10 +191,8 @@ md_begin (void) char prev_buffer[100]; int idx = 0; -#ifdef BFD_ASSEMBLER if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, bfd_mach_h8300)) as_warn (_("could not set architecture and machine")); -#endif opcode_hash_control = hash_new (); prev_buffer[0] = 0; @@ -2017,18 +1998,8 @@ md_assemble (char *str) build_bytes (instruction, operand); -#ifdef BFD_ASSEMBLER dwarf2_emit_insn (instruction->length); -#endif -} - -#ifndef BFD_ASSEMBLER -void -tc_crawl_symbol_chain (object_headers *headers ATTRIBUTE_UNUSED) -{ - printf (_("call to tc_crawl_symbol_chain \n")); } -#endif symbolS * md_undefined_symbol (char *name ATTRIBUTE_UNUSED) @@ -2036,14 +2007,6 @@ md_undefined_symbol (char *name ATTRIBUTE_UNUSED) return 0; } -#ifndef BFD_ASSEMBLER -void -tc_headers_hook (object_headers *headers ATTRIBUTE_UNUSED) -{ - printf (_("call to tc_headers_hook \n")); -} -#endif - /* Various routines to kill one day */ /* Equal to MAX_PRECISION in atof-ieee.c */ #define MAX_LITTLENUMS 6 @@ -2132,12 +2095,7 @@ tc_aout_fix_to_chars (void) } void -md_convert_frag ( -#ifdef BFD_ASSEMBLER - bfd *headers ATTRIBUTE_UNUSED, -#else - object_headers *headers ATTRIBUTE_UNUSED, -#endif +md_convert_frag (bfd *headers ATTRIBUTE_UNUSED, segT seg ATTRIBUTE_UNUSED, fragS *fragP ATTRIBUTE_UNUSED) { @@ -2145,22 +2103,12 @@ md_convert_frag ( abort (); } -#ifdef BFD_ASSEMBLER valueT md_section_align (segT segment, valueT size) { int align = bfd_get_section_alignment (stdoutput, segment); return ((size + (1 << align) - 1) & (-1 << align)); } -#else -valueT -md_section_align (segT seg, valueT size) -{ - return ((size + (1 << section_alignment[(int) seg]) - 1) - & (-1 << section_alignment[(int) seg])); -} -#endif - void md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) @@ -2212,66 +2160,6 @@ md_pcrel_from (fixS *fixP ATTRIBUTE_UNUSED) abort (); } -#ifndef BFD_ASSEMBLER -void -tc_reloc_mangle (fixS *fix_ptr, struct internal_reloc *intr, bfd_vma base) -{ - symbolS *symbol_ptr; - - symbol_ptr = fix_ptr->fx_addsy; - - /* If this relocation is attached to a symbol then it's ok - to output it. */ - if (fix_ptr->fx_r_type == TC_CONS_RELOC) - { - /* cons likes to create reloc32's whatever the size of the reloc.. - */ - switch (fix_ptr->fx_size) - { - case 4: - intr->r_type = R_RELLONG; - break; - case 2: - intr->r_type = R_RELWORD; - break; - case 1: - intr->r_type = R_RELBYTE; - break; - default: - abort (); - } - } - else - { - intr->r_type = fix_ptr->fx_r_type; - } - - intr->r_vaddr = fix_ptr->fx_frag->fr_address + fix_ptr->fx_where + base; - intr->r_offset = fix_ptr->fx_offset; - - if (symbol_ptr) - { - if (symbol_ptr->sy_number != -1) - intr->r_symndx = symbol_ptr->sy_number; - else - { - symbolS *segsym; - - /* This case arises when a reference is made to `.'. */ - segsym = seg_info (S_GET_SEGMENT (symbol_ptr))->dot; - if (segsym == NULL) - intr->r_symndx = -1; - else - { - intr->r_symndx = segsym->sy_number; - intr->r_offset += S_GET_VALUE (symbol_ptr); - } - } - } - else - intr->r_symndx = -1; -} -#else /* BFD_ASSEMBLER */ arelent * tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp) { @@ -2313,4 +2201,3 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp) return rel; } -#endif diff --git a/gas/config/tc-h8300.h b/gas/config/tc-h8300.h index 4493838..3d928fd 100644 --- a/gas/config/tc-h8300.h +++ b/gas/config/tc-h8300.h @@ -1,6 +1,6 @@ /* This file is tc-h8300.h Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, - 1997, 1998, 2000, 2001, 2002, 2003 + 1997, 1998, 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -26,10 +26,8 @@ #define TARGET_ARCH bfd_arch_h8300 -#ifdef BFD_ASSEMBLER /* Fixup debug sections since we will never relax them. */ #define TC_LINKRELAX_FIXUP(seg) (seg->flags & SEC_ALLOC) -#endif #ifdef OBJ_ELF #define TARGET_FORMAT "elf32-h8300" #define LOCAL_LABEL_PREFIX '.' @@ -42,12 +40,7 @@ struct internal_reloc; #define WORKING_DOT_WORD -/* This macro translates between an internal fix and a coff reloc type. */ -#define TC_COFF_FIX2RTYPE(fixP) abort (); - -#define BFD_ARCH bfd_arch_h8300 #define COFF_MAGIC ( Smode && Nmode ? 0x8304 : Hmode && Nmode ? 0x8303 : Smode ? 0x8302 : Hmode ? 0x8301 : 0x8300) -#define TC_COUNT_RELOC(x) (1) #define IGNORE_NONSTANDARD_ESCAPES #define tc_coff_symbol_emit_hook(a) ; /* not used */ @@ -84,10 +77,7 @@ extern void tc_reloc_mangle (struct fix *, struct internal_reloc *, bfd_vma); #define tc_fix_adjustable(FIX) 0 #endif -#define TC_CONS_RELOC (Hmode ? R_RELLONG: R_RELWORD) - #define LISTING_HEADER "Renesas H8/300 GAS " -#define NEED_FX_R_TYPE 1 #ifndef OBJ_ELF #define RELOC_32 1234 #endif diff --git a/gas/config/tc-h8500.c b/gas/config/tc-h8500.c deleted file mode 100644 index 63168b0..0000000 --- a/gas/config/tc-h8500.c +++ /dev/null @@ -1,1486 +0,0 @@ -/* tc-h8500.c -- Assemble code for the Renesas H8/500 - Copyright 1993, 1994, 1995, 1998, 2000, 2001, 2002, 2003, 2005 - 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -/* Written By Steve Chamberlain <sac@cygnus.com>. */ - -#include <stdio.h> -#include "as.h" -#include "bfd.h" -#include "subsegs.h" -#define DEFINE_TABLE -#define ASSEMBLER_TABLE -#include "opcodes/h8500-opc.h" -#include "safe-ctype.h" - -const char comment_chars[] = "!"; -const char line_separator_chars[] = ";"; -const char line_comment_chars[] = "!#"; - -/* This table describes all the machine specific pseudo-ops the assembler - has to support. The fields are: - pseudo-op name without dot - function to call to execute this pseudo-op - Integer arg to pass to the function. */ - -const pseudo_typeS md_pseudo_table[] = -{ - {"int", cons, 2}, - {"data.b", cons, 1}, - {"data.w", cons, 2}, - {"data.l", cons, 4}, - {"form", listing_psize, 0}, - {"heading", listing_title, 0}, - {"import", s_ignore, 0}, - {"page", listing_eject, 0}, - {"program", s_ignore, 0}, - {0, 0, 0} -}; - -const int md_reloc_size; - -const char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant. - As in 0f12.456 - or 0d1.2345e12. */ -const char FLT_CHARS[] = "rRsSfFdDxXpP"; - -#define C(a,b) ENCODE_RELAX(a, b) -#define ENCODE_RELAX(what, length) (((what) << 2) + (length)) - -#define GET_WHAT(x) ((x >> 2)) - -#define BYTE_DISP 1 -#define WORD_DISP 2 -#define UNDEF_BYTE_DISP 0 -#define UNDEF_WORD_DISP 3 - -#define BRANCH 1 -#define SCB_F 2 -#define SCB_TST 3 -#define END 4 - -#define BYTE_F 127 -#define BYTE_B -126 -#define WORD_F 32767 -#define WORD_B 32768 - -relax_typeS md_relax_table[C (END, 0)] = -{ - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - - /* BRANCH */ - { 0, 0, 0, 0 }, - { BYTE_F, BYTE_B, 2, C (BRANCH, WORD_DISP) }, - { WORD_F, WORD_B, 3, 0 }, - { 0, 0, 3, 0 }, - - /* SCB_F */ - { 0, 0, 0, 0 }, - { BYTE_F, BYTE_B, 3, C (SCB_F, WORD_DISP) }, - { WORD_F, WORD_B, 8, 0 }, - { 0, 0, 8, 0 }, - - /* SCB_TST */ - { 0, 0, 0, 0 }, - { BYTE_F, BYTE_B, 3, C (SCB_TST, WORD_DISP) }, - { WORD_F, WORD_B, 10, 0 }, - { 0, 0, 10, 0 } - -}; - -static struct hash_control *opcode_hash_control; /* Opcode mnemonics. */ - -/* This function is called once, at assembler startup time. This should - set up all the tables, etc. that the MD part of the assembler needs. */ - -void -md_begin (void) -{ - const h8500_opcode_info *opcode; - char prev_buffer[100]; - int idx = 0; - - opcode_hash_control = hash_new (); - prev_buffer[0] = 0; - - /* Insert unique names into hash table. */ - for (opcode = h8500_table; opcode->name; opcode++) - { - if (idx != opcode->idx) - { - hash_insert (opcode_hash_control, opcode->name, (char *) opcode); - idx++; - } - } -} - -static int rn; /* Register number used by RN. */ -static int rs; /* Register number used by RS. */ -static int rd; /* Register number used by RD. */ -static int crb; /* Byte size cr. */ -static int crw; /* Word sized cr. */ -static int cr; /* Unknown size cr. */ - -static expressionS displacement;/* Displacement expression. */ -static int immediate_inpage; -static expressionS immediate; /* Immediate expression. */ -static expressionS absolute; /* Absolute expression. */ - -typedef struct -{ - int type; - unsigned int reg; - expressionS exp; - int page; -} - -h8500_operand_info; - -/* Try to parse a reg name. Return the number of chars consumed. */ - -static int parse_reg (char *, int *, unsigned int *); - -static int -parse_reg (char *src, int *mode, unsigned int *reg) -{ - char *end; - int len; - - /* Cribbed from get_symbol_end(). */ - if (!is_name_beginner (*src) || *src == '\001') - return 0; - end = src + 1; - while (is_part_of_name (*end) || *end == '\001') - end++; - len = end - src; - - if (len == 2 && src[0] == 'r') - { - if (src[1] >= '0' && src[1] <= '7') - { - *mode = RN; - *reg = (src[1] - '0'); - return len; - } - } - if (len == 2 && src[0] == 's' && src[1] == 'p') - { - *mode = RN; - *reg = 7; - return len; - } - if (len == 3 && src[0] == 'c' && src[1] == 'c' && src[2] == 'r') - { - *mode = CRB; - *reg = 1; - return len; - } - if (len == 2 && src[0] == 's' && src[1] == 'r') - { - *mode = CRW; - *reg = 0; - return len; - } - if (len == 2 && src[0] == 'b' && src[1] == 'r') - { - *mode = CRB; - *reg = 3; - return len; - } - if (len == 2 && src[0] == 'e' && src[1] == 'p') - { - *mode = CRB; - *reg = 4; - return len; - } - if (len == 2 && src[0] == 'd' && src[1] == 'p') - { - *mode = CRB; - *reg = 5; - return len; - } - if (len == 2 && src[0] == 't' && src[1] == 'p') - { - *mode = CRB; - *reg = 7; - return len; - } - if (len == 2 && src[0] == 'f' && src[1] == 'p') - { - *mode = RN; - *reg = 6; - return len; - } - return 0; -} - -static char * -parse_exp (char *s, expressionS *op, int *page) -{ - char *save; - char *new; - - save = input_line_pointer; - - *page = 0; - if (s[0] == '%') - { - if (s[1] == 'p' && s[2] == 'a' && s[3] == 'g' && s[4] == 'e') - { - s += 5; - *page = 'p'; - } - if (s[1] == 'h' && s[2] == 'i' && s[3] == '1' && s[4] == '6') - { - s += 5; - *page = 'h'; - } - else if (s[1] == 'o' && s[2] == 'f' && s[3] == 'f') - { - s += 4; - *page = 'o'; - } - } - - input_line_pointer = s; - - expression (op); - if (op->X_op == O_absent) - as_bad (_("missing operand")); - new = input_line_pointer; - input_line_pointer = save; - return new; -} - -typedef enum -{ - exp_signed, exp_unsigned, exp_sandu -} sign_type; - -static char * -skip_colonthing (sign_type sign, - char *ptr, - h8500_operand_info *exp, - int def, - int size8, - int size16, - int size24) -{ - ptr = parse_exp (ptr, &exp->exp, &exp->page); - if (*ptr == ':') - { - ptr++; - if (*ptr == '8') - { - ptr++; - exp->type = size8; - } - else if (ptr[0] == '1' && ptr[1] == '6') - { - ptr += 2; - exp->type = size16; - } - else if (ptr[0] == '2' && ptr[1] == '4') - { - if (!size24) - { - as_bad (_(":24 not valid for this opcode")); - } - ptr += 2; - exp->type = size24; - } - else - { - as_bad (_("expect :8,:16 or :24")); - exp->type = size16; - } - } - else - { - if (exp->page == 'p') - exp->type = IMM8; - else if (exp->page == 'h') - exp->type = IMM16; - else - { - /* Let's work out the size from the context. */ - int n = exp->exp.X_add_number; - - if (size8 - && exp->exp.X_op == O_constant - && ((sign == exp_signed && (n >= -128 && n <= 127)) - || (sign == exp_unsigned && (n >= 0 && (n <= 255))) - || (sign == exp_sandu && (n >= -128 && (n <= 255))))) - exp->type = size8; - else - exp->type = def; - } - } - return ptr; -} - -static int -parse_reglist (char *src, h8500_operand_info *op) -{ - int mode; - unsigned int rn; - int mask = 0; - unsigned int rm; - int idx = 1; - - /* Skip (. */ - while (src[idx] && src[idx] != ')') - { - int done = parse_reg (src + idx, &mode, &rn); - - if (done) - { - idx += done; - mask |= 1 << rn; - } - else - { - as_bad (_("syntax error in reg list")); - return 0; - } - - if (src[idx] == '-') - { - idx++; - done = parse_reg (src + idx, &mode, &rm); - if (done) - { - idx += done; - while (rn <= rm) - { - mask |= 1 << rn; - rn++; - } - } - else - as_bad (_("missing final register in range")); - } - - if (src[idx] == ',') - idx++; - } - idx++; - op->exp.X_add_symbol = 0; - op->exp.X_op_symbol = 0; - op->exp.X_add_number = mask; - op->exp.X_op = O_constant; - op->exp.X_unsigned = 1; - op->type = IMM8; - return idx; -} - -/* The many forms of operand: - - Rn Register direct - @Rn Register indirect - @(disp[:size], Rn) Register indirect with displacement - @Rn+ - @-Rn - @aa[:size] absolute - #xx[:size] immediate data. */ - -static void -get_operand (char **ptr, - h8500_operand_info *op, - char ispage) -{ - char *src = *ptr; - int mode; - unsigned int num; - unsigned int len; - - op->page = 0; - if (src[0] == '(' && src[1] == 'r') - { - /* This is a register list */ - *ptr = src + parse_reglist (src, op); - return; - } - - len = parse_reg (src, &op->type, &op->reg); - - if (len) - { - *ptr = src + len; - return; - } - - if (*src == '@') - { - src++; - if (*src == '-') - { - src++; - len = parse_reg (src, &mode, &num); - if (len == 0) - { - /* Oops, not a reg after all, must be ordinary exp */ - src--; - /* must be a symbol */ - *ptr = skip_colonthing (exp_unsigned, src, - op, ABS16, ABS8, ABS16, ABS24); - return; - } - - op->type = RNDEC; - op->reg = num; - *ptr = src + len; - return; - } - if (*src == '(') - { - /* Disp */ - src++; - - src = skip_colonthing (exp_signed, src, - op, RNIND_D16, RNIND_D8, RNIND_D16, 0); - - if (*src != ',') - { - as_bad (_("expected @(exp, Rn)")); - return; - } - src++; - len = parse_reg (src, &mode, &op->reg); - if (len == 0 || mode != RN) - { - as_bad (_("expected @(exp, Rn)")); - return; - } - src += len; - if (*src != ')') - { - as_bad (_("expected @(exp, Rn)")); - return; - } - *ptr = src + 1; - return; - } - len = parse_reg (src, &mode, &num); - - if (len) - { - src += len; - if (*src == '+') - { - src++; - if (mode != RN) - { - as_bad (_("@Rn+ needs word register")); - return; - } - op->type = RNINC; - op->reg = num; - *ptr = src; - return; - } - if (mode != RN) - { - as_bad (_("@Rn needs word register")); - return; - } - op->type = RNIND; - op->reg = num; - *ptr = src; - return; - } - else - { - /* must be a symbol */ - *ptr = - skip_colonthing (exp_unsigned, src, op, - ispage ? ABS24 : ABS16, ABS8, ABS16, ABS24); - return; - } - } - - if (*src == '#') - { - src++; - *ptr = skip_colonthing (exp_sandu, src, op, IMM16, IMM8, IMM16, ABS24); - return; - } - else - *ptr = skip_colonthing (exp_signed, src, op, - ispage ? ABS24 : PCREL8, PCREL8, PCREL16, ABS24); -} - -static char * -get_operands (h8500_opcode_info *info, - char *args, - h8500_operand_info *operand) -{ - char *ptr = args; - - switch (info->nargs) - { - case 0: - operand[0].type = 0; - operand[1].type = 0; - break; - - case 1: - ptr++; - get_operand (&ptr, operand + 0, info->name[0] == 'p'); - operand[1].type = 0; - break; - - case 2: - ptr++; - get_operand (&ptr, operand + 0, 0); - if (*ptr == ',') - ptr++; - get_operand (&ptr, operand + 1, 0); - break; - - default: - abort (); - } - - return ptr; -} - -/* Passed a pointer to a list of opcodes which use different - addressing modes, return the opcode which matches the opcodes - provided. */ - -int pcrel8; /* Set when we've seen a pcrel operand. */ - -static h8500_opcode_info * -get_specific (h8500_opcode_info *opcode, - h8500_operand_info *operands) -{ - h8500_opcode_info *this_try = opcode; - int found = 0; - unsigned int noperands = opcode->nargs; - int this_index = opcode->idx; - - while (this_index == opcode->idx && !found) - { - unsigned int i; - - this_try = opcode++; - - /* Look at both operands needed by the opcodes and provided by - the user. */ - for (i = 0; i < noperands; i++) - { - h8500_operand_info *user = operands + i; - - switch (this_try->arg_type[i]) - { - case FPIND_D8: - /* Opcode needs (disp:8,fp). */ - if (user->type == RNIND_D8 && user->reg == 6) - { - displacement = user->exp; - continue; - } - break; - case RDIND_D16: - if (user->type == RNIND_D16) - { - displacement = user->exp; - rd = user->reg; - continue; - } - break; - case RDIND_D8: - if (user->type == RNIND_D8) - { - displacement = user->exp; - rd = user->reg; - continue; - } - break; - case RNIND_D16: - case RNIND_D8: - if (user->type == this_try->arg_type[i]) - { - displacement = user->exp; - rn = user->reg; - continue; - } - break; - - case SPDEC: - if (user->type == RNDEC && user->reg == 7) - continue; - break; - - case SPINC: - if (user->type == RNINC && user->reg == 7) - continue; - break; - - case ABS16: - if (user->type == ABS16) - { - absolute = user->exp; - continue; - } - break; - case ABS8: - if (user->type == ABS8) - { - absolute = user->exp; - continue; - } - break; - case ABS24: - if (user->type == ABS24) - { - absolute = user->exp; - continue; - } - break; - - case CRB: - if ((user->type == CRB || user->type == CR) && user->reg != 0) - { - crb = user->reg; - continue; - } - break; - case CRW: - if ((user->type == CRW || user->type == CR) && user->reg == 0) - { - crw = user->reg; - continue; - } - break; - case DISP16: - if (user->type == DISP16) - { - displacement = user->exp; - continue; - } - break; - case DISP8: - if (user->type == DISP8) - { - displacement = user->exp; - continue; - } - break; - case FP: - if (user->type == RN && user->reg == 6) - continue; - break; - - case PCREL16: - if (user->type == PCREL16) - { - displacement = user->exp; - continue; - } - break; - case PCREL8: - if (user->type == PCREL8) - { - displacement = user->exp; - pcrel8 = 1; - continue; - } - break; - - case IMM16: - if (user->type == IMM16 - || user->type == IMM8) - { - immediate_inpage = user->page; - immediate = user->exp; - continue; - } - break; - case RLIST: - case IMM8: - if (user->type == IMM8) - { - immediate_inpage = user->page; - immediate = user->exp; - continue; - } - break; - case IMM4: - if (user->type == IMM8) - { - immediate_inpage = user->page; - immediate = user->exp; - continue; - } - break; - case QIM: - if (user->type == IMM8 - && user->exp.X_op == O_constant - && (user->exp.X_add_number == -2 - || user->exp.X_add_number == -1 - || user->exp.X_add_number == 1 - || user->exp.X_add_number == 2)) - { - immediate_inpage = user->page; - immediate = user->exp; - continue; - } - break; - case RD: - if (user->type == RN) - { - rd = user->reg; - continue; - } - break; - case RS: - if (user->type == RN) - { - rs = user->reg; - continue; - } - break; - case RDIND: - if (user->type == RNIND) - { - rd = user->reg; - continue; - - } - break; - case RNINC: - case RNIND: - case RNDEC: - case RN: - if (user->type == this_try->arg_type[i]) - { - rn = user->reg; - continue; - } - break; - case SP: - if (user->type == RN && user->reg == 7) - continue; - break; - default: - printf (_("unhandled %d\n"), this_try->arg_type[i]); - break; - } - - /* If we get here this didn't work out. */ - goto fail; - } - found = 1; - fail:; - - } - - if (found) - return this_try; - else - return 0; -} - -static int -check (expressionS *operand, - int low, - int high) -{ - if (operand->X_op != O_constant - || operand->X_add_number < low - || operand->X_add_number > high) - as_bad (_("operand must be absolute in range %d..%d"), low, high); - - return operand->X_add_number; -} - -static void -insert (char *output, int index, expressionS *exp, int reloc, int pcrel) -{ - fix_new_exp (frag_now, - output - frag_now->fr_literal + index, - 4, /* Always say size is 4, but we know better. */ - exp, pcrel, reloc); -} - -static void -build_relaxable_instruction (h8500_opcode_info *opcode, - h8500_operand_info *operand ATTRIBUTE_UNUSED) -{ - /* All relaxable instructions start life as two bytes but can become - three bytes long if a lonely branch and up to 9 bytes if long - scb. */ - char *p; - int len; - int type; - - if (opcode->bytes[0].contents == 0x01) - type = SCB_F; - else if (opcode->bytes[0].contents == 0x06 - || opcode->bytes[0].contents == 0x07) - type = SCB_TST; - else - type = BRANCH; - - p = frag_var (rs_machine_dependent, - md_relax_table[C (type, WORD_DISP)].rlx_length, - len = md_relax_table[C (type, BYTE_DISP)].rlx_length, - C (type, UNDEF_BYTE_DISP), - displacement.X_add_symbol, - displacement.X_add_number, - 0); - - p[0] = opcode->bytes[0].contents; - if (type != BRANCH) - p[1] = opcode->bytes[1].contents | rs; -} - -/* Now we know what sort of opcodes it is, let's build the bytes. */ - -static void -build_bytes (h8500_opcode_info *opcode, h8500_operand_info *operand) -{ - int index; - - if (pcrel8) - { - pcrel8 = 0; - build_relaxable_instruction (opcode, operand); - } - else - { - char *output = frag_more (opcode->length); - - memset (output, 0, opcode->length); - for (index = 0; index < opcode->length; index++) - { - output[index] = opcode->bytes[index].contents; - - switch (opcode->bytes[index].insert) - { - default: - printf (_("failed for %d\n"), opcode->bytes[index].insert); - break; - case 0: - break; - case RN: - output[index] |= rn; - break; - case RD: - case RDIND: - output[index] |= rd; - break; - case RS: - output[index] |= rs; - break; - case DISP16: - insert (output, index, &displacement, R_H8500_IMM16, 0); - index++; - break; - case DISP8: - case FPIND_D8: - insert (output, index, &displacement, R_H8500_IMM8, 0); - break; - case IMM16: - { - int p; - - switch (immediate_inpage) - { - case 'p': - p = R_H8500_HIGH16; - break; - case 'h': - p = R_H8500_HIGH16; - break; - default: - p = R_H8500_IMM16; - break; - } - insert (output, index, &immediate, p, 0); - } - index++; - break; - case RLIST: - case IMM8: - if (immediate_inpage) - insert (output, index, &immediate, R_H8500_HIGH8, 0); - else - insert (output, index, &immediate, R_H8500_IMM8, 0); - break; - case PCREL16: - insert (output, index, &displacement, R_H8500_PCREL16, 1); - index++; - break; - case PCREL8: - insert (output, index, &displacement, R_H8500_PCREL8, 1); - break; - case IMM4: - output[index] |= check (&immediate, 0, 15); - break; - case CR: - output[index] |= cr; - if (cr == 0) - output[0] |= 0x8; - else - output[0] &= ~0x8; - break; - case CRB: - output[index] |= crb; - output[0] &= ~0x8; - break; - case CRW: - output[index] |= crw; - output[0] |= 0x8; - break; - case ABS24: - insert (output, index, &absolute, R_H8500_IMM24, 0); - index += 2; - break; - case ABS16: - insert (output, index, &absolute, R_H8500_IMM16, 0); - index++; - break; - case ABS8: - insert (output, index, &absolute, R_H8500_IMM8, 0); - break; - case QIM: - switch (immediate.X_add_number) - { - case -2: - output[index] |= 0x5; - break; - case -1: - output[index] |= 0x4; - break; - case 1: - output[index] |= 0; - break; - case 2: - output[index] |= 1; - break; - } - break; - } - } - } -} - -/* This is the guts of the machine-dependent assembler. STR points to - a machine dependent instruction. This function is supposed to emit - the frags/bytes it assembles to. */ - -void -md_assemble (char *str) -{ - char *op_start; - char *op_end; - h8500_operand_info operand[2]; - h8500_opcode_info *opcode; - h8500_opcode_info *prev_opcode; - char name[11]; - - int nlen = 0; - - /* Drop leading whitespace. */ - while (*str == ' ') - str++; - - /* Find the op code end. */ - for (op_start = op_end = str; - !is_end_of_line[(unsigned char) *op_end] && *op_end != ' '; - op_end++) - if (nlen < 10) - name[nlen++] = *op_end; - - name[nlen] = 0; - - if (op_end == op_start) - as_bad (_("can't find opcode ")); - - opcode = (h8500_opcode_info *) hash_find (opcode_hash_control, name); - - if (opcode == NULL) - { - as_bad (_("unknown opcode")); - return; - } - - get_operands (opcode, op_end, operand); - prev_opcode = opcode; - - opcode = get_specific (opcode, operand); - - if (opcode == 0) - { - /* Couldn't find an opcode which matched the operands. */ - char *where = frag_more (2); - - where[0] = 0x0; - where[1] = 0x0; - as_bad (_("invalid operands for opcode")); - return; - } - - build_bytes (opcode, operand); -} - -void -tc_crawl_symbol_chain (object_headers *headers ATTRIBUTE_UNUSED) -{ - printf (_("call to tc_crawl_symbol_chain \n")); -} - -symbolS * -md_undefined_symbol (char *name ATTRIBUTE_UNUSED) -{ - return NULL; -} - -void -tc_headers_hook (object_headers *headers ATTRIBUTE_UNUSED) -{ - printf (_("call to tc_headers_hook \n")); -} - -/* Various routines to kill one day. */ -/* Equal to MAX_PRECISION in atof-ieee.c. */ -#define MAX_LITTLENUMS 6 - -/* Turn a string in input_line_pointer into a floating point constant - of type type, and store the appropriate bytes in *LITP. The number - of LITTLENUMS emitted is stored in *SIZEP. An error message is - returned, or NULL on OK. */ - -char * -md_atof (int type, char *litP, int *sizeP) -{ - int prec; - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - char *t; - - switch (type) - { - case 'f': - case 'F': - case 's': - case 'S': - prec = 2; - break; - - case 'd': - case 'D': - case 'r': - case 'R': - prec = 4; - break; - - case 'x': - case 'X': - prec = 6; - break; - - case 'p': - case 'P': - prec = 6; - break; - - default: - *sizeP = 0; - return _("Bad call to MD_ATOF()"); - } - t = atof_ieee (input_line_pointer, type, words); - if (t) - input_line_pointer = t; - - *sizeP = prec * sizeof (LITTLENUM_TYPE); - for (wordP = words; prec--;) - { - md_number_to_chars (litP, (long) (*wordP++), sizeof (LITTLENUM_TYPE)); - litP += sizeof (LITTLENUM_TYPE); - } - return 0; -} - -const char *md_shortopts = ""; -struct option md_longopts[] = -{ - {NULL, no_argument, NULL, 0} -}; -size_t md_longopts_size = sizeof (md_longopts); - -int -md_parse_option (int c ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED) -{ - return 0; -} - -void -md_show_usage (FILE *stream ATTRIBUTE_UNUSED) -{ -} - -static void -wordify_scb (char *buffer, int *disp_size, int *inst_size) -{ - int rn = buffer[1] & 0x7; - - switch (buffer[0]) - { - case 0x0e: /* BSR */ - case 0x20: - case 0x21: - case 0x22: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - case 0x29: - case 0x2a: - case 0x2b: - case 0x2c: - case 0x2d: - case 0x2e: - case 0x2f: - buffer[0] |= 0x10; - buffer[1] = 0; - buffer[2] = 0; - *disp_size = 2; - *inst_size = 1; - return; - default: - abort (); - - case 0x01: - *inst_size = 6; - *disp_size = 2; - break; - case 0x06: - *inst_size = 8; - *disp_size = 2; - - *buffer++ = 0x26; /* bne + 8 */ - *buffer++ = 0x08; - break; - case 0x07: - *inst_size = 8; - *disp_size = 2; - *buffer++ = 0x27; /* bne + 8 */ - *buffer++ = 0x08; - break; - - } - *buffer++ = 0xa8 | rn; /* addq -1,rn */ - *buffer++ = 0x0c; - *buffer++ = 0x04; /* cmp #0xff:8, rn */ - *buffer++ = 0xff; - *buffer++ = 0x70 | rn; - *buffer++ = 0x36; /* bne ... */ - *buffer++ = 0; - *buffer++ = 0; -} - -/* Called after relaxing, change the frags so they know how big they - are. */ - -void -md_convert_frag (object_headers *headers ATTRIBUTE_UNUSED, - segT seg ATTRIBUTE_UNUSED, - fragS *fragP) -{ - int disp_size = 0; - int inst_size = 0; - char *buffer = fragP->fr_fix + fragP->fr_literal; - - switch (fragP->fr_subtype) - { - case C (BRANCH, BYTE_DISP): - disp_size = 1; - inst_size = 1; - break; - - case C (SCB_F, BYTE_DISP): - case C (SCB_TST, BYTE_DISP): - disp_size = 1; - inst_size = 2; - break; - - /* Branches to a known 16 bit displacement. */ - - /* Turn on the 16bit bit. */ - case C (BRANCH, WORD_DISP): - case C (SCB_F, WORD_DISP): - case C (SCB_TST, WORD_DISP): - wordify_scb (buffer, &disp_size, &inst_size); - break; - - case C (BRANCH, UNDEF_WORD_DISP): - case C (SCB_F, UNDEF_WORD_DISP): - case C (SCB_TST, UNDEF_WORD_DISP): - /* This tried to be relaxed, but didn't manage it, it now needs - a fix. */ - wordify_scb (buffer, &disp_size, &inst_size); - - /* Make a reloc */ - fix_new (fragP, - fragP->fr_fix + inst_size, - 4, - fragP->fr_symbol, - fragP->fr_offset, - 0, - R_H8500_PCREL16); - - fragP->fr_fix += disp_size + inst_size; - return; - break; - default: - abort (); - } - if (inst_size) - { - /* Get the address of the end of the instruction. */ - int next_inst = fragP->fr_fix + fragP->fr_address + disp_size + inst_size; - int targ_addr = (S_GET_VALUE (fragP->fr_symbol) + - fragP->fr_offset); - int disp = targ_addr - next_inst; - - md_number_to_chars (buffer + inst_size, disp, disp_size); - fragP->fr_fix += disp_size + inst_size; - } -} - -valueT -md_section_align (segT seg, valueT size) -{ - return ((size + (1 << section_alignment[(int) seg]) - 1) - & (-1 << section_alignment[(int) seg])); -} - -void -md_apply_fix (fixS *fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED) -{ - long val = * (long *) valP; - char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; - - if (fixP->fx_r_type == 0) - fixP->fx_r_type = fixP->fx_size == 4 ? R_H8500_IMM32 : R_H8500_IMM16; - - switch (fixP->fx_r_type) - { - case R_H8500_IMM8: - case R_H8500_PCREL8: - *buf++ = val; - break; - case R_H8500_IMM16: - case R_H8500_LOW16: - case R_H8500_PCREL16: - *buf++ = (val >> 8); - *buf++ = val; - break; - case R_H8500_HIGH8: - *buf++ = val >> 16; - break; - case R_H8500_HIGH16: - *buf++ = val >> 24; - *buf++ = val >> 16; - break; - case R_H8500_IMM24: - *buf++ = (val >> 16); - *buf++ = (val >> 8); - *buf++ = val; - break; - case R_H8500_IMM32: - *buf++ = (val >> 24); - *buf++ = (val >> 16); - *buf++ = (val >> 8); - *buf++ = val; - break; - default: - abort (); - } - - if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0) - fixP->fx_done = 1; -} - -/* Called just before address relaxation, return the length - by which a fragment must grow to reach it's destination. */ - -int -md_estimate_size_before_relax (fragS *fragP, segT segment_type) -{ - int what; - - switch (fragP->fr_subtype) - { - default: - abort (); - - case C (BRANCH, UNDEF_BYTE_DISP): - case C (SCB_F, UNDEF_BYTE_DISP): - case C (SCB_TST, UNDEF_BYTE_DISP): - what = GET_WHAT (fragP->fr_subtype); - /* Used to be a branch to somewhere which was unknown. */ - if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type) - { - /* Got a symbol and it's defined in this segment, become byte - sized - maybe it will fix up. */ - fragP->fr_subtype = C (what, BYTE_DISP); - } - else - /* Its got a segment, but its not ours, so it will always be - long. */ - fragP->fr_subtype = C (what, UNDEF_WORD_DISP); - break; - - case C (BRANCH, BYTE_DISP): - case C (BRANCH, WORD_DISP): - case C (BRANCH, UNDEF_WORD_DISP): - case C (SCB_F, BYTE_DISP): - case C (SCB_F, WORD_DISP): - case C (SCB_F, UNDEF_WORD_DISP): - case C (SCB_TST, BYTE_DISP): - case C (SCB_TST, WORD_DISP): - case C (SCB_TST, UNDEF_WORD_DISP): - /* When relaxing a section for the second time, we don't need to - do anything besides return the current size. */ - break; - } - - return md_relax_table[fragP->fr_subtype].rlx_length; -} - -/* Put number into target byte order. */ - -void -md_number_to_chars (char *ptr, valueT use, int nbytes) -{ - number_to_chars_bigendian (ptr, use, nbytes); -} - -long -md_pcrel_from (fixS *fixP) -{ - return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address; -} - -void -tc_coff_symbol_emit_hook (symbolS *ignore ATTRIBUTE_UNUSED) -{ -} - -short -tc_coff_fix2rtype (fixS *fix_ptr) -{ - if (fix_ptr->fx_r_type == RELOC_32) - { - /* Cons likes to create reloc32's whatever the size of the reloc. */ - switch (fix_ptr->fx_size) - { - case 2: - return R_H8500_IMM16; - break; - case 1: - return R_H8500_IMM8; - break; - default: - abort (); - } - } - return fix_ptr->fx_r_type; -} - -void -tc_reloc_mangle (fixS *fix_ptr, - struct internal_reloc *intr, - bfd_vma base) -{ - symbolS *symbol_ptr; - - symbol_ptr = fix_ptr->fx_addsy; - - /* If this relocation is attached to a symbol then it's ok - to output it */ - if (fix_ptr->fx_r_type == RELOC_32) - { - /* Cons likes to create reloc32's whatever the size of the reloc. */ - switch (fix_ptr->fx_size) - { - case 2: - intr->r_type = R_IMM16; - break; - case 1: - intr->r_type = R_IMM8; - break; - default: - abort (); - } - } - else - intr->r_type = fix_ptr->fx_r_type; - - intr->r_vaddr = fix_ptr->fx_frag->fr_address + fix_ptr->fx_where + base; - intr->r_offset = fix_ptr->fx_offset; - - /* Turn the segment of the symbol into an offset. */ - if (symbol_ptr) - { - symbolS *dot; - - dot = segment_info[S_GET_SEGMENT (symbol_ptr)].dot; - if (dot) - { - intr->r_offset += S_GET_VALUE (symbol_ptr); - intr->r_symndx = dot->sy_number; - } - else - intr->r_symndx = symbol_ptr->sy_number; - } - else - intr->r_symndx = -1; -} - -int -start_label (char *ptr) -{ - /* Check for :s.w */ - if (ISALPHA (ptr[1]) && ptr[2] == '.') - return 0; - /* Check for :s */ - if (ISALPHA (ptr[1]) && !ISALPHA (ptr[2])) - return 0; - return 1; -} - -int -tc_coff_sizemachdep (fragS *frag) -{ - return md_relax_table[frag->fr_subtype].rlx_length; -} diff --git a/gas/config/tc-h8500.h b/gas/config/tc-h8500.h deleted file mode 100644 index 024f212..0000000 --- a/gas/config/tc-h8500.h +++ /dev/null @@ -1,55 +0,0 @@ -/* This file is tc-h8500.h - Copyright 1993, 1995, 1997, 1998, 2000, 2003, 2005 - 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -#define TC_H8500 - -#define TARGET_BYTES_BIG_ENDIAN 1 - -struct internal_reloc; - -#define WORKING_DOT_WORD - -/* This macro translates between an internal fix and a coff reloc type. */ -#define TC_COFF_FIX2RTYPE(fixP) tc_coff_fix2rtype (fixP) - -#define BFD_ARCH bfd_arch_h8500 -#define COFF_MAGIC 0x8500 -#define TC_COUNT_RELOC(x) ((x)->fx_addsy || (x)->fx_subsy) -#define IGNORE_NONSTANDARD_ESCAPES - -#define TC_RELOC_MANGLE(s,a,b,c) tc_reloc_mangle(a, b, c) -extern void tc_reloc_mangle - (struct fix *, struct internal_reloc *, bfd_vma); - -#define LISTING_HEADER "Renesas H8/500 GAS " -#define NEED_FX_R_TYPE 1 -#define RELOC_32 1234 - -#define TC_START_LABEL(ch, ptr) (ch == ':' && start_label (ptr)) -int start_label (char *); - -#define TC_COFF_SIZEMACHDEP(frag) tc_coff_sizemachdep (frag) -int tc_coff_sizemachdep (struct frag *); - -#define md_operand(x) - -extern struct relax_type md_relax_table[]; -#define TC_GENERIC_RELAX_TABLE md_relax_table diff --git a/gas/config/tc-hppa.h b/gas/config/tc-hppa.h index 5743173..9b3edc1 100644 --- a/gas/config/tc-hppa.h +++ b/gas/config/tc-hppa.h @@ -106,10 +106,6 @@ extern void pa_check_eof PARAMS ((void)); extern const char hppa_symbol_chars[]; #define tc_symbol_chars hppa_symbol_chars -/* The PA does not need support for either of these. */ -#define tc_crawl_symbol_chain(headers) {;} -#define tc_headers_hook(headers) {;} - #define RELOC_EXPANSION_POSSIBLE #define MAX_RELOC_EXPANSION 6 diff --git a/gas/config/tc-i370.h b/gas/config/tc-i370.h index 8822996..4cd5f2f 100644 --- a/gas/config/tc-i370.h +++ b/gas/config/tc-i370.h @@ -29,10 +29,6 @@ struct fix; #define TARGET_BYTES_BIG_ENDIAN 1 #endif -#ifndef BFD_ASSEMBLER - #error I370 support requires BFD_ASSEMBLER -#endif - /* The target BFD architecture. */ #define TARGET_ARCH (i370_arch ()) extern enum bfd_architecture i370_arch (void); diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 9482311..afdd169 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -4870,9 +4870,6 @@ int md_short_jump_size = 2; /* Size of dword displacement jmp. */ int md_long_jump_size = 5; -/* Size of relocation record. */ -const int md_reloc_size = 8; - void md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol) char *ptr; @@ -4986,10 +4983,7 @@ md_apply_fix (fixP, valP, seg) /* For some reason, the PE format does not store a section address offset for a PC relative symbol. */ if (S_GET_SEGMENT (fixP->fx_addsy) != seg -#if defined(BFD_ASSEMBLER) || defined(S_IS_WEAK) - || S_IS_WEAK (fixP->fx_addsy) -#endif - ) + || S_IS_WEAK (fixP->fx_addsy)) value += md_pcrel_from (fixP); #endif } diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h index 3796ae1..ddfe297 100644 --- a/gas/config/tc-i386.h +++ b/gas/config/tc-i386.h @@ -1,6 +1,6 @@ /* tc-i386.h -- Header file for tc-i386.c Copyright 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004 + 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -23,10 +23,6 @@ #ifndef TC_I386 #define TC_I386 1 -#ifndef BFD_ASSEMBLER -#error So, do you know what you are doing? -#endif - struct fix; #define TARGET_BYTES_BIG_ENDIAN 0 diff --git a/gas/config/tc-i860.h b/gas/config/tc-i860.h index 4fb34e5..11c36b5 100644 --- a/gas/config/tc-i860.h +++ b/gas/config/tc-i860.h @@ -1,5 +1,5 @@ /* tc-i860.h -- Header file for the i860. - Copyright 1991, 1992, 1995, 1998, 2000, 2001, 2002, 2003 + Copyright 1991, 1992, 1995, 1998, 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. Brought back from the dead and completely reworked @@ -24,10 +24,6 @@ #ifndef TC_I860 #define TC_I860 1 -#ifndef BFD_ASSEMBLER -#error i860 support requires BFD_ASSEMBLER -#endif - enum i860_fix_info { OP_NONE = 0x00000, diff --git a/gas/config/tc-i960.c b/gas/config/tc-i960.c index eef97fe..a3206bb 100644 --- a/gas/config/tc-i960.c +++ b/gas/config/tc-i960.c @@ -123,14 +123,6 @@ extern char *input_line_pointer; -#if !defined (BFD_ASSEMBLER) && !defined (BFD) -#ifdef OBJ_COFF -const int md_reloc_size = sizeof (struct reloc); -#else /* OBJ_COFF */ -const int md_reloc_size = sizeof (struct relocation_info); -#endif /* OBJ_COFF */ -#endif - /* Local i80960 routines. */ struct memS; struct regop; @@ -2050,17 +2042,10 @@ relax_cobr (fragS *fragP) /* fragP->fr_opcode is assumed to point to If the fragment substate is 2, a 13-bit displacement was not enough. Replace the cobr with a two instructions (a compare and a branch). */ -#ifndef BFD_ASSEMBLER -void -md_convert_frag (object_headers *headers ATTRIBUTE_UNUSED, - segT seg ATTRIBUTE_UNUSED, - fragS *fragP) -#else void md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT sec ATTRIBUTE_UNUSED, fragS *fragP) -#endif { /* Structure describing needed address fix. */ fixS *fixP; @@ -2455,15 +2440,6 @@ md_apply_fix (fixS *fixP, if (!fixP->fx_bit_fixP) { -#ifndef BFD_ASSEMBLER - /* For callx, we always want to write out zero, and emit a - symbolic relocation. */ - if (fixP->fx_bsr) - val = 0; - - fixP->fx_addnumber = val; -#endif - md_number_to_imm (place, val, fixP->fx_size); } else if ((int) (size_t) fixP->fx_bit_fixP == 13 @@ -2546,33 +2522,6 @@ tc_bout_fix_to_chars (char *where, #endif /* OBJ_AOUT or OBJ_BOUT */ -#if defined (OBJ_COFF) && defined (BFD) -short -tc_coff_fix2rtype (fixS *fixP) -{ - if (fixP->fx_bsr) - abort (); - - if (fixP->fx_pcrel == 0 && fixP->fx_size == 4) - return R_RELLONG; - - if (fixP->fx_pcrel != 0 && fixP->fx_size == 4) - return R_IPRMED; - - abort (); - return 0; -} - -int -tc_coff_sizemachdep (fragS *frag) -{ - if (frag->fr_next) - return frag->fr_next->fr_address - frag->fr_address; - else - return 0; -} -#endif - /* Align an address by rounding it up to the specified boundary. */ valueT @@ -2581,139 +2530,12 @@ md_section_align (segT seg, { int align; -#ifdef BFD_ASSEMBLER align = bfd_get_section_alignment (stdoutput, seg); -#else - align = section_alignment[(int) seg]; -#endif return (addr + (1 << align) - 1) & (-1 << align); } extern int coff_flags; -#ifdef OBJ_COFF -void -tc_headers_hook (object_headers *headers) -{ - switch (architecture) - { - case ARCH_KA: - coff_flags |= F_I960KA; - break; - - case ARCH_KB: - coff_flags |= F_I960KB; - break; - - case ARCH_MC: - coff_flags |= F_I960MC; - break; - - case ARCH_CA: - coff_flags |= F_I960CA; - break; - - case ARCH_JX: - coff_flags |= F_I960JX; - break; - - case ARCH_HX: - coff_flags |= F_I960HX; - break; - - default: - if (iclasses_seen == I_BASE) - coff_flags |= F_I960CORE; - else if (iclasses_seen & I_CX) - coff_flags |= F_I960CA; - else if (iclasses_seen & I_HX) - coff_flags |= F_I960HX; - else if (iclasses_seen & I_JX) - coff_flags |= F_I960JX; - else if (iclasses_seen & I_CX2) - coff_flags |= F_I960CA; - else if (iclasses_seen & I_MIL) - coff_flags |= F_I960MC; - else if (iclasses_seen & (I_DEC | I_FP)) - coff_flags |= F_I960KB; - else - coff_flags |= F_I960KA; - break; - } - - if (flag_readonly_data_in_text) - { - headers->filehdr.f_magic = I960RWMAGIC; - headers->aouthdr.magic = OMAGIC; - } - else - { - headers->filehdr.f_magic = I960ROMAGIC; - headers->aouthdr.magic = NMAGIC; - } /* set magic numbers */ -} - -#endif /* OBJ_COFF */ - -#ifndef BFD_ASSEMBLER - -/* Things going on here: - - For bout, We need to assure a couple of simplifying - assumptions about leafprocs for the linker: the leafproc - entry symbols will be defined in the same assembly in - which they're declared with the '.leafproc' directive; - and if a leafproc has both 'call' and 'bal' entry points - they are both global or both local. - - For coff, the call symbol has a second aux entry that - contains the bal entry point. The bal symbol becomes a - label. - - For coff representation, the call symbol has a second aux entry that - contains the bal entry point. The bal symbol becomes a label. */ - -void -tc_crawl_symbol_chain (object_headers *headers ATTRIBUTE_UNUSED) -{ - symbolS *symbolP; - - for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP)) - { -#ifdef OBJ_COFF - if (TC_S_IS_SYSPROC (symbolP)) - { - /* Second aux entry already contains the sysproc number. */ - S_SET_NUMBER_AUXILIARY (symbolP, 2); - S_SET_STORAGE_CLASS (symbolP, C_SCALL); - S_SET_DATA_TYPE (symbolP, S_GET_DATA_TYPE (symbolP) | (DT_FCN << N_BTSHFT)); - continue; - } -#endif /* OBJ_COFF */ - - if (!TC_S_IS_BALNAME (symbolP) && !TC_S_IS_CALLNAME (symbolP)) - continue; - - if (!S_IS_DEFINED (symbolP)) - as_bad (_("leafproc symbol '%s' undefined"), S_GET_NAME (symbolP)); - - if (TC_S_IS_CALLNAME (symbolP)) - { - symbolS *balP = tc_get_bal_of_call (symbolP); - - if (S_IS_EXTERNAL (symbolP) != S_IS_EXTERNAL (balP)) - { - S_SET_EXTERNAL (symbolP); - S_SET_EXTERNAL (balP); - as_warn (_("Warning: making leafproc entries %s and %s both global\n"), - S_GET_NAME (symbolP), S_GET_NAME (balP)); - } /* externality mismatch */ - } /* if callname */ - } /* walk the symbol chain */ -} - -#endif /* ! BFD_ASSEMBLER */ - /* For aout or bout, the bal immediately follows the call. For coff, we cheat and store a pointer to the bal symbol in the @@ -2841,8 +2663,6 @@ i960_validate_fix (fixS *fixP, segT this_segment_type ATTRIBUTE_UNUSED) return 1; } -#ifdef BFD_ASSEMBLER - /* From cgen.c: */ static short @@ -2895,8 +2715,6 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP) /* end from cgen.c */ -#endif /* BFD_ASSEMBLER */ - const pseudo_typeS md_pseudo_table[] = { {"bss", s_lcomm, 1}, diff --git a/gas/config/tc-i960.h b/gas/config/tc-i960.h index 897901d..05db36e 100644 --- a/gas/config/tc-i960.h +++ b/gas/config/tc-i960.h @@ -52,21 +52,12 @@ */ /* tailor gas */ -#define SYMBOLS_NEED_BACKPOINTERS #define LOCAL_LABELS_FB 1 #define BITFIELD_CONS_EXPRESSIONS /* tailor the coff format */ -#define BFD_ARCH bfd_arch_i960 -#define COFF_FLAGS F_AR32WR #define COFF_MAGIC I960ROMAGIC -#define OBJ_COFF_SECTION_HEADER_HAS_ALIGNMENT #define OBJ_COFF_MAX_AUXENTRIES (2) -#define TC_COUNT_RELOC(FIX) (!(FIX)->fx_done) -#define TC_COFF_FIX2RTYPE(FIX) tc_coff_fix2rtype (FIX) -#define TC_COFF_SIZEMACHDEP(FRAGP) tc_coff_sizemachdep (FRAGP) -#define TC_COFF_SET_MACHINE(HDRS) tc_headers_hook (HDRS) -extern int tc_coff_sizemachdep PARAMS ((struct frag *)); /* MEANING OF 'n_other' in the symbol record. * @@ -188,7 +179,6 @@ extern struct symbol *tc_get_bal_of_call PARAMS ((symbolS *)); extern void i960_handle_align PARAMS ((struct frag *)); #define HANDLE_ALIGN(FRAG) i960_handle_align (FRAG) -#define NEED_FX_R_TYPE #define NO_RELOC -1 #define md_operand(x) diff --git a/gas/config/tc-ip2k.h b/gas/config/tc-ip2k.h index ad8d906..e26e901 100644 --- a/gas/config/tc-ip2k.h +++ b/gas/config/tc-ip2k.h @@ -20,11 +20,6 @@ #define TC_IP2K -#ifndef BFD_ASSEMBLER -/* Leading space so will compile with cc. */ - #error IP2K support requires BFD_ASSEMBLER -#endif - #define LISTING_HEADER "IP2xxx GAS " /* The target BFD architecture. */ diff --git a/gas/config/tc-iq2000.h b/gas/config/tc-iq2000.h index 0fe7699..aba1da1 100644 --- a/gas/config/tc-iq2000.h +++ b/gas/config/tc-iq2000.h @@ -1,5 +1,5 @@ /* tc-iq2000.h -- Header file for tc-iq2000.c. - Copyright (C) 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -20,11 +20,6 @@ #define TC_IQ2000 -#ifndef BFD_ASSEMBLER -/* Leading space so will compile with cc. */ - #error IQ2000 support requires BFD_ASSEMBLER -#endif - #define LISTING_HEADER "IQ2000 GAS " /* The target BFD architecture. */ diff --git a/gas/config/tc-m32c.h b/gas/config/tc-m32c.h index 826bcf8..971b59d 100644 --- a/gas/config/tc-m32c.h +++ b/gas/config/tc-m32c.h @@ -1,5 +1,5 @@ /* tc-m32c.h -- Header file for tc-m32c.c. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2005 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -20,10 +20,6 @@ #define TC_M32C -#ifndef BFD_ASSEMBLER -#error M32C support requires BFD_ASSEMBLER -#endif - #define LISTING_HEADER "M16C/M32C GAS " /* The target BFD architecture. */ diff --git a/gas/config/tc-m32r.h b/gas/config/tc-m32r.h index 9ac61cf..eb03495 100644 --- a/gas/config/tc-m32r.h +++ b/gas/config/tc-m32r.h @@ -21,11 +21,6 @@ #define TC_M32R -#ifndef BFD_ASSEMBLER -/* Leading space so will compile with cc. */ - #error M32R support requires BFD_ASSEMBLER -#endif - #define LISTING_HEADER \ (target_big_endian ? "M32R GAS" : "M32R GAS Little Endian") diff --git a/gas/config/tc-m68hc11.h b/gas/config/tc-m68hc11.h index 954e486..a1a42b8 100644 --- a/gas/config/tc-m68hc11.h +++ b/gas/config/tc-m68hc11.h @@ -32,10 +32,6 @@ struct fix; /* Motorola assembler specs does not require '.' before pseudo-ops. */ #define NO_PSEUDO_DOT 1 -#ifndef BFD_ASSEMBLER -#error M68HC11 support requires BFD_ASSEMBLER -#endif - /* The target BFD architecture. */ #define TARGET_ARCH (m68hc11_arch ()) extern enum bfd_architecture m68hc11_arch (void); diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c index 07b06e7..8862a7f 100644 --- a/gas/config/tc-m68k.c +++ b/gas/config/tc-m68k.c @@ -70,8 +70,6 @@ const char FLT_CHARS[] = "rRsSfFdDxXeEpP"; changed in read.c . Ideally it shouldn't have to know about it at all, but nothing is ideal around here. */ -const int md_reloc_size = 8; /* Size of relocation record. */ - /* Are we trying to generate PIC code? If so, absolute references ought to be made into linkage table references or pc-relative references. Not implemented. For ELF there are other means @@ -740,63 +738,6 @@ find_cf_chip (int architecture) return buf; } -#if defined (M68KCOFF) && !defined (BFD_ASSEMBLER) - -#ifdef NO_PCREL_RELOCS - -int -make_pcrel_absolute (fixS *fixP, long *add_number) -{ - register unsigned char *opcode = fixP->fx_frag->fr_opcode; - - /* Rewrite the PC relative instructions to absolute address ones. - these are rumored to be faster, and the apollo linker refuses - to deal with the PC relative relocations. */ - if (opcode[0] == 0x60 && opcode[1] == 0xff) /* BRA -> JMP. */ - { - if (flag_keep_pcrel) - as_fatal (_("Tried to convert PC relative branch to absolute jump")); - opcode[0] = 0x4e; - opcode[1] = 0xf9; - } - else if (opcode[0] == 0x61 && opcode[1] == 0xff) /* BSR -> JSR. */ - { - if (flag_keep_pcrel) - as_fatal (_("Tried to convert PC relative BSR to absolute JSR")); - opcode[0] = 0x4e; - opcode[1] = 0xb9; - } - else - as_fatal (_("Unknown PC relative instruction")); - *add_number -= 4; - return 0; -} - -#endif /* NO_PCREL_RELOCS */ - -short -tc_coff_fix2rtype (fixS *fixP) -{ - if (fixP->fx_tcbit && fixP->fx_size == 4) - return R_RELLONG_NEG; -#ifdef NO_PCREL_RELOCS - know (fixP->fx_pcrel == 0); - return (fixP->fx_size == 1 ? R_RELBYTE - : fixP->fx_size == 2 ? R_DIR16 - : R_DIR32); -#else - return (fixP->fx_pcrel - ? (fixP->fx_size == 1 ? R_PCRBYTE - : fixP->fx_size == 2 ? R_PCRWORD - : R_PCRLONG) - : (fixP->fx_size == 1 ? R_RELBYTE - : fixP->fx_size == 2 ? R_RELWORD - : R_RELLONG)); -#endif -} - -#endif - #ifdef OBJ_ELF /* Return zero if the reference to SYMBOL from within the same segment may @@ -956,8 +897,6 @@ tc_m68k_fix_adjustable (fixS *fixP) #endif /* OBJ_ELF */ -#ifdef BFD_ASSEMBLER - arelent * tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp) { @@ -1068,8 +1007,6 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp) return reloc; } -#endif /* BFD_ASSEMBLER */ - /* Handle of the OPCODE hash table. NULL means any use before m68k_ip_begin() will crash. */ static struct hash_control *op_hash; @@ -2273,12 +2210,8 @@ m68k_ip (char *instring) && m68k_abspcadd) { opP->disp.exp.X_op = O_symbol; -#ifndef BFD_ASSEMBLER - opP->disp.exp.X_add_symbol = &abs_symbol; -#else opP->disp.exp.X_add_symbol = section_symbol (absolute_section); -#endif } /* Force into index mode. Hope this works. */ @@ -3894,11 +3827,6 @@ init_regtable (void) static int no_68851, no_68881; -#ifdef OBJ_AOUT -/* a.out machine type. Default to 68020. */ -int m68k_aout_machtype = 2; -#endif - void md_assemble (char *str) { @@ -4444,18 +4372,6 @@ m68k_init_after_args (void) if (no_68851 && (current_architecture & m68851)) as_bad (_("options for 68851 and no-68851 both given")); -#ifdef OBJ_AOUT - /* Work out the magic number. This isn't very general. */ - if (current_architecture & m68000) - m68k_aout_machtype = 0; - else if (current_architecture & m68010) - m68k_aout_machtype = 1; - else if (current_architecture & m68020) - m68k_aout_machtype = 2; - else - m68k_aout_machtype = 2; -#endif - /* Note which set of "movec" control registers is available. */ select_control_regs (); @@ -4654,11 +4570,9 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) } #endif -#ifdef BFD_ASSEMBLER if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY) return; -#endif switch (fixP->fx_size) { @@ -4712,10 +4626,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) in write.c may have clobbered fx_pcrel, so we need to examine the reloc type. */ if ((fixP->fx_pcrel -#ifdef BFD_ASSEMBLER - || fixP->fx_r_type == BFD_RELOC_8_PCREL -#endif - ) + || fixP->fx_r_type == BFD_RELOC_8_PCREL) && fixP->fx_size == 1 && (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy)) @@ -4943,18 +4854,6 @@ md_convert_frag_1 (fragS *fragP) } } -#ifndef BFD_ASSEMBLER - -void -md_convert_frag (object_headers *headers ATTRIBUTE_UNUSED, - segT sec ATTRIBUTE_UNUSED, - fragS *fragP) -{ - md_convert_frag_1 (fragP); -} - -#else - void md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT sec ATTRIBUTE_UNUSED, @@ -4962,7 +4861,6 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, { md_convert_frag_1 (fragP); } -#endif /* Force truly undefined symbols to their maximum size, and generally set up the frag list to be relaxed @@ -5121,38 +5019,6 @@ md_ri_to_chars (char *the_bytes, struct reloc_info_generic *ri) #endif -#ifndef BFD_ASSEMBLER -void -tc_aout_fix_to_chars (char *where, fixS *fixP, - relax_addressT segment_address_in_file) -{ - /* - * In: length of relocation (or of address) in chars: 1, 2 or 4. - * Out: GNU LD relocation length code: 0, 1, or 2. - */ - - static const unsigned char nbytes_r_length[] = {42, 0, 1, 42, 2}; - long r_symbolnum; - - know (fixP->fx_addsy != NULL); - - md_number_to_chars (where, - (fixP->fx_frag->fr_address - + fixP->fx_where - segment_address_in_file), 4); - - r_symbolnum = (S_IS_DEFINED (fixP->fx_addsy) - ? S_GET_TYPE (fixP->fx_addsy) - : fixP->fx_addsy->sy_number); - - where[4] = (r_symbolnum >> 16) & 0x0ff; - where[5] = (r_symbolnum >> 8) & 0x0ff; - where[6] = r_symbolnum & 0x0ff; - where[7] = (((fixP->fx_pcrel << 7) & 0x80) - | ((nbytes_r_length[fixP->fx_size] << 5) & 0x60) - | ((!S_IS_DEFINED (fixP->fx_addsy) << 4) & 0x10)); -} -#endif - #endif /* OBJ_AOUT or OBJ_BOUT */ #ifndef WORKING_DOT_WORD @@ -7408,7 +7274,6 @@ valueT md_section_align (segT segment ATTRIBUTE_UNUSED, valueT size) { #ifdef OBJ_AOUT -#ifdef BFD_ASSEMBLER /* For a.out, force the section size to be aligned. If we don't do this, BFD will align it for us, but it will not write out the final bytes of the section. This may be a bug in BFD, but it is @@ -7419,7 +7284,6 @@ md_section_align (segT segment ATTRIBUTE_UNUSED, valueT size) align = bfd_get_section_alignment (stdoutput, segment); size = ((size + (1 << align) - 1) & ((valueT) -1 << align)); #endif -#endif return size; } @@ -7441,34 +7305,6 @@ md_pcrel_from (fixS *fixP) return fixP->fx_where + fixP->fx_frag->fr_address - adjust; } -#ifndef BFD_ASSEMBLER -#ifdef OBJ_COFF - -void -tc_coff_symbol_emit_hook (symbolS *ignore ATTRIBUTE_UNUSED) -{ -} - -int -tc_coff_sizemachdep (fragS *frag) -{ - switch (frag->fr_subtype & 0x3) - { - case BYTE: - return 1; - case SHORT: - return 2; - case LONG: - return 4; - default: - abort (); - return 0; - } -} - -#endif -#endif - #ifdef OBJ_ELF void m68k_elf_final_processing (void) diff --git a/gas/config/tc-m68k.h b/gas/config/tc-m68k.h index 7f46592..523a387 100644 --- a/gas/config/tc-m68k.h +++ b/gas/config/tc-m68k.h @@ -61,34 +61,11 @@ struct fix; #ifndef COFF_MAGIC #define COFF_MAGIC MC68MAGIC #endif -#define BFD_ARCH bfd_arch_m68k /* for non-BFD_ASSEMBLER */ -#define TARGET_ARCH bfd_arch_m68k /* BFD_ASSEMBLER */ -#define COFF_FLAGS F_AR32W -#define TC_COUNT_RELOC(x) ((x)->fx_addsy||(x)->fx_subsy) - -#define TC_COFF_FIX2RTYPE(FIX) tc_coff_fix2rtype(FIX) -#define TC_COFF_SIZEMACHDEP(frag) tc_coff_sizemachdep(frag) -extern int tc_coff_sizemachdep (struct frag *); -#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 */ - -#ifndef AOUT_MACHTYPE -#define AOUT_MACHTYPE m68k_aout_machtype -extern int m68k_aout_machtype; -#endif +#define TARGET_ARCH bfd_arch_m68k #define tc_comment_chars m68k_comment_chars extern const char *m68k_comment_chars; -#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 */ @@ -101,10 +78,6 @@ extern const char *m68k_comment_chars; #if !defined (REGISTER_PREFIX_OPTIONAL) #if defined (M68KCOFF) || defined (OBJ_ELF) -#ifndef BFD_ASSEMBLER -#define LOCAL_LABEL(name) (name[0] == '.' \ - && (name[1] == 'L' || name[1] == '.')) -#endif /* ! BFD_ASSEMBLER */ #define REGISTER_PREFIX_OPTIONAL 0 #else /* ! (COFF || ELF) */ #define REGISTER_PREFIX_OPTIONAL 1 @@ -120,11 +93,6 @@ extern const char *m68k_comment_chars; #define tc_canonicalize_symbol_name(s) ((*(s) == '~' ? *(s) = '.' : '.'), s) /* On the Delta, dots are not required before pseudo-ops. */ #define NO_PSEUDO_DOT 1 -#ifndef BFD_ASSEMBLER -#undef LOCAL_LABEL -#define LOCAL_LABEL(name) \ - (name[0] == '.' || (name[0] == 'L' && name[1] == '%')) -#endif #endif extern void m68k_mri_mode_change (int); @@ -141,8 +109,6 @@ extern void m68k_flush_pending_output (void); extern void m68k_frob_symbol (symbolS *); -#ifdef BFD_ASSEMBLER - #define tc_frob_symbol(sym,punt) \ do \ { \ @@ -177,20 +143,6 @@ extern int tc_m68k_fix_adjustable (struct fix *); extern void m68k_elf_final_processing (void); #endif -#else /* ! BFD_ASSEMBLER */ - -#define tc_frob_coff_symbol(sym) m68k_frob_symbol (sym) - -#define NO_RELOC 0 -#define RELAX_RELOC_ABS8 0 -#define RELAX_RELOC_ABS16 0 -#define RELAX_RELOC_ABS32 0 -#define RELAX_RELOC_PC8 0 -#define RELAX_RELOC_PC16 0 -#define RELAX_RELOC_PC32 0 - -#endif /* ! BFD_ASSEMBLER */ - #define DIFF_EXPR_OK extern void m68k_init_after_args (void); diff --git a/gas/config/tc-m88k.c b/gas/config/tc-m88k.c deleted file mode 100644 index d4a950e..0000000 --- a/gas/config/tc-m88k.c +++ /dev/null @@ -1,1138 +0,0 @@ -/* m88k.c -- Assembler for the Motorola 88000 - Contributed by Devon Bowen of Buffalo University - and Torbjorn Granlund of the Swedish Institute of Computer Science. - Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999, - 2000, 2001, 2002, 2003, 2005 - 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -#include "as.h" -#include "safe-ctype.h" -#include "subsegs.h" -#include "m88k-opcode.h" - -struct field_val_assoc -{ - char *name; - unsigned val; -}; - -struct field_val_assoc cr_regs[] = -{ - {"PID", 0}, - {"PSR", 1}, - {"EPSR", 2}, - {"SSBR", 3}, - {"SXIP", 4}, - {"SNIP", 5}, - {"SFIP", 6}, - {"VBR", 7}, - {"DMT0", 8}, - {"DMD0", 9}, - {"DMA0", 10}, - {"DMT1", 11}, - {"DMD1", 12}, - {"DMA1", 13}, - {"DMT2", 14}, - {"DMD2", 15}, - {"DMA2", 16}, - {"SR0", 17}, - {"SR1", 18}, - {"SR2", 19}, - {"SR3", 20}, - - {NULL, 0}, -}; - -struct field_val_assoc fcr_regs[] = -{ - {"FPECR", 0}, - {"FPHS1", 1}, - {"FPLS1", 2}, - {"FPHS2", 3}, - {"FPLS2", 4}, - {"FPPT", 5}, - {"FPRH", 6}, - {"FPRL", 7}, - {"FPIT", 8}, - - {"FPSR", 62}, - {"FPCR", 63}, - - {NULL, 0}, -}; - -struct field_val_assoc cmpslot[] = -{ -/* Integer Floating point. */ - {"nc", 0}, - {"cp", 1}, - {"eq", 2}, - {"ne", 3}, - {"gt", 4}, - {"le", 5}, - {"lt", 6}, - {"ge", 7}, - {"hi", 8}, {"ou", 8}, - {"ls", 9}, {"ib", 9}, - {"lo", 10}, {"in", 10}, - {"hs", 11}, {"ob", 11}, - {"be", 12}, {"ue", 12}, - {"nb", 13}, {"lg", 13}, - {"he", 14}, {"ug", 14}, - {"nh", 15}, {"ule", 15}, - {"ul", 16}, - {"uge", 17}, - - {NULL, 0}, -}; - -struct field_val_assoc cndmsk[] = -{ - {"gt0", 1}, - {"eq0", 2}, - {"ge0", 3}, - {"lt0", 12}, - {"ne0", 13}, - {"le0", 14}, - - {NULL, 0}, -}; - -struct m88k_insn -{ - unsigned long opcode; - expressionS exp; - enum reloc_type reloc; -}; - -extern char *myname; -static struct hash_control *op_hash = NULL; - -/* These bits should be turned off in the first address of every segment. */ -int md_seg_align = 7; - -/* These chars start a comment anywhere in a source file (except inside - another comment. */ -const char comment_chars[] = ";"; - -/* These chars only start a comment at the beginning of a line. */ -const char line_comment_chars[] = "#"; - -const char line_separator_chars[] = ""; - -/* Chars that can be used to separate mant from exp in floating point nums. */ -const char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant. - as in 0f123.456 - or 0H1.234E-12 (see exp chars above). */ -const char FLT_CHARS[] = "dDfF"; - -void -md_begin (void) -{ - const char *retval = NULL; - unsigned int i = 0; - - /* Initialize hash table. */ - op_hash = hash_new (); - - while (*m88k_opcodes[i].name) - { - char *name = m88k_opcodes[i].name; - - /* Hash each mnemonic and record its position. */ - retval = hash_insert (op_hash, name, &m88k_opcodes[i]); - - if (retval != NULL) - as_fatal (_("Can't hash instruction '%s':%s"), - m88k_opcodes[i].name, retval); - - /* Skip to next unique mnemonic or end of list. */ - for (i++; !strcmp (m88k_opcodes[i].name, name); i++) - ; - } -} - -const char *md_shortopts = ""; -struct option md_longopts[] = -{ - {NULL, no_argument, NULL, 0} -}; -size_t md_longopts_size = sizeof (md_longopts); - -int -md_parse_option (int c ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED) -{ - return 0; -} - -void -md_show_usage (FILE *stream ATTRIBUTE_UNUSED) -{ -} - -static char * -get_o6 (char *param, unsigned *valp) -{ - unsigned val; - char *save_ptr; - - save_ptr = input_line_pointer; - input_line_pointer = param; - val = get_absolute_expression (); - param = input_line_pointer; - input_line_pointer = save_ptr; - - if (val & 0x3) - as_warn (_("Removed lower 2 bits of expression")); - - *valp = val; - - return (param); -} - -static char * -get_vec9 (char *param, unsigned *valp) -{ - unsigned val; - char *save_ptr; - - save_ptr = input_line_pointer; - input_line_pointer = param; - val = get_absolute_expression (); - param = input_line_pointer; - input_line_pointer = save_ptr; - - if (val >= 1 << 9) - as_warn (_("Expression truncated to 9 bits")); - - *valp = val % (1 << 9); - - return param; -} - -static char * -get_bf2 (char *param, int bc) -{ - int depth = 0; - int c; - - for (;;) - { - c = *param; - if (c == 0) - return param; - else if (c == '(') - depth++; - else if (c == ')') - depth--; - else if (c == bc && depth <= 0) - return param; - param++; - } -} - -static char * -match_name (char *param, - struct field_val_assoc *assoc_tab, - unsigned *valp) -{ - int i; - char *name; - int name_len; - - for (i = 0;; i++) - { - name = assoc_tab[i].name; - if (name == NULL) - return NULL; - name_len = strlen (name); - if (!strncmp (param, name, name_len)) - { - *valp = assoc_tab[i].val; - return param + name_len; - } - } -} - -static char * -get_bf_offset_expression (char *param, unsigned *offsetp) -{ - unsigned offset; - - if (ISALPHA (param[0])) - { - param[0] = TOLOWER (param[0]); - param[1] = TOLOWER (param[1]); - - param = match_name (param, cmpslot, offsetp); - - return param; - } - else - { - input_line_pointer = param; - offset = get_absolute_expression (); - param = input_line_pointer; - } - - *offsetp = offset; - return param; -} - -static char * -get_bf (char *param, unsigned *valp) -{ - unsigned offset = 0; - unsigned width = 0; - char *xp; - char *save_ptr; - - xp = get_bf2 (param, '<'); - - save_ptr = input_line_pointer; - input_line_pointer = param; - if (*xp == 0) - { - /* We did not find '<'. We have an offset (width implicitly 32). */ - param = get_bf_offset_expression (param, &offset); - input_line_pointer = save_ptr; - if (param == NULL) - return NULL; - } - else - { - *xp++ = 0; /* Overwrite the '<'. */ - param = get_bf2 (xp, '>'); - if (*param == 0) - return NULL; - *param++ = 0; /* Overwrite the '>'. */ - - width = get_absolute_expression (); - xp = get_bf_offset_expression (xp, &offset); - input_line_pointer = save_ptr; - - if (xp + 1 != param) - return NULL; - } - - *valp = ((width % 32) << 5) | (offset % 32); - - return param; -} - -static char * -get_cr (char *param, unsigned *regnop) -{ - unsigned regno; - unsigned c; - - if (!strncmp (param, "cr", 2)) - { - param += 2; - - regno = *param++ - '0'; - if (regno < 10) - { - if (regno == 0) - { - *regnop = 0; - return param; - } - c = *param - '0'; - if (c < 10) - { - regno = regno * 10 + c; - if (c < 64) - { - *regnop = regno; - return param + 1; - } - } - else - { - *regnop = regno; - return param; - } - } - return NULL; - } - - param = match_name (param, cr_regs, regnop); - - return param; -} - -static char * -get_fcr (char *param, unsigned *regnop) -{ - unsigned regno; - unsigned c; - - if (!strncmp (param, "fcr", 3)) - { - param += 3; - - regno = *param++ - '0'; - if (regno < 10) - { - if (regno == 0) - { - *regnop = 0; - return param; - } - c = *param - '0'; - if (c < 10) - { - regno = regno * 10 + c; - if (c < 64) - { - *regnop = regno; - return param + 1; - } - } - else - { - *regnop = regno; - return param; - } - } - return NULL; - } - - param = match_name (param, fcr_regs, regnop); - - return param; -} - -#define hexval(z) \ - (ISDIGIT (z) ? (z) - '0' : \ - ISLOWER (z) ? (z) - 'a' + 10 : \ - ISUPPER (z) ? (z) - 'A' + 10 : (unsigned) -1) - -static char * -getval (char *param, unsigned int *valp) -{ - unsigned int val = 0; - unsigned int c; - - c = *param++; - if (c == '0') - { - c = *param++; - if (c == 'x' || c == 'X') - { - c = *param++; - c = hexval (c); - while (c < 16) - { - val = val * 16 + c; - c = *param++; - c = hexval (c); - } - } - else - { - c -= '0'; - while (c < 8) - { - val = val * 8 + c; - c = *param++ - '0'; - } - } - } - else - { - c -= '0'; - while (c < 10) - { - val = val * 10 + c; - c = *param++ - '0'; - } - } - - *valp = val; - return param - 1; -} - -static char * -get_cnd (char *param, unsigned *valp) -{ - unsigned int val; - - if (ISDIGIT (*param)) - { - param = getval (param, &val); - - if (val >= 32) - { - as_warn (_("Expression truncated to 5 bits")); - val %= 32; - } - } - else - { - param[0] = TOLOWER (param[0]); - param[1] = TOLOWER (param[1]); - - param = match_name (param, cndmsk, valp); - - if (param == NULL) - return NULL; - - val = *valp; - } - - *valp = val << 21; - return param; -} - -static char * -get_reg (char *param, unsigned *regnop, unsigned int reg_prefix) -{ - unsigned c; - unsigned regno; - - c = *param++; - if (c == reg_prefix) - { - regno = *param++ - '0'; - if (regno < 10) - { - if (regno == 0) - { - *regnop = 0; - return param; - } - c = *param - '0'; - if (c < 10) - { - regno = regno * 10 + c; - if (c < 32) - { - *regnop = regno; - return param + 1; - } - } - else - { - *regnop = regno; - return param; - } - } - return NULL; - } - else if (c == 's' && param[0] == 'p') - { - *regnop = 31; - return param + 1; - } - - return 0; -} - -static char * -get_imm16 (char *param, struct m88k_insn *insn) -{ - enum reloc_type reloc = NO_RELOC; - unsigned int val; - char *save_ptr; - - if (!strncmp (param, "hi16", 4) && !ISALNUM (param[4])) - { - reloc = RELOC_HI16; - param += 4; - } - else if (!strncmp (param, "lo16", 4) && !ISALNUM (param[4])) - { - reloc = RELOC_LO16; - param += 4; - } - else if (!strncmp (param, "iw16", 4) && !ISALNUM (param[4])) - { - reloc = RELOC_IW16; - param += 4; - } - - save_ptr = input_line_pointer; - input_line_pointer = param; - expression (&insn->exp); - param = input_line_pointer; - input_line_pointer = save_ptr; - - val = insn->exp.X_add_number; - - if (insn->exp.X_op == O_constant) - { - /* Insert the value now, and reset reloc to NO_RELOC. */ - if (reloc == NO_RELOC) - { - /* Warn about too big expressions if not surrounded by xx16. */ - if (val > 0xffff) - as_warn (_("Expression truncated to 16 bits")); - } - - if (reloc == RELOC_HI16) - val >>= 16; - - insn->opcode |= val & 0xffff; - reloc = NO_RELOC; - } - else if (reloc == NO_RELOC) - /* We accept a symbol even without lo16, hi16, etc, and assume - lo16 was intended. */ - reloc = RELOC_LO16; - - insn->reloc = reloc; - - return param; -} - -static char * -get_pcr (char *param, struct m88k_insn *insn, enum reloc_type reloc) -{ - char *saveptr, *saveparam; - - saveptr = input_line_pointer; - input_line_pointer = param; - - expression (&insn->exp); - - saveparam = input_line_pointer; - input_line_pointer = saveptr; - - /* Botch: We should relocate now if O_constant. */ - insn->reloc = reloc; - - return saveparam; -} - -static char * -get_cmp (char *param, unsigned *valp) -{ - unsigned int val; - char *save_ptr; - - save_ptr = param; - - param = match_name (param, cmpslot, valp); - val = *valp; - - if (param == NULL) - { - param = save_ptr; - - save_ptr = input_line_pointer; - input_line_pointer = param; - val = get_absolute_expression (); - param = input_line_pointer; - input_line_pointer = save_ptr; - - if (val >= 32) - { - as_warn (_("Expression truncated to 5 bits")); - val %= 32; - } - } - - *valp = val << 21; - return param; -} - -static int -calcop (struct m88k_opcode *format, - char *param, - struct m88k_insn *insn) -{ - char *fmt = format->op_spec; - int f; - unsigned val; - unsigned opcode; - unsigned int reg_prefix = 'r'; - - insn->opcode = format->opcode; - opcode = 0; - - for (;;) - { - if (param == 0) - return 0; - f = *fmt++; - switch (f) - { - case 0: - insn->opcode |= opcode; - return (*param == 0 || *param == '\n'); - - default: - if (f != *param++) - return 0; - break; - - case 'd': - param = get_reg (param, &val, reg_prefix); - reg_prefix = 'r'; - opcode |= val << 21; - break; - - case 'o': - param = get_o6 (param, &val); - opcode |= ((val >> 2) << 7); - break; - - case 'x': - reg_prefix = 'x'; - break; - - case '1': - param = get_reg (param, &val, reg_prefix); - reg_prefix = 'r'; - opcode |= val << 16; - break; - - case '2': - param = get_reg (param, &val, reg_prefix); - reg_prefix = 'r'; - opcode |= val; - break; - - case '3': - param = get_reg (param, &val, 'r'); - opcode |= (val << 16) | val; - break; - - case 'I': - param = get_imm16 (param, insn); - break; - - case 'b': - param = get_bf (param, &val); - opcode |= val; - break; - - case 'p': - param = get_pcr (param, insn, RELOC_PC16); - break; - - case 'P': - param = get_pcr (param, insn, RELOC_PC26); - break; - - case 'B': - param = get_cmp (param, &val); - opcode |= val; - break; - - case 'M': - param = get_cnd (param, &val); - opcode |= val; - break; - - case 'c': - param = get_cr (param, &val); - opcode |= val << 5; - break; - - case 'f': - param = get_fcr (param, &val); - opcode |= val << 5; - break; - - case 'V': - param = get_vec9 (param, &val); - opcode |= val; - break; - - case '?': - /* Having this here repeats the warning somtimes. - But can't we stand that? */ - as_warn (_("Use of obsolete instruction")); - break; - } - } -} - -void -md_assemble (char *op) -{ - char *param, *thisfrag; - char c; - struct m88k_opcode *format; - struct m88k_insn insn; - - assert (op); - - /* Skip over instruction to find parameters. */ - for (param = op; *param != 0 && !ISSPACE (*param); param++) - ; - c = *param; - *param++ = '\0'; - - /* Try to find the instruction in the hash table. */ - if ((format = (struct m88k_opcode *) hash_find (op_hash, op)) == NULL) - { - as_bad (_("Invalid mnemonic '%s'"), op); - return; - } - - /* Try parsing this instruction into insn. */ - insn.exp.X_add_symbol = 0; - insn.exp.X_op_symbol = 0; - insn.exp.X_add_number = 0; - insn.exp.X_op = O_illegal; - insn.reloc = NO_RELOC; - - while (!calcop (format, param, &insn)) - { - /* If it doesn't parse try the next instruction. */ - if (!strcmp (format[0].name, format[1].name)) - format++; - else - { - as_fatal (_("Parameter syntax error")); - return; - } - } - - /* Grow the current frag and plop in the opcode. */ - thisfrag = frag_more (4); - md_number_to_chars (thisfrag, insn.opcode, 4); - - /* If this instruction requires labels mark it for later. */ - switch (insn.reloc) - { - case NO_RELOC: - break; - - case RELOC_LO16: - case RELOC_HI16: - fix_new_exp (frag_now, - thisfrag - frag_now->fr_literal + 2, - 2, - &insn.exp, - 0, - insn.reloc); - break; - - case RELOC_IW16: - fix_new_exp (frag_now, - thisfrag - frag_now->fr_literal, - 4, - &insn.exp, - 0, - insn.reloc); - break; - - case RELOC_PC16: - fix_new_exp (frag_now, - thisfrag - frag_now->fr_literal + 2, - 2, - &insn.exp, - 1, - insn.reloc); - break; - - case RELOC_PC26: - fix_new_exp (frag_now, - thisfrag - frag_now->fr_literal, - 4, - &insn.exp, - 1, - insn.reloc); - break; - - default: - as_fatal (_("Unknown relocation type")); - break; - } -} - -void -md_number_to_chars (char *buf, valueT val, int nbytes) -{ - number_to_chars_bigendian (buf, val, nbytes); -} - -#define MAX_LITTLENUMS 6 - -/* Turn a string in input_line_pointer into a floating point constant of type - type, and store the appropriate bytes in *litP. The number of LITTLENUMS - emitted is stored in *sizeP . An error message is returned, or NULL on OK. */ - -char * -md_atof (int type, char *litP, int *sizeP) -{ - int prec; - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - char *t; - - switch (type) - { - case 'f': - case 'F': - case 's': - case 'S': - prec = 2; - break; - - case 'd': - case 'D': - case 'r': - case 'R': - prec = 4; - break; - - case 'x': - case 'X': - prec = 6; - break; - - case 'p': - case 'P': - prec = 6; - break; - - default: - *sizeP = 0; - return _("Bad call to MD_ATOF()"); - } - t = atof_ieee (input_line_pointer, type, words); - if (t) - input_line_pointer = t; - - *sizeP = prec * sizeof (LITTLENUM_TYPE); - for (wordP = words; prec--;) - { - md_number_to_chars (litP, (long) (*wordP++), sizeof (LITTLENUM_TYPE)); - litP += sizeof (LITTLENUM_TYPE); - } - return 0; -} - -int md_short_jump_size = 4; - -void -md_create_short_jump (char *ptr, - addressT from_addr ATTRIBUTE_UNUSED, - addressT to_addr ATTRIBUTE_UNUSED, - fragS *frag, - symbolS *to_symbol) -{ - ptr[0] = (char) 0xc0; - ptr[1] = 0x00; - ptr[2] = 0x00; - ptr[3] = 0x00; - fix_new (frag, - ptr - frag->fr_literal, - 4, - to_symbol, - (offsetT) 0, - 0, - RELOC_PC26); /* Botch: Shouldn't this be RELOC_PC16? */ -} - -int md_long_jump_size = 4; - -void -md_create_long_jump (char *ptr, - addressT from_addr ATTRIBUTE_UNUSED, - addressT to_addr ATTRIBUTE_UNUSED, - fragS *frag, - symbolS *to_symbol) -{ - ptr[0] = (char) 0xc0; - ptr[1] = 0x00; - ptr[2] = 0x00; - ptr[3] = 0x00; - fix_new (frag, - ptr - frag->fr_literal, - 4, - to_symbol, - (offsetT) 0, - 0, - RELOC_PC26); -} - -int -md_estimate_size_before_relax (fragS *fragP ATTRIBUTE_UNUSED, - segT segment_type ATTRIBUTE_UNUSED) -{ - as_fatal (_("Relaxation should never occur")); - return -1; -} - -#ifdef M88KCOFF - -/* These functions are needed if we are linking with obj-coffbfd.c. - That file may be replaced by a more BFD oriented version at some - point. If that happens, these functions should be reexamined. - - Ian Lance Taylor, Cygnus Support, 13 July 1993. */ - -/* Given a fixS structure (created by a call to fix_new, above), - return the BFD relocation type to use for it. */ - -short -tc_coff_fix2rtype (fixS *fixp) -{ - switch (fixp->fx_r_type) - { - case RELOC_LO16: - return R_LVRT16; - case RELOC_HI16: - return R_HVRT16; - case RELOC_PC16: - return R_PCR16L; - case RELOC_PC26: - return R_PCR26L; - case RELOC_32: - return R_VRT32; - case RELOC_IW16: - return R_VRT16; - default: - abort (); - } -} - -/* Apply a fixS to the object file. Since COFF does not use addends - in relocs, the addend is actually stored directly in the object - file itself. */ - -void -md_apply_fix (fixS *fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED) -{ - long val = * (long *) valP; - char *buf; - - buf = fixP->fx_frag->fr_literal + fixP->fx_where; - fixP->fx_offset = 0; - - switch (fixP->fx_r_type) - { - case RELOC_IW16: - fixP->fx_offset = val >> 16; - buf[2] = val >> 8; - buf[3] = val; - break; - - case RELOC_LO16: - fixP->fx_offset = val >> 16; - buf[0] = val >> 8; - buf[1] = val; - break; - - case RELOC_HI16: - fixP->fx_offset = val >> 16; - buf[0] = val >> 8; - buf[1] = val; - break; - - case RELOC_PC16: - buf[0] = val >> 10; - buf[1] = val >> 2; - break; - - case RELOC_PC26: - buf[0] |= (val >> 26) & 0x03; - buf[1] = val >> 18; - buf[2] = val >> 10; - buf[3] = val >> 2; - break; - - case RELOC_32: - buf[0] = val >> 24; - buf[1] = val >> 16; - buf[2] = val >> 8; - buf[3] = val; - break; - - default: - abort (); - } - - if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0) - fixP->fx_done = 1; -} - -/* Where a PC relative offset is calculated from. On the m88k they - are calculated from just after the instruction. */ - -long -md_pcrel_from (fixS *fixp) -{ - switch (fixp->fx_r_type) - { - case RELOC_PC16: - return fixp->fx_frag->fr_address + fixp->fx_where - 2; - case RELOC_PC26: - return fixp->fx_frag->fr_address + fixp->fx_where; - default: - abort (); - } -} - -/* Fill in rs_align_code fragments. */ - -void -m88k_handle_align (fragS *fragp) -{ - static const unsigned char nop_pattern[] = { 0xf4, 0x00, 0x58, 0x00 }; - - int bytes; - char *p; - - if (fragp->fr_type != rs_align_code) - return; - - bytes = fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix; - p = fragp->fr_literal + fragp->fr_fix; - - if (bytes & 3) - { - int fix = bytes & 3; - memset (p, 0, fix); - p += fix; - bytes -= fix; - fragp->fr_fix += fix; - } - - memcpy (p, nop_pattern, 4); - fragp->fr_var = 4; -} - -#endif /* M88KCOFF */ - -const pseudo_typeS md_pseudo_table[] = -{ - {"align", s_align_bytes, 4}, - {"def", s_set, 0}, - {"dfloat", float_cons, 'd'}, - {"ffloat", float_cons, 'f'}, - {"half", cons, 2}, - {"bss", s_lcomm, 1}, - {"string", stringer, 0}, - {"word", cons, 4}, - /* Force set to be treated as an instruction. */ - {"set", NULL, 0}, - {".set", s_set, 0}, - {NULL, NULL, 0} -}; diff --git a/gas/config/tc-m88k.h b/gas/config/tc-m88k.h deleted file mode 100644 index 2c2984f..0000000 --- a/gas/config/tc-m88k.h +++ /dev/null @@ -1,109 +0,0 @@ -/* 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 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000, - 2002, 2005 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -#define TC_M88K - -#define TARGET_BYTES_BIG_ENDIAN 1 - -#ifdef M88KCOFF -#define COFF_MAGIC MC88OMAGIC -#define BFD_ARCH bfd_arch_m88k -#define COFF_FLAGS F_AR32W -#endif - -#define NEED_FX_R_TYPE -#define TC_KEEP_FX_OFFSET -#define TC_CONS_RELOC RELOC_32 - -/* Different type of relocation available in the m88k. */ - -enum reloc_type -{ - 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 -}; - -struct reloc_info_m88k -{ - unsigned long int r_address; - unsigned int r_symbolnum:24; - unsigned int r_extern:1; - unsigned int r_pad:3; - enum reloc_type r_type:4; - long int r_addend; -}; - -#define relocation_info reloc_info_m88k - -/* The m88k uses '@' to start local labels. */ -#define LEX_AT (LEX_BEGIN_NAME | LEX_NAME) - -#ifndef BFD_ASSEMBLER -#define LOCAL_LABEL(name) \ - ((name[0] =='@' && (name [1] == 'L' || name [1] == '.')) \ - || (name[0] == 'L' && name[1] == '0' && name[2] == '\001')) -#endif - -/* The m88k uses pseudo-ops with no leading period. */ -#define NO_PSEUDO_DOT 1 - -/* Don't warn on word overflow; it happens on %hi relocs. */ -#undef WARN_SIGNED_OVERFLOW_WORD - -#define md_convert_frag(b,s,f) {as_fatal (_("m88k convert_frag\n"));} - -/* We don't need to do anything special for undefined symbols. */ -#define md_undefined_symbol(s) 0 - -/* We have no special operand handling. */ -#define md_operand(e) - -#ifdef M88KCOFF - -/* Whether a reloc should be output. */ -#define TC_COUNT_RELOC(fixp) ((fixp)->fx_addsy != NULL) - -/* Get the BFD reloc type to use for a gas fixS structure. */ -#define TC_COFF_FIX2RTYPE(fixp) tc_coff_fix2rtype (fixp) - -/* No special hook needed for symbols. */ -#define tc_coff_symbol_emit_hook(s) - -/* Align sections to a four byte boundary. */ -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif -#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) max (section_alignment[(int) (SEG)], 4) - -/* Fill in rs_align_code fragments. */ -extern void m88k_handle_align (fragS *); -#define HANDLE_ALIGN(frag) m88k_handle_align (frag) - -#define MAX_MEM_FOR_RS_ALIGN_CODE (3 + 4) - -#endif /* M88KCOFF */ diff --git a/gas/config/tc-maxq.c b/gas/config/tc-maxq.c index e6987e1..c1a11af 100644 --- a/gas/config/tc-maxq.c +++ b/gas/config/tc-maxq.c @@ -90,7 +90,6 @@ union _maxq20_op typedef union _maxq20_op maxq20_opcode; /* For handling optional L/S in Maxq20. */ -#ifdef BFD_ASSEMBLER /* Exposed For Linker - maps indirectly to the liker relocations. */ #define LONG_PREFIX MAXQ_LONGJUMP /* BFD_RELOC_16 */ @@ -100,16 +99,6 @@ typedef union _maxq20_op maxq20_opcode; #define NO_PREFIX 0 #define EXPLICT_LONG_PREFIX 14 -#else - -#define EXPLICT_LONG_PREFIX 14 -#define LONG_PREFIX 5 -#define SHORT_PREFIX 1 -#define ABSOLUTE_ADDR_FOR_DATA 0 -#define NO_PREFIX 0 - -#endif - /* The main instruction structure containing fields to describe instrn */ typedef struct _maxq20_insn { @@ -229,7 +218,6 @@ md_show_usage (FILE * stream) ")); } -#ifdef BFD_ASSEMBLER unsigned long maxq20_mach (void) { @@ -298,8 +286,6 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp) return rel; } -#endif - /* md_estimate_size_before_relax() Called just before relax() for rs_machine_dependent frags. The MAXQ @@ -464,35 +450,13 @@ maxq20_cons_fix_new (fragS * frag, unsigned int off, unsigned int len, return; } -short -tc_coff_fix2rtype (fixS * fixP) -{ - return fixP->fx_r_type; -} - -int -tc_coff_sizemachdep (fragS *fragP) -{ - if (fragP->fr_next) - return (fragP->fr_next->fr_address - fragP->fr_address); - - return 0; -} - /* GAS will call this for every rs_machine_dependent fragment. The instruction is compleated using the data from the relaxation pass. It may also create any necessary relocations. */ -#ifdef BFD_ASSEMBLER void md_convert_frag (bfd * headers ATTRIBUTE_UNUSED, segT seg ATTRIBUTE_UNUSED, fragS * fragP) -#else -void -md_convert_frag (object_headers * headers ATTRIBUTE_UNUSED, - segT sec ATTRIBUTE_UNUSED, - fragS * fragP) -#endif { char *opcode; offsetT target_address; @@ -619,18 +583,10 @@ md_apply_fix (fixS *fixP, valueT *valT, segT seg ATTRIBUTE_UNUSED) maxq_number_to_chars (p + 1, PFX0, 1); } -#ifdef BFD_ASSEMBLER /* Remember value for tc_gen_reloc. */ fixP->fx_addnumber = *valT; -#endif } - /* This prob can be fixed by defining tc_fix_adjustable. */ -#ifndef BFD_ASSEMBLER - if (fixP->fx_addsy && S_GET_SEGMENT (fixP->fx_addsy)) - segment_info[S_GET_SEGMENT (fixP->fx_addsy)].dot = NULL; -#endif - /* Some fixups generated by GAS which gets resovled before this this func. is called need to be wriiten to the frag as here we are going to go away with the relocations fx_done=1. */ @@ -728,16 +684,6 @@ const pseudo_typeS md_pseudo_table[] = {NULL, 0, 0}, }; -#if defined(BFD_HEADERS) -#ifdef RELSZ -const int md_reloc_size = RELSZ; /* Coff headers. */ -#else -const int md_reloc_size = 12; /* Something else headers. */ -#endif -#else -const int md_reloc_size = 12; /* Not bfdized. */ -#endif - #define SET_PFX_ARG(x) (PFX_INSN[1] = x) @@ -1512,22 +1458,8 @@ maxq20_data (char *op_string) if (symbolP != NULL && S_GET_SEGMENT (symbolP) != now_seg - && S_GET_SEGMENT (symbolP) != -#ifdef BFD_ASSEMBLER - bfd_und_section_ptr -#else - SEG_UNKNOWN -#endif - ) + && S_GET_SEGMENT (symbolP) != bfd_und_section_ptr) { - int val_pfx; - -#ifdef BFD_ASSEMBLER - val_pfx = 0; -#else - val_pfx = (symbolP->sy_value.X_add_number) >> 8; -#endif - /* In case we do not want to always include the prefix instruction and let the loader handle the job or in case of a 8 bit addressing mode, we will just check for val_pfx to be equal to zero and then load the @@ -1535,7 +1467,7 @@ maxq20_data (char *op_string) loaded. */ /* The prefix register will have to be loaded automatically as we have a 16 bit addressing field. */ - pfx_for_imm_val (val_pfx); + pfx_for_imm_val (0); return symbolP; } @@ -1592,23 +1524,14 @@ maxq20_displacement (char *disp_start, char *disp_end) #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT)) if (exp->X_op != O_constant -#ifdef BFD_ASSEMBLER && OUTPUT_FLAVOR == bfd_target_aout_flavour -#endif && exp_seg != absolute_section && exp_seg != text_section && exp_seg != data_section && exp_seg != bss_section && exp_seg != undefined_section -#ifdef BFD_ASSEMBLER - && !bfd_is_com_section (exp_seg) -#endif - ) + && !bfd_is_com_section (exp_seg)) { -#ifdef BFD_ASSEMBLER as_bad (_("unimplemented segment %s in operand"), exp_seg->name); -#else - as_bad (_("unimplemented segment type %d in operand"), exp_seg); -#endif return 0; } #endif diff --git a/gas/config/tc-maxq.h b/gas/config/tc-maxq.h index 0735785..12b7a94 100644 --- a/gas/config/tc-maxq.h +++ b/gas/config/tc-maxq.h @@ -1,6 +1,6 @@ /* tc-maxq.h -- Header file for the asssembler(MAXQ) - Copyright 2004 Free Software Foundation, Inc. + Copyright 2004, 2005 Free Software Foundation, Inc. Contributed by HCL Technologies Pvt. Ltd. @@ -50,10 +50,6 @@ typedef enum _RELOC_ENUM } RELOC_ENUM; -#ifndef NEED_FX_R_TYPE -#define NEED_FX_R_TYPE /* For defining our own rloc type. */ -#endif - #ifndef MAX_STACK #define MAX_STACK 0xf #endif @@ -86,9 +82,6 @@ RELOC_ENUM; /* Locally defined symbol shoudnot be adjusted to section symbol. */ #define tc_fix_adjustable(FIX) 0 -#define TC_COFF_SIZEMACHDEP(frag) tc_coff_sizemachdep (frag) -extern int tc_coff_sizemachdep (fragS * frag); - /* This specifies that the target has been defined as little endian - default. */ #define TARGET_BYTES_BIG_ENDIAN 0 @@ -107,23 +100,6 @@ extern int tc_coff_sizemachdep (fragS * frag); #define TARGET_MACH maxq20_mach () extern unsigned long maxq20_mach (void); -/* COFF format. */ -#ifndef BFD_ASSEMBLER - -/* Defines the magic number we are using for the maxq-coff. defined in coff.h. */ -#define COFF_MAGIC MAXQ20MAGIC -#define BFD_ARCH bfd_arch_maxq - -/* Whether the reloc should be outputted to the file or not. This - is only true if the symbol we are relocating for is not empty. */ -#define TC_COUNT_RELOC(fixp) ((fixp) -> fx_addsy != NULL) - -/* This macro translates between an internal fix and an coff reloc type. */ -#define TC_COFF_FIX2RTYPE(fixP) tc_coff_fix2rtype (fixP) -extern short tc_coff_fix2rtype (struct fix *); - -#endif /* BFD_ASSEMBLER */ - #ifndef LEX_AT /* We define this macro to generate a fixup for a data allocation pseudo-op. */ #define TC_CONS_FIX_NEW(FRAG,OFF,LEN,EXP) maxq20_cons_fix_new (FRAG,OFF,LEN,EXP) diff --git a/gas/config/tc-mcore.c b/gas/config/tc-mcore.c index 0f9ec69..a795a55 100644 --- a/gas/config/tc-mcore.c +++ b/gas/config/tc-mcore.c @@ -49,8 +49,6 @@ const char comment_chars[] = "#/"; const char line_separator_chars[] = ";"; const char line_comment_chars[] = "#/"; -const int md_reloc_size = 8; - static int do_jsri2bsr = 0; /* Change here from 1 by Cruess 19 August 97. */ static int sifilter_mode = 0; diff --git a/gas/config/tc-mcore.h b/gas/config/tc-mcore.h index 12410c8..dc97eb5 100644 --- a/gas/config/tc-mcore.h +++ b/gas/config/tc-mcore.h @@ -23,18 +23,10 @@ #ifndef TC_MCORE #define TC_MCORE 1 -#ifndef BFD_ASSEMBLER - #error MCORE support requires BFD_ASSEMBLER -#endif - #define TARGET_ARCH bfd_arch_mcore /* Used to initialise target_big_endian. */ #define TARGET_BYTES_BIG_ENDIAN 0 -/* Don't write out relocs for pcrel stuff. */ -#define TC_COUNT_RELOC(x) (((x)->fx_addsy || (x)->fx_subsy) && \ - (x)->fx_r_type < BFD_RELOC_MCORE_PCREL_IMM8BY4) - #define IGNORE_NONSTANDARD_ESCAPES #define TC_RELOC_MANGLE(a,b,c) tc_reloc_mangle (a, b, c) @@ -45,15 +37,9 @@ #define LISTING_HEADER "M.CORE GAS Version 2.9.4" #define LISTING_LHS_CONT_LINES 4 -#define NEED_FX_R_TYPE 1 -#define COFF_FLAGS 1 - /* We want local label support. */ #define LOCAL_LABELS_FB 1 -#define TC_COFF_SIZEMACHDEP(frag) tc_coff_sizemachdep (frag) -int tc_coff_sizemachdep (struct frag *); - extern const struct relax_type md_relax_table[]; #define TC_GENERIC_RELAX_TABLE md_relax_table #define md_end md_mcore_end diff --git a/gas/config/tc-mn10200.h b/gas/config/tc-mn10200.h index ba10f49..b4722df 100644 --- a/gas/config/tc-mn10200.h +++ b/gas/config/tc-mn10200.h @@ -1,5 +1,5 @@ /* tc-mn10200.h -- Header file for tc-mn10200.c. - Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc. + Copyright 1996, 1997, 2000, 2001, 2005 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -22,10 +22,6 @@ #define TARGET_BYTES_BIG_ENDIAN 0 -#ifndef BFD_ASSEMBLER - #error MN10200 support requires BFD_ASSEMBLER -#endif - /* The target BFD architecture. */ #define TARGET_ARCH bfd_arch_mn10200 diff --git a/gas/config/tc-mn10300.c b/gas/config/tc-mn10300.c index d9124d8..8849d1c 100644 --- a/gas/config/tc-mn10300.c +++ b/gas/config/tc-mn10300.c @@ -1,5 +1,5 @@ /* tc-mn10300.c -- Assembler code for the Matsushita 10300 - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -2468,11 +2468,10 @@ md_apply_fix (fixP, valP, seg) abort (); /* The value we are passed in *valuep includes the symbol values. - Since we are using BFD_ASSEMBLER, if we are doing this relocation - the code in write.c is going to call bfd_install_relocation, which - is also going to use the symbol value. That means that if the - reloc is fully resolved we want to use *valuep since - bfd_install_relocation is not being used. + If we are doing this relocation the code in write.c is going to + call bfd_install_relocation, which is also going to use the symbol + value. That means that if the reloc is fully resolved we want to + use *valuep since bfd_install_relocation is not being used. However, if the reloc is not fully resolved we do not want to use *valuep, and must use fx_offset instead. However, if the reloc diff --git a/gas/config/tc-mn10300.h b/gas/config/tc-mn10300.h index fc65025..ad41df4 100644 --- a/gas/config/tc-mn10300.h +++ b/gas/config/tc-mn10300.h @@ -1,5 +1,5 @@ /* tc-mn10300.h -- Header file for tc-mn10300.c. - Copyright 1996, 1997, 2000, 2001, 2002, 2003, 2004 + Copyright 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -23,10 +23,6 @@ #define TARGET_BYTES_BIG_ENDIAN 0 -#ifndef BFD_ASSEMBLER - #error MN10300 support requires BFD_ASSEMBLER -#endif - #define DIFF_EXPR_OK #define GLOBAL_OFFSET_TABLE_NAME "_GLOBAL_OFFSET_TABLE_" diff --git a/gas/config/tc-ms1.h b/gas/config/tc-ms1.h index bc2b3f1..ebf9533 100644 --- a/gas/config/tc-ms1.h +++ b/gas/config/tc-ms1.h @@ -20,11 +20,6 @@ #define TC_MS1 -#ifndef BFD_ASSEMBLER -/* Leading space so will compile with cc. */ - #error MS1 support requires BFD_ASSEMBLER -#endif - #define LISTING_HEADER "MS1 GAS " /* The target BFD architecture. */ diff --git a/gas/config/tc-msp430.c b/gas/config/tc-msp430.c index 9e5c533..5b6e196 100644 --- a/gas/config/tc-msp430.c +++ b/gas/config/tc-msp430.c @@ -1964,12 +1964,11 @@ md_apply_fix (fixS * fixp, valueT * valuep, segT seg) } } -/* A `BFD_ASSEMBLER' GAS will call this to generate a reloc. GAS - will pass the resulting reloc to `bfd_install_relocation'. This - currently works poorly, as `bfd_install_relocation' often does the - wrong thing, and instances of `tc_gen_reloc' have been written to - work around the problems, which in turns makes it difficult to fix - `bfd_install_relocation'. */ +/* GAS will call this to generate a reloc, passing the resulting reloc + to `bfd_install_relocation'. This currently works poorly, as + `bfd_install_relocation' often does the wrong thing, and instances of + `tc_gen_reloc' have been written to work around the problems, which + in turns makes it difficult to fix `bfd_install_relocation'. */ /* If while processing a fixup, a reloc really needs to be created then it is done here. */ diff --git a/gas/config/tc-msp430.h b/gas/config/tc-msp430.h index e0ca859..632e2a9 100644 --- a/gas/config/tc-msp430.h +++ b/gas/config/tc-msp430.h @@ -1,5 +1,5 @@ /* This file is tc-msp430.h - Copyright (C) 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. Contributed by Dmitry Diky <diwil@mail.ru> @@ -20,10 +20,6 @@ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef BFD_ASSEMBLER - #error MSP430 support requires BFD_ASSEMBLER -#endif - #define TC_MSP430 /* By convention, you should define this macro in the `.h' file. For example, `tc-m68k.h' defines `TC_M68K'. You might have to use this diff --git a/gas/config/tc-ns32k.c b/gas/config/tc-ns32k.c index 1b35fb6..1a8c3cb 100644 --- a/gas/config/tc-ns32k.c +++ b/gas/config/tc-ns32k.c @@ -1243,7 +1243,6 @@ parse (const char *line, int recursive_level) return recursive_level; } -#ifdef BFD_ASSEMBLER /* This functionality should really be in the bfd library. */ static bfd_reloc_code_real_type @@ -1307,7 +1306,6 @@ reloc (int size, int pcrel, int type) return BFD_RELOC_NONE; } -#endif static void fix_new_ns32k (fragS *frag, /* Which frag? */ @@ -1327,11 +1325,7 @@ fix_new_ns32k (fragS *frag, /* Which frag? */ { fixS *fixP = fix_new (frag, where, size, add_symbol, offset, pcrel, -#ifdef BFD_ASSEMBLER bit_fixP ? NO_RELOC : reloc (size, pcrel, im_disp) -#else - NO_RELOC -#endif ); fix_opcode_frag (fixP) = opcode_frag; @@ -1359,11 +1353,7 @@ fix_new_ns32k_exp (fragS *frag, /* Which frag? */ unsigned int opcode_offset) { fixS *fixP = fix_new_exp (frag, where, size, exp, pcrel, -#ifdef BFD_ASSEMBLER bit_fixP ? NO_RELOC : reloc (size, pcrel, im_disp) -#else - NO_RELOC -#endif ); fix_opcode_frag (fixP) = opcode_frag; @@ -2047,17 +2037,10 @@ md_apply_fix (fixS *fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED) /* Convert a relaxed displacement to ditto in final output. */ -#ifndef BFD_ASSEMBLER -void -md_convert_frag (object_headers *headers, - segT sec, - fragS *fragP) -#else void md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT sec ATTRIBUTE_UNUSED, fragS *fragP) -#endif { long disp; long ext = 0; @@ -2137,7 +2120,6 @@ md_estimate_size_before_relax (fragS *fragP, segT segment) int md_short_jump_size = 3; int md_long_jump_size = 5; -const int md_reloc_size = 8; /* Size of relocation record. */ void md_create_short_jump (char *ptr, @@ -2275,8 +2257,6 @@ md_pcrel_from (fixS *fixP) return res; } -#ifdef BFD_ASSEMBLER - arelent * tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp) { @@ -2308,39 +2288,3 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp) return rel; } -#else /* BFD_ASSEMBLER */ - -#ifdef OBJ_AOUT -void -cons_fix_new_ns32k (char *where, - struct fix *fixP, - relax_addressT segment_address_in_file) -{ - /* In: Length of relocation (or of address) in chars: 1, 2 or 4. - Out: GNU LD relocation length code: 0, 1, or 2. */ - - static unsigned char nbytes_r_length[] = { 42, 0, 1, 42, 2 }; - long r_symbolnum; - - know (fixP->fx_addsy != NULL); - - md_number_to_chars (where, - fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file, - 4); - - r_symbolnum = (S_IS_DEFINED (fixP->fx_addsy) - ? S_GET_TYPE (fixP->fx_addsy) - : fixP->fx_addsy->sy_number); - - md_number_to_chars (where + 4, - ((long) (r_symbolnum) - | (long) (fixP->fx_pcrel << 24) - | (long) (nbytes_r_length[fixP->fx_size] << 25) - | (long) ((!S_IS_DEFINED (fixP->fx_addsy)) << 27) - | (long) (fix_bsr (fixP) << 28) - | (long) (fix_im_disp (fixP) << 29)), - 4); -} - -#endif /* OBJ_AOUT */ -#endif /* BFD_ASSEMBLER */ diff --git a/gas/config/tc-ns32k.h b/gas/config/tc-ns32k.h index 30f7cc1..1504966 100644 --- a/gas/config/tc-ns32k.h +++ b/gas/config/tc-ns32k.h @@ -26,7 +26,6 @@ #define TC_PCREL_ADJUST(F) md_pcrel_adjust(F) extern int md_pcrel_adjust (fragS *); -#ifdef BFD_ASSEMBLER #define NO_RELOC BFD_RELOC_NONE #define TARGET_ARCH bfd_arch_ns32k @@ -34,18 +33,11 @@ extern int md_pcrel_adjust (fragS *); #ifndef TARGET_FORMAT /* Maybe defined in te-*.h. */ #define TARGET_FORMAT "a.out-pc532-mach" #endif -#else -#define NO_RELOC 0 -#endif #define LOCAL_LABELS_FB 1 #include "bit_fix.h" -#define tc_aout_pre_write_hook(x) {;} /* not used */ -#define tc_crawl_symbol_chain(a) {;} /* not used */ -#define tc_headers_hook(a) {;} /* not used */ - #ifdef SEQUENT_COMPATABILITY #define DEF_MODEC 20 #define DEF_MODEL 21 diff --git a/gas/config/tc-openrisc.h b/gas/config/tc-openrisc.h index 22d2be8..0c14da2 100644 --- a/gas/config/tc-openrisc.h +++ b/gas/config/tc-openrisc.h @@ -20,11 +20,6 @@ #define TC_OPENRISC -#ifndef BFD_ASSEMBLER -/* leading space so will compile with cc */ -# error OPENRISC support requires BFD_ASSEMBLER -#endif - #define LISTING_HEADER "OpenRISC GAS " /* The target BFD architecture. */ diff --git a/gas/config/tc-or32.c b/gas/config/tc-or32.c index f8790db..3099e9f 100644 --- a/gas/config/tc-or32.c +++ b/gas/config/tc-or32.c @@ -26,10 +26,7 @@ #include "safe-ctype.h" #include "as.h" #include "opcode/or32.h" - -#ifdef BFD_ASSEMBLER #include "elf/or32.h" -#endif #define DEBUG 0 @@ -74,16 +71,6 @@ const pseudo_typeS md_pseudo_table[] = int md_short_jump_size = 4; int md_long_jump_size = 4; -#if defined(BFD_HEADERS) -#ifdef RELSZ -const int md_reloc_size = RELSZ; /* Coff headers. */ -#else -const int md_reloc_size = 12; /* Something else headers. */ -#endif -#else -const int md_reloc_size = 12; /* Not bfdized. */ -#endif - /* This array holds the chars that always start a comment. If the pre-processor is disabled, these aren't very useful. */ const char comment_chars[] = "#"; @@ -254,11 +241,7 @@ md_assemble (char *str) md_number_to_chars (toP, the_insn.opcode, 4); /* Put out the symbol-dependent stuff. */ -#ifdef BFD_ASSEMBLER if (the_insn.reloc != BFD_RELOC_NONE) -#else - if (the_insn.reloc != NO_RELOC) -#endif { fix_new_exp (frag_now, (toP - frag_now->fr_literal + the_insn.reloc_offset), @@ -274,7 +257,6 @@ static int waiting_for_shift = 0; static int mask_or_shift = 0; -#ifdef BFD_ASSEMBLER static char * parse_operand (char *s, expressionS *operandp, int opt) { @@ -338,83 +320,11 @@ parse_operand (char *s, expressionS *operandp, int opt) return new; } -#else - -static char * -parse_operand (char *s, expressionS *operandp, int opt) -{ - char *save = input_line_pointer; - char *new; - -#if DEBUG - printf (" PROCESS NEW OPERAND(%s) == %c (%d)\n", s, opt ? opt : '!', opt); -#endif - - input_line_pointer = s; - - if (strncasecmp (s, "HI(", 3) == 0) - { - waiting_for_shift = 1; - mask_or_shift = RELOC_CONSTH; - - input_line_pointer += 3; - } - else if (strncasecmp (s, "LO(", 3) == 0) - { - mask_or_shift = RELOC_CONST; - - input_line_pointer += 3; - } - else - mask_or_shift = 0; - - expression (operandp); - - if (operandp->X_op == O_absent) - { - if (! opt) - as_bad (_("missing operand")); - else - { - operandp->X_add_number = 0; - operandp->X_op = O_constant; - } - } - - new = input_line_pointer; - input_line_pointer = save; - - if ((operandp->X_op == O_symbol) && (*s != '_')) - { -#if DEBUG - printf ("symbol: '%s'\n", save); -#endif - - for (save = s; s < new; s++) - if ((*s == REGISTER_PREFIX) && (*(s + 1) == 'r')) /* Register prefix. */ - s++; - - if ((*s == 'r') && ISDIGIT (*(s + 1))) - { - operandp->X_add_number = strtol (s + 1, NULL, 10); - operandp->X_op = O_register; - } - s = save; - } - -#if DEBUG - printf (" %s=parse_operand(%s): operandp->X_op = %u\n", new, s, operandp->X_op); -#endif - - return new; -} -#endif /* Instruction parsing. Takes a string containing the opcode. Operands are at input_line_pointer. Output is in the_insn. Warnings or errors are generated. */ -#ifdef BFD_ASSEMBLER static void machine_ip (char *str) { @@ -619,214 +529,6 @@ machine_ip (char *str) } } -#else - -static void -machine_ip (char *str) -{ - char *s; - const char *args; - const struct machine_opcode *insn; - char *argsStart; - unsigned long opcode; - expressionS the_operand; - expressionS *operand = &the_operand; - unsigned int regno; - int reloc = NO_RELOC; - -#if DEBUG - printf ("machine_ip(%s)\n", str); -#endif - - s = str; - for (; ISALNUM (*s) || *s == '.'; ++s) - if (ISUPPER (*s)) - *s = TOLOWER (*s); - - switch (*s) - { - case '\0': - break; - - case ' ': /* FIXME-SOMEDAY more whitespace. */ - *s++ = '\0'; - break; - - default: - as_bad (_("unknown opcode1: `%s'"), str); - return; - } - - if ((insn = (struct machine_opcode *) hash_find (op_hash, str)) == NULL) - { - as_bad (_("unknown opcode2 `%s'."), str); - return; - } - - argsStart = s; - opcode = 0; - memset (&the_insn, '\0', sizeof (the_insn)); - the_insn.reloc = NO_RELOC; - - reloc = NO_RELOC; - - /* Build the opcode, checking as we go to make sure that the - operands match. - - If an operand matches, we modify the_insn or opcode appropriately, - and do a "continue". If an operand fails to match, we "break". */ - if (insn->args[0] != '\0') - /* Prime the pump. */ - s = parse_operand (s, operand, - insn->args[0] == 'I' - || strcmp (insn->name, "l.nop") == 0); - - for (args = insn->args;; ++args) - { -#if DEBUG - printf (" args = %s\n", args); -#endif - switch (*args) - { - case '\0': /* End of args. */ - /* We have have 0 args, do the bazoooka! */ - if (args == insn->args) - encode (insn, &opcode, 0, 0); - - if (*s == '\0') - { - /* We are truly done. */ - the_insn.opcode = opcode; - if (check_invalid_opcode (opcode)) - as_bad (_("instruction not allowed: %s"), str); - return; - } - as_bad (_("too many operands: %s"), s); - break; - - case ',': /* Must match a comma. */ - if (*s++ == ',') - { - reloc = NO_RELOC; - - /* Parse next operand. */ - s = parse_operand (s, operand, args[1] == 'I'); -#if DEBUG - printf (" ',' case: operand->X_add_number = %d, *args = %s, *s = %s\n", - operand->X_add_number, args, s); -#endif - continue; - } - break; - - case '(': /* Must match a (. */ - s = parse_operand (s, operand, args[1] == 'I'); - continue; - - case ')': /* Must match a ). */ - continue; - - case 'r': /* A general register. */ - args++; - - if (operand->X_op != O_register) - break; /* Only registers. */ - - know (operand->X_add_symbol == 0); - know (operand->X_op_symbol == 0); - regno = operand->X_add_number; - encode (insn, &opcode, regno, *args); -#if DEBUG - printf (" r: operand->X_op = %d\n", operand->X_op); -#endif - continue; - - default: - /* if (! ISALPHA (*args)) - break; */ /* Only immediate values. */ - - if (mask_or_shift) - { -#if DEBUG - printf ("mask_or_shift = %d\n", mask_or_shift); -#endif - reloc = mask_or_shift; - } - mask_or_shift = 0; - - if (strncasecmp (args, "LO(", 3) == 0) - { -#if DEBUG - printf ("reloc_const\n"); -#endif - reloc = RELOC_CONST; - } - else if (strncasecmp (args, "HI(", 3) == 0) - { -#if DEBUG - printf ("reloc_consth\n"); -#endif - reloc = RELOC_CONSTH; - } - - if (*s == '(') - operand->X_op = O_constant; - else if (*s == ')') - s += 1; -#if DEBUG - printf (" default case: operand->X_add_number = %d, *args = %s, *s = %s\n", - operand->X_add_number, args, s); -#endif - if (operand->X_op == O_constant) - { - if (reloc == NO_RELOC) - { - unsigned long v, mask; - - mask = 0x3ffffff; - v = abs (operand->X_add_number) & ~ mask; - if (v) - as_bad (_("call/jmp target out of range (1)")); - } - - if (reloc == RELOC_CONSTH) - operand->X_add_number = ((operand->X_add_number>>16) & 0xffff); - - the_insn.pcrel = 0; - encode (insn, &opcode, operand->X_add_number, *args); - /* the_insn.reloc = NO_RELOC; */ - continue; - } - - if (reloc == NO_RELOC) - the_insn.reloc = RELOC_JUMPTARG; - else - the_insn.reloc = reloc; -#if DEBUG - printf (" reloc sym=%d\n", the_insn.reloc); - printf (" NO_RELOC=%d\n", NO_RELOC); -#endif - the_insn.exp = *operand; - - /* the_insn.reloc_offset = 1; */ - the_insn.pcrel = 1; /* Assume PC-relative jump. */ - - /* FIXME-SOON, Do we figure out whether abs later, after - know sym val? */ - if (reloc == RELOC_CONST || reloc == RELOC_CONSTH) - the_insn.pcrel = 0; - - encode (insn, &opcode, operand->X_add_number, *args); - continue; - } - - /* Types or values of args don't match. */ - as_bad (_("invalid operands")); - return; - } -} -#endif - /* This is identical to the md_atof in m68k.c. I think this is right, but I'm not sure. @@ -900,7 +602,6 @@ md_number_to_chars (char *buf, valueT val, int n) number_to_chars_bigendian (buf, val, n); } -#ifdef BFD_ASSEMBLER void md_apply_fix (fixS * fixP, valueT * val, segT seg ATTRIBUTE_UNUSED) { @@ -996,153 +697,6 @@ md_apply_fix (fixS * fixP, valueT * val, segT seg ATTRIBUTE_UNUSED) if (fixP->fx_addsy == (symbolS *) NULL) fixP->fx_done = 1; } -#else -void -md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) -{ - long val = *valP; - char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; - -#if DEBUG - printf ("md_apply_fix val:%x\n", val); -#endif - - fixP->fx_addnumber = val; /* Remember value for emit_reloc. */ - - know (fixP->fx_size == 4); - know (fixP->fx_r_type < NO_RELOC); - - /* This is a hack. There should be a better way to handle this. */ - if (fixP->fx_r_type == RELOC_WDISP30 && fixP->fx_addsy) - val += fixP->fx_where + fixP->fx_frag->fr_address; - - switch (fixP->fx_r_type) - { - case RELOC_32: - buf[0] = val >> 24; - buf[1] = val >> 16; - buf[2] = val >> 8; - buf[3] = val; - break; - - case RELOC_8: - buf[0] = val; - break; - - case RELOC_WDISP30: - val = (val >> 2) + 1; - buf[0] |= (val >> 24) & 0x3f; - buf[1] = (val >> 16); - buf[2] = val >> 8; - buf[3] = val; - break; - - case RELOC_HI22: - buf[1] |= (val >> 26) & 0x3f; - buf[2] = val >> 18; - buf[3] = val >> 10; - break; - - case RELOC_LO10: - buf[2] |= (val >> 8) & 0x03; - buf[3] = val; - break; - - case RELOC_BASE13: - buf[2] |= (val >> 8) & 0x1f; - buf[3] = val; - break; - - case RELOC_WDISP22: - val = (val >> 2) + 1; - /* FALLTHROUGH */ - case RELOC_BASE22: - buf[1] |= (val >> 16) & 0x3f; - buf[2] = val >> 8; - buf[3] = val; - break; - - case RELOC_JUMPTARG: /* 0000XXXX pattern in a word. */ - if (!fixP->fx_done) - { - /* The linker tries to support both AMD and old GNU style - R_IREL relocs. That means that if the addend is exactly - the negative of the address within the section, the - linker will not handle it correctly. */ - } - else if (fixP->fx_pcrel) - { - long v = val >> 28; - if (v != 0 && v != -1) - as_bad_where (fixP->fx_file, fixP->fx_line, - _("call/jmp target out of range (2)")); - } - else - /* This case was supposed to be handled in machine_ip. */ - abort (); - - buf[0] |= (val >> 26) & 0x03; /* Holds bits 0FFFFFFC of address. */ - buf[1] = val >> 18; - buf[2] = val >> 10; - buf[3] = val >> 2; - break; - - case RELOC_CONST: /* 0000XXXX pattern in a word. */ -#if DEBUG - printf ("reloc_const: val=%x\n", val); -#endif - buf[2] = val >> 8; /* Holds bits 0000XXXX. */ - buf[3] = val; - break; - - case RELOC_CONSTH: /* 0000XXXX pattern in a word. */ -#if DEBUG - printf ("reloc_consth: val=%x\n", val); -#endif - buf[2] = val >> 24; /* Holds bits XXXX0000. */ - buf[3] = val >> 16; - break; - - case BFD_RELOC_VTABLE_INHERIT: - case BFD_RELOC_VTABLE_ENTRY: - fixP->fx_done = 0; - break; - - case NO_RELOC: - default: - as_bad (_("bad relocation type: 0x%02x"), fixP->fx_r_type); - break; - } - - if (fixP->fx_addsy == (symbolS *) NULL) - fixP->fx_done = 1; -} -#endif - -#ifdef OBJ_COFF -short -tc_coff_fix2rtype (fixS *fixP) -{ -#if DEBUG - printf ("tc_coff_fix2rtype\n"); -#endif - - switch (fixP->fx_r_type) - { - case RELOC_32: return R_WORD; - case RELOC_8: return R_BYTE; - case RELOC_CONST: return R_ILOHALF; - case RELOC_CONSTH: return R_IHIHALF; - case RELOC_JUMPTARG: return R_IREL; - default: - printf ("need %d\n", fixP->fx_r_type); - abort (); - } - - return 0; -} - -#endif /* OBJ_COFF */ /* Should never be called for or32. */ @@ -1158,16 +712,6 @@ md_create_short_jump (char * ptr ATTRIBUTE_UNUSED, /* Should never be called for or32. */ -#ifndef BFD_ASSEMBLER -void -md_convert_frag (object_headers * headers ATTRIBUTE_UNUSED, - segT seg ATTRIBUTE_UNUSED, - register fragS * fragP ATTRIBUTE_UNUSED) -{ - as_fatal ("or32_convert_frag\n"); -} - -#else void md_convert_frag (bfd * headers ATTRIBUTE_UNUSED, segT seg ATTRIBUTE_UNUSED, @@ -1175,7 +719,6 @@ md_convert_frag (bfd * headers ATTRIBUTE_UNUSED, { as_fatal ("or32_convert_frag\n"); } -#endif /* Should never be called for or32. */ @@ -1307,34 +850,6 @@ or32_unrecognized_line (int c) symbolS * md_undefined_symbol (char *name ATTRIBUTE_UNUSED) { -#ifndef BFD_ASSEMBLER - long regnum; - char testbuf[5 + /*SLOP*/ 5]; - -#if DEBUG - printf ("md_undefined_symbol(%s)\n", name); -#endif - - /* Register name. */ - if (name[0] == 'r' || name[0] == 'R' || name[0] == 'a' || name[0] == 'b') - { - /* Parse the number, make sure it has no extra zeroes or - trailing chars. */ - regnum = atol (& name[1]); - - if (regnum > 31) - as_fatal (_("register out of range")); - - sprintf (testbuf, "%ld", regnum); - - if (strcmp (testbuf, &name[1]) != 0) - return NULL; /* gr007 or lr7foo or whatever. */ - - /* We have a wiener! Define and return a new symbol for it. */ - return (symbol_new (name, SEG_REGISTER, (valueT) regnum, - &zero_address_frag)); - } -#endif return NULL; } @@ -1486,7 +1001,6 @@ md_pcrel_from (fixS *fixP) /* Generate a reloc for a fixup. */ -#ifdef BFD_ASSEMBLER arelent * tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp) { @@ -1513,4 +1027,3 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp) reloc->addend = fixp->fx_addnumber; return reloc; } -#endif diff --git a/gas/config/tc-or32.h b/gas/config/tc-or32.h index d2bac3e..b17482d 100644 --- a/gas/config/tc-or32.h +++ b/gas/config/tc-or32.h @@ -40,14 +40,8 @@ extern int or32_unrecognized_line (int); -#define tc_headers_hook(a) ; /* Not used. */ -#define tc_headers_hook(a) ; /* Not used. */ -#define tc_crawl_symbol_chain(a) ; /* Not used. */ #define tc_coff_symbol_emit_hook(a) ; /* Not used. */ -#define AOUT_MACHTYPE 80 -#define TC_COFF_FIX2RTYPE(fix_ptr) tc_coff_fix2rtype (fix_ptr) -#define BFD_ARCH bfd_arch_or32 #define COFF_MAGIC SIPFBOMAGIC /* No shared lib support, so we don't need to ensure externally @@ -59,13 +53,4 @@ extern int or32_unrecognized_line (int); #define MD_APPLY_SYM_VALUE(FIX) 0 #endif -/* Should the reloc be output ? - on the 29k, this is true only if there is a symbol attached. - on the h8, this is always true, since no fixup is done. */ -#define TC_COUNT_RELOC(x) (x->fx_addsy) -#define TC_CONS_RELOC RELOC_32 - -#define COFF_FLAGS F_AR32W -#define NEED_FX_R_TYPE - #define ZERO_BASED_SEGMENTS diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c index b0c136c..cea7f21 100644 --- a/gas/config/tc-ppc.c +++ b/gas/config/tc-ppc.c @@ -5532,11 +5532,11 @@ md_apply_fix (fixP, valP, seg) fixP->fx_done = 1; #else /* FIXME FIXME FIXME: The value we are passed in *valP includes - the symbol values. Since we are using BFD_ASSEMBLER, if we are - doing this relocation the code in write.c is going to call - bfd_install_relocation, which is also going to use the symbol - value. That means that if the reloc is fully resolved we want to - use *valP since bfd_install_relocation is not being used. + the symbol values. If we are doing this relocation the code in + write.c is going to call bfd_install_relocation, which is also + going to use the symbol value. That means that if the reloc is + fully resolved we want to use *valP since bfd_install_relocation is + not being used. However, if the reloc is not fully resolved we do not want to use *valP, and must use fx_offset instead. However, if the reloc is PC relative, we do want to use *valP since it includes the diff --git a/gas/config/tc-ppc.h b/gas/config/tc-ppc.h index 0e85bba..7b6126a 100644 --- a/gas/config/tc-ppc.h +++ b/gas/config/tc-ppc.h @@ -29,10 +29,6 @@ struct fix; #define TARGET_BYTES_BIG_ENDIAN 1 #endif -#ifndef BFD_ASSEMBLER - #error PowerPC support requires BFD_ASSEMBLER -#endif - /* If OBJ_COFF is defined, and TE_PE is not defined, we are assembling XCOFF for AIX or PowerMac. If TE_PE is defined, we are assembling COFF for Windows NT. */ diff --git a/gas/config/tc-s390.h b/gas/config/tc-s390.h index 8a22e53..dbecfef 100644 --- a/gas/config/tc-s390.h +++ b/gas/config/tc-s390.h @@ -1,5 +1,6 @@ /* tc-s390.h -- Header file for tc-s390.c. - Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright 2000, 2001, 2002, 2003, 2004, 2005 + Free Software Foundation, Inc. Written by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of GAS, the GNU Assembler. @@ -23,10 +24,6 @@ struct fix; -#ifndef BFD_ASSEMBLER - #error S390 support requires BFD_ASSEMBLER -#endif - #define TC_FORCE_RELOCATION(FIX) tc_s390_force_relocation(FIX) extern int tc_s390_force_relocation PARAMS ((struct fix *)); diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c index b8248a1..27ccdee 100644 --- a/gas/config/tc-sh.c +++ b/gas/config/tc-sh.c @@ -124,8 +124,6 @@ const pseudo_typeS md_pseudo_table[] = {0, 0, 0} }; -/*int md_reloc_size; */ - int sh_relax; /* set if -relax seen */ /* Whether -small was seen. */ @@ -2871,9 +2869,7 @@ md_assemble (char *str) } } -#ifdef BFD_ASSEMBLER dwarf2_emit_insn (size); -#endif } /* This routine is called each time a label definition is seen. It @@ -2922,24 +2918,6 @@ md_undefined_symbol (char *name ATTRIBUTE_UNUSED) return 0; } -#ifdef OBJ_COFF -#ifndef BFD_ASSEMBLER - -void -tc_crawl_symbol_chain (object_headers *headers ATTRIBUTE_UNUSED) -{ - printf (_("call to tc_crawl_symbol_chain \n")); -} - -void -tc_headers_hook (object_headers *headers ATTRIBUTE_UNUSED) -{ - printf (_("call to tc_headers_hook \n")); -} - -#endif -#endif - /* Various routines to kill one day. */ /* Equal to MAX_PRECISION in atof-ieee.c. */ #define MAX_LITTLENUMS 6 @@ -3245,8 +3223,7 @@ struct sh_count_relocs }; /* Count the number of fixups in a section which refer to a particular - symbol. When using BFD_ASSEMBLER, this is called via - bfd_map_over_sections. */ + symbol. This is called via bfd_map_over_sections. */ static void sh_count_relocs (bfd *abfd ATTRIBUTE_UNUSED, segT sec, void *data) @@ -3271,8 +3248,8 @@ sh_count_relocs (bfd *abfd ATTRIBUTE_UNUSED, segT sec, void *data) } } -/* Handle the count relocs for a particular section. When using - BFD_ASSEMBLER, this is called via bfd_map_over_sections. */ +/* Handle the count relocs for a particular section. + This is called via bfd_map_over_sections. */ static void sh_frob_section (bfd *abfd ATTRIBUTE_UNUSED, segT sec, @@ -3302,9 +3279,6 @@ sh_frob_section (bfd *abfd ATTRIBUTE_UNUSED, segT sec, || fix->fx_subsy != NULL || fix->fx_addnumber != 0 || S_GET_SEGMENT (sym) != sec -#if ! defined (BFD_ASSEMBLER) && defined (OBJ_COFF) - || S_GET_STORAGE_CLASS (sym) == C_EXT -#endif || S_IS_EXTERNAL (sym)) { as_warn_where (fix->fx_file, fix->fx_line, @@ -3344,9 +3318,6 @@ sh_frob_section (bfd *abfd ATTRIBUTE_UNUSED, segT sec, || fscan->fx_subsy != NULL || fscan->fx_addnumber != 0 || S_GET_SEGMENT (sym) != sec -#if ! defined (BFD_ASSEMBLER) && defined (OBJ_COFF) - || S_GET_STORAGE_CLASS (sym) == C_EXT -#endif || S_IS_EXTERNAL (sym)) { as_warn_where (fix->fx_file, fix->fx_line, @@ -3358,16 +3329,7 @@ sh_frob_section (bfd *abfd ATTRIBUTE_UNUSED, segT sec, counting the number of times we find a reference to sym. */ info.sym = sym; info.count = 0; -#ifdef BFD_ASSEMBLER bfd_map_over_sections (stdoutput, sh_count_relocs, &info); -#else - { - int iscan; - - for (iscan = SEG_E0; iscan < SEG_UNKNOWN; iscan++) - sh_count_relocs ((bfd *) NULL, iscan, &info); - } -#endif if (info.count < 1) abort (); @@ -3402,28 +3364,14 @@ sh_frob_file (void) if (! sh_relax) return; -#ifdef BFD_ASSEMBLER bfd_map_over_sections (stdoutput, sh_frob_section, NULL); -#else - { - int iseg; - - for (iseg = SEG_E0; iseg < SEG_UNKNOWN; iseg++) - sh_frob_section ((bfd *) NULL, iseg, NULL); - } -#endif } /* Called after relaxing. Set the correct sizes of the fragments, and create relocs so that md_apply_fix will fill in the correct values. */ void -#ifdef BFD_ASSEMBLER md_convert_frag (bfd *headers ATTRIBUTE_UNUSED, segT seg, fragS *fragP) -#else -md_convert_frag (object_headers *headers ATTRIBUTE_UNUSED, segT seg, - fragS *fragP) -#endif { int donerelax = 0; @@ -3496,12 +3444,7 @@ md_convert_frag (object_headers *headers ATTRIBUTE_UNUSED, segT seg, /* Build a relocation to six / four bytes farther on. */ subseg_change (seg, 0); - fix_new (fragP, fragP->fr_fix, 2, -#ifdef BFD_ASSEMBLER - section_symbol (seg), -#else - seg_info (seg)->dot, -#endif + fix_new (fragP, fragP->fr_fix, 2, section_symbol (seg), fragP->fr_address + fragP->fr_fix + (delay ? 4 : 6), 1, BFD_RELOC_SH_PCDISP8BY2); @@ -3568,17 +3511,12 @@ md_convert_frag (object_headers *headers ATTRIBUTE_UNUSED, segT seg, valueT md_section_align (segT seg ATTRIBUTE_UNUSED, valueT size) { -#ifdef BFD_ASSEMBLER #ifdef OBJ_ELF return size; #else /* ! OBJ_ELF */ return ((size + (1 << bfd_get_section_alignment (stdoutput, seg)) - 1) & (-1 << bfd_get_section_alignment (stdoutput, seg))); #endif /* ! OBJ_ELF */ -#else /* ! BFD_ASSEMBLER */ - return ((size + (1 << section_alignment[(int) seg]) - 1) - & (-1 << section_alignment[(int) seg])); -#endif /* ! BFD_ASSEMBLER */ } /* This static variable is set by s_uacons to tell sh_cons_align that @@ -3803,7 +3741,6 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) long max, min; int shift; -#ifdef BFD_ASSEMBLER /* A difference between two symbols, the second of which is in the current section, is transformed in a PC-relative relocation to the other symbol. We have to adjust the relocation type here. */ @@ -3849,24 +3786,9 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) && fixP->fx_addsy != NULL && S_IS_WEAK (fixP->fx_addsy)) val -= S_GET_VALUE (fixP->fx_addsy); -#endif -#ifdef BFD_ASSEMBLER if (SWITCH_TABLE (fixP)) val -= S_GET_VALUE (fixP->fx_subsy); -#else - if (fixP->fx_r_type == 0) - { - if (fixP->fx_size == 2) - fixP->fx_r_type = BFD_RELOC_16; - else if (fixP->fx_size == 4) - fixP->fx_r_type = BFD_RELOC_32; - else if (fixP->fx_size == 1) - fixP->fx_r_type = BFD_RELOC_8; - else - abort (); - } -#endif max = min = 0; shift = 0; @@ -4207,8 +4129,7 @@ md_number_to_chars (char *ptr, valueT use, int nbytes) number_to_chars_bigendian (ptr, use, nbytes); } -/* This version is used in obj-coff.c when not using BFD_ASSEMBLER. - eg for the sh-hms target. */ +/* This version is used in obj-coff.c eg. for the sh-hms target. */ long md_pcrel_from (fixS *fixP) @@ -4234,167 +4155,6 @@ md_pcrel_from_section (fixS *fixP, segT sec) return md_pcrel_from (fixP); } -#ifdef OBJ_COFF - -int -tc_coff_sizemachdep (fragS *frag) -{ - return md_relax_table[frag->fr_subtype].rlx_length; -} - -#endif /* OBJ_COFF */ - -#ifndef BFD_ASSEMBLER -#ifdef OBJ_COFF - -/* Map BFD relocs to SH COFF relocs. */ - -struct reloc_map -{ - bfd_reloc_code_real_type bfd_reloc; - int sh_reloc; -}; - -static const struct reloc_map coff_reloc_map[] = -{ - { BFD_RELOC_32, R_SH_IMM32 }, - { BFD_RELOC_16, R_SH_IMM16 }, - { BFD_RELOC_8, R_SH_IMM8 }, - { BFD_RELOC_SH_PCDISP8BY2, R_SH_PCDISP8BY2 }, - { BFD_RELOC_SH_PCDISP12BY2, R_SH_PCDISP }, - { BFD_RELOC_SH_IMM4, R_SH_IMM4 }, - { BFD_RELOC_SH_IMM4BY2, R_SH_IMM4BY2 }, - { BFD_RELOC_SH_IMM4BY4, R_SH_IMM4BY4 }, - { BFD_RELOC_SH_IMM8, R_SH_IMM8 }, - { BFD_RELOC_SH_IMM8BY2, R_SH_IMM8BY2 }, - { BFD_RELOC_SH_IMM8BY4, R_SH_IMM8BY4 }, - { BFD_RELOC_SH_PCRELIMM8BY2, R_SH_PCRELIMM8BY2 }, - { BFD_RELOC_SH_PCRELIMM8BY4, R_SH_PCRELIMM8BY4 }, - { BFD_RELOC_8_PCREL, R_SH_SWITCH8 }, - { BFD_RELOC_SH_SWITCH16, R_SH_SWITCH16 }, - { BFD_RELOC_SH_SWITCH32, R_SH_SWITCH32 }, - { BFD_RELOC_SH_USES, R_SH_USES }, - { BFD_RELOC_SH_COUNT, R_SH_COUNT }, - { BFD_RELOC_SH_ALIGN, R_SH_ALIGN }, - { BFD_RELOC_SH_CODE, R_SH_CODE }, - { BFD_RELOC_SH_DATA, R_SH_DATA }, - { BFD_RELOC_SH_LABEL, R_SH_LABEL }, - { BFD_RELOC_UNUSED, 0 } -}; - -/* Adjust a reloc for the SH. This is similar to the generic code, - but does some minor tweaking. */ - -void -sh_coff_reloc_mangle (segment_info_type *seg, fixS *fix, - struct internal_reloc *intr, unsigned int paddr) -{ - symbolS *symbol_ptr = fix->fx_addsy; - symbolS *dot; - - intr->r_vaddr = paddr + fix->fx_frag->fr_address + fix->fx_where; - - if (! SWITCH_TABLE (fix)) - { - const struct reloc_map *rm; - - for (rm = coff_reloc_map; rm->bfd_reloc != BFD_RELOC_UNUSED; rm++) - if (rm->bfd_reloc == (bfd_reloc_code_real_type) fix->fx_r_type) - break; - if (rm->bfd_reloc == BFD_RELOC_UNUSED) - as_bad_where (fix->fx_file, fix->fx_line, - _("Can not represent %s relocation in this object file format"), - bfd_get_reloc_code_name (fix->fx_r_type)); - intr->r_type = rm->sh_reloc; - intr->r_offset = 0; - } - else - { - know (sh_relax); - - if (fix->fx_r_type == BFD_RELOC_16) - intr->r_type = R_SH_SWITCH16; - else if (fix->fx_r_type == BFD_RELOC_8) - intr->r_type = R_SH_SWITCH8; - else if (fix->fx_r_type == BFD_RELOC_32) - intr->r_type = R_SH_SWITCH32; - else - abort (); - - /* For a switch reloc, we set r_offset to the difference between - the reloc address and the subtrahend. When the linker is - doing relaxing, it can use the determine the starting and - ending points of the switch difference expression. */ - intr->r_offset = intr->r_vaddr - S_GET_VALUE (fix->fx_subsy); - } - - /* PC relative relocs are always against the current section. */ - if (symbol_ptr == NULL) - { - switch (fix->fx_r_type) - { - case BFD_RELOC_SH_PCRELIMM8BY2: - case BFD_RELOC_SH_PCRELIMM8BY4: - case BFD_RELOC_SH_PCDISP8BY2: - case BFD_RELOC_SH_PCDISP12BY2: - case BFD_RELOC_SH_USES: - symbol_ptr = seg->dot; - break; - default: - break; - } - } - - if (fix->fx_r_type == BFD_RELOC_SH_USES) - { - /* We can't store the offset in the object file, since this - reloc does not take up any space, so we store it in r_offset. - The fx_addnumber field was set in md_apply_fix. */ - intr->r_offset = fix->fx_addnumber; - } - else if (fix->fx_r_type == BFD_RELOC_SH_COUNT) - { - /* We can't store the count in the object file, since this reloc - does not take up any space, so we store it in r_offset. The - fx_offset field was set when the fixup was created in - sh_coff_frob_file. */ - intr->r_offset = fix->fx_offset; - /* This reloc is always absolute. */ - symbol_ptr = NULL; - } - else if (fix->fx_r_type == BFD_RELOC_SH_ALIGN) - { - /* Store the alignment in the r_offset field. */ - intr->r_offset = fix->fx_offset; - /* This reloc is always absolute. */ - symbol_ptr = NULL; - } - else if (fix->fx_r_type == BFD_RELOC_SH_CODE - || fix->fx_r_type == BFD_RELOC_SH_DATA - || fix->fx_r_type == BFD_RELOC_SH_LABEL) - { - /* These relocs are always absolute. */ - symbol_ptr = NULL; - } - - /* Turn the segment of the symbol into an offset. */ - if (symbol_ptr != NULL) - { - dot = segment_info[S_GET_SEGMENT (symbol_ptr)].dot; - if (dot != NULL) - intr->r_symndx = dot->sy_number; - else - intr->r_symndx = symbol_ptr->sy_number; - } - else - intr->r_symndx = -1; -} - -#endif /* OBJ_COFF */ -#endif /* ! BFD_ASSEMBLER */ - -#ifdef BFD_ASSEMBLER - /* Create a reloc. */ arelent * @@ -4610,4 +4370,3 @@ sh_regname_to_dw2regnum (const char *regname) return regnum; } #endif /* OBJ_ELF */ -#endif /* BFD_ASSEMBLER */ diff --git a/gas/config/tc-sh.h b/gas/config/tc-sh.h index 4143aef..c533a87 100644 --- a/gas/config/tc-sh.h +++ b/gas/config/tc-sh.h @@ -1,6 +1,6 @@ /* This file is tc-sh.h Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, - 2003, 2004 Free Software Foundation, Inc. + 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -60,16 +60,6 @@ extern int sh_force_relocation (struct fix *); to know about all such entries so that it can adjust them if necessary. */ -#ifdef BFD_ASSEMBLER -#define SWITCH_TABLE_CONS(FIX) (0) -#else -#define SWITCH_TABLE_CONS(FIX) \ - ((FIX)->fx_r_type == 0 \ - && ((FIX)->fx_size == 2 \ - || (FIX)->fx_size == 1 \ - || (FIX)->fx_size == 4)) -#endif - #define SWITCH_TABLE(FIX) \ ((FIX)->fx_addsy != NULL \ && (FIX)->fx_subsy != NULL \ @@ -77,8 +67,7 @@ extern int sh_force_relocation (struct fix *); && S_GET_SEGMENT ((FIX)->fx_subsy) == text_section \ && ((FIX)->fx_r_type == BFD_RELOC_32 \ || (FIX)->fx_r_type == BFD_RELOC_16 \ - || (FIX)->fx_r_type == BFD_RELOC_8 \ - || SWITCH_TABLE_CONS (FIX))) + || (FIX)->fx_r_type == BFD_RELOC_8)) #define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC) \ (! SEG_NORMAL (SEC) \ @@ -122,27 +111,15 @@ extern void sh_frob_label (void); extern void sh_flush_pending_output (void); #define md_flush_pending_output() sh_flush_pending_output () -#ifdef BFD_ASSEMBLER #define tc_frob_file_before_adjust sh_frob_file -#else -#define tc_frob_file sh_frob_file -#endif extern void sh_frob_file (void); #ifdef OBJ_COFF /* COFF specific definitions. */ -/* This macro translates between an internal fix and a coff reloc type. */ -#define TC_COFF_FIX2RTYPE(fix) ((fix)->fx_r_type) - -#define BFD_ARCH TARGET_ARCH - #define COFF_MAGIC (!target_big_endian ? SH_ARCH_MAGIC_LITTLE : SH_ARCH_MAGIC_BIG) -/* We need to write out relocs which have not been completed. */ -#define TC_COUNT_RELOC(fix) ((fix)->fx_addsy != NULL) - #define TC_RELOC_MANGLE(seg, fix, int, paddr) \ sh_coff_reloc_mangle ((seg), (fix), (int), (paddr)) extern void sh_coff_reloc_mangle @@ -151,18 +128,9 @@ extern void sh_coff_reloc_mangle #define tc_coff_symbol_emit_hook(a) ; /* not used */ -#define NEED_FX_R_TYPE 1 - #define TC_KEEP_FX_OFFSET 1 -#define TC_COFF_SIZEMACHDEP(frag) tc_coff_sizemachdep(frag) -extern int tc_coff_sizemachdep (fragS *); - -#ifdef BFD_ASSEMBLER #define SEG_NAME(SEG) segment_name (SEG) -#else -#define SEG_NAME(SEG) obj_segment_name (SEG) -#endif /* We align most sections to a 16 byte boundary. */ #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) \ diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c index 60b5dae..1f2b2f9 100644 --- a/gas/config/tc-sparc.c +++ b/gas/config/tc-sparc.c @@ -174,9 +174,6 @@ const pseudo_typeS md_pseudo_table[] = {NULL, 0, 0}, }; -/* Size of relocation record. */ -const int md_reloc_size = 12; - /* This array holds the chars that always start a comment. If the pre-processor is disabled, these aren't very useful. */ const char comment_chars[] = "!"; /* JF removed '|' from @@ -3961,9 +3958,7 @@ s_common (ignore) goto allocate_common; } -#ifdef BFD_ASSEMBLER symbol_get_bfdsym (symbolP)->flags |= BSF_OBJECT; -#endif demand_empty_rest_of_line (); return; diff --git a/gas/config/tc-tahoe.c b/gas/config/tc-tahoe.c deleted file mode 100644 index 6bef4be..0000000 --- a/gas/config/tc-tahoe.c +++ /dev/null @@ -1,1892 +0,0 @@ -/* This file is tc-tahoe.c - - Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1995, 2000, 2001, 2002, - 2003, 2004, 2005 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -#include "as.h" -#include "safe-ctype.h" -#include "obstack.h" - -/* This bit glommed from tahoe-inst.h. */ - -typedef unsigned char byte; -typedef byte tahoe_opcodeT; - -/* This is part of tahoe-ins-parse.c & friends. - We want to parse a tahoe instruction text into a tree defined here. */ - -#define TIT_MAX_OPERANDS 4 /* Maximum number of operands in one - single tahoe instruction. */ - -struct top /* Tahoe instruction operand. */ - { - int top_ndx; /* -1, or index register. eg 7=[R7]. */ - int top_reg; /* -1, or register number. eg 7 = R7 or (R7). */ - byte top_mode; /* Addressing mode byte. This byte, defines - which of the 11 modes opcode is. */ - - char top_access; /* Access type wanted for this operand - 'b'branch ' 'no-instruction 'amrvw'. */ - char top_width; /* Operand width expected, one of "bwlq?-:!". */ - - char * top_error; /* Say if operand is inappropriate. */ - - segT seg_of_operand; /* Segment as returned by expression(). */ - - expressionS exp_of_operand; /* The expression as parsed by expression(). */ - - byte top_dispsize; /* Number of bytes in the displacement if we - can figure it out. */ - }; - -/* The addressing modes for an operand. These numbers are the actual values - for certain modes, so be careful if you screw with them. */ -#define TAHOE_DIRECT_REG 0x50 -#define TAHOE_REG_DEFERRED 0x60 - -#define TAHOE_REG_DISP 0xE0 -#define TAHOE_REG_DISP_DEFERRED 0xF0 - -#define TAHOE_IMMEDIATE 0x8F -#define TAHOE_IMMEDIATE_BYTE 0x88 -#define TAHOE_IMMEDIATE_WORD 0x89 -#define TAHOE_IMMEDIATE_LONGWORD 0x8F -#define TAHOE_ABSOLUTE_ADDR 0x9F - -#define TAHOE_DISPLACED_RELATIVE 0xEF -#define TAHOE_DISP_REL_DEFERRED 0xFF - -#define TAHOE_AUTO_DEC 0x7E -#define TAHOE_AUTO_INC 0x8E -#define TAHOE_AUTO_INC_DEFERRED 0x9E -/* INDEXED_REG is decided by the existence or lack of a [reg]. */ - -/* These are encoded into top_width when top_access=='b' - and it's a psuedo op. */ -#define TAHOE_WIDTH_ALWAYS_JUMP '-' -#define TAHOE_WIDTH_CONDITIONAL_JUMP '?' -#define TAHOE_WIDTH_BIG_REV_JUMP '!' -#define TAHOE_WIDTH_BIG_NON_REV_JUMP ':' - -/* The hex code for certain tahoe commands and modes. - This is just for readability. */ -#define TAHOE_JMP 0x71 -#define TAHOE_PC_REL_LONG 0xEF -#define TAHOE_BRB 0x11 -#define TAHOE_BRW 0x13 -/* These, when 'ored' with, or added to, a register number, - set up the number for the displacement mode. */ -#define TAHOE_PC_OR_BYTE 0xA0 -#define TAHOE_PC_OR_WORD 0xC0 -#define TAHOE_PC_OR_LONG 0xE0 - -struct tit /* Get it out of the sewer, it stands for - tahoe instruction tree (Geeze!). */ -{ - tahoe_opcodeT tit_opcode; /* The opcode. */ - byte tit_operands; /* How many operands are here. */ - struct top tit_operand[TIT_MAX_OPERANDS]; /* Operands. */ - char *tit_error; /* "" or fatal error text. */ -}; - -/* end: tahoe-inst.h */ - -/* tahoe.c - tahoe-specific - - Not part of gas yet. */ - -#include "opcode/tahoe.h" - -/* This is the number to put at the beginning of the a.out file. */ -long omagic = OMAGIC; - -/* These chars start a comment anywhere in a source file (except inside - another comment or a quoted string. */ -const char comment_chars[] = "#;"; - -/* These chars only start a comment at the beginning of a line. */ -const char line_comment_chars[] = "#"; - -/* Chars that can be used to separate mant from exp in floating point nums. */ -const char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant - as in 0f123.456 - or 0d1.234E-12 (see exp chars above) - Note: The Tahoe port doesn't support floating point constants. This is - consistent with 'as' If it's needed, I can always add it later. */ -const char FLT_CHARS[] = "df"; - -/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be - changed in read.c . Ideally it shouldn't have to know about it at all, - but nothing is ideal around here. - (The tahoe has plenty of room, so the change currently isn't needed.) */ - -static struct tit t; /* A tahoe instruction after decoding. */ - -void float_cons (); -/* A table of pseudo ops (sans .), the function called, and an integer op - that the function is called with. */ - -const pseudo_typeS md_pseudo_table[] = -{ - {"dfloat", float_cons, 'd'}, - {"ffloat", float_cons, 'f'}, - {0} -}; - -/* For Tahoe, relative addresses of "just the right length" are pretty easy. - The branch displacement is always the last operand, even in - synthetic instructions. - For Tahoe, we encode the relax_substateTs (in e.g. fr_substate) as: - - 4 3 2 1 0 bit number - ---/ /--+-------+-------+-------+-------+-------+ - | what state ? | how long ? | - ---/ /--+-------+-------+-------+-------+-------+ - - The "how long" bits are 00=byte, 01=word, 10=long. - This is a Un*x convention. - Not all lengths are legit for a given value of (what state). - The four states are listed below. - The "how long" refers merely to the displacement length. - The address usually has some constant bytes in it as well. - - States for Tahoe address relaxing. - 1. TAHOE_WIDTH_ALWAYS_JUMP (-) - Format: "b-" - Tahoe opcodes are: (Hex) - jr 11 - jbr 11 - Simple branch. - Always, 1 byte opcode, then displacement/absolute. - If word or longword, change opcode to brw or jmp. - - 2. TAHOE_WIDTH_CONDITIONAL_JUMP (?) - J<cond> where <cond> is a simple flag test. - Format: "b?" - Tahoe opcodes are: (Hex) - jneq/jnequ 21 - jeql/jeqlu 31 - jgtr 41 - jleq 51 - jgeq 81 - jlss 91 - jgtru a1 - jlequ b1 - jvc c1 - jvs d1 - jlssu/jcs e1 - jgequ/jcc f1 - Always, you complement 4th bit to reverse the condition. - Always, 1-byte opcode, then 1-byte displacement. - - 3. TAHOE_WIDTH_BIG_REV_JUMP (!) - Jbc/Jbs where cond tests a memory bit. - Format: "rlvlb!" - Tahoe opcodes are: (Hex) - jbs 0e - jbc 1e - Always, you complement 4th bit to reverse the condition. - Always, 1-byte opcde, longword, longword-address, 1-word-displacement - - 4. TAHOE_WIDTH_BIG_NON_REV_JUMP (:) - JaoblXX/Jbssi - Format: "rlmlb:" - Tahoe opcodes are: (Hex) - aojlss 2f - jaoblss 2f - aojleq 3f - jaobleq 3f - jbssi 5f - Always, we cannot reverse the sense of the branch; we have a word - displacement. - - We need to modify the opcode is for class 1, 2 and 3 instructions. - After relax() we may complement the 4th bit of 2 or 3 to reverse sense of - branch. - - We sometimes store context in the operand literal. This way we can figure out - after relax() what the original addressing mode was. (Was is pc_rel, or - pc_rel_disp? That sort of thing.) */ - -/* These displacements are relative to the START address of the - displacement which is at the start of the displacement, not the end of - the instruction. The hardware pc_rel is at the end of the instructions. - That's why all the displacements have the length of the displacement added - to them. (WF + length(word)) - - The first letter is Byte, Word. - 2nd letter is Forward, Backward. */ -#define BF (1 + 127) -#define BB (1 + -128) -#define WF (2 + 32767) -#define WB (2 + -32768) -/* Dont need LF, LB because they always reach. [They are coded as 0.] */ - -#define C(a,b) ENCODE_RELAX(a, b) -/* This macro has no side-effects. */ -#define ENCODE_RELAX(what,length) (((what) << 2) + (length)) -#define RELAX_STATE(s) ((s) >> 2) -#define RELAX_LENGTH(s) ((s) & 3) - -#define STATE_ALWAYS_BRANCH 1 -#define STATE_CONDITIONAL_BRANCH 2 -#define STATE_BIG_REV_BRANCH 3 -#define STATE_BIG_NON_REV_BRANCH 4 -#define STATE_PC_RELATIVE 5 - -#define STATE_BYTE 0 -#define STATE_WORD 1 -#define STATE_LONG 2 -#define STATE_UNDF 3 /* Symbol undefined in pass1. */ - -/* This is the table used by gas to figure out relaxing modes. The fields are - forward_branch reach, backward_branch reach, number of bytes it would take, - where the next biggest branch is. */ -const relax_typeS md_relax_table[] = -{ - { - 1, 1, 0, 0 - }, /* Error sentinel 0,0 */ - { - 1, 1, 0, 0 - }, /* Unused 0,1 */ - { - 1, 1, 0, 0 - }, /* Unused 0,2 */ - { - 1, 1, 0, 0 - }, /* Unused 0,3 */ -/* Unconditional branch cases "jrb" - The relax part is the actual displacement */ - { - BF, BB, 1, C (1, 1) - }, /* Brb B`foo 1,0 */ - { - WF, WB, 2, C (1, 2) - }, /* Brw W`foo 1,1 */ - { - 0, 0, 5, 0 - }, /* Jmp L`foo 1,2 */ - { - 1, 1, 0, 0 - }, /* Unused 1,3 */ -/* Reversible Conditional Branch. If the branch won't reach, reverse - it, and jump over a brw or a jmp that will reach. The relax part is the - actual address. */ - { - BF, BB, 1, C (2, 1) - }, /* b<cond> B`foo 2,0 */ - { - WF + 2, WB + 2, 4, C (2, 2) - }, /* brev over, brw W`foo, over: 2,1 */ - { - 0, 0, 7, 0 - }, /* brev over, jmp L`foo, over: 2,2 */ - { - 1, 1, 0, 0 - }, /* Unused 2,3 */ -/* Another type of reversible branch. But this only has a word - displacement. */ - { - 1, 1, 0, 0 - }, /* Unused 3,0 */ - { - WF, WB, 2, C (3, 2) - }, /* jbX W`foo 3,1 */ - { - 0, 0, 8, 0 - }, /* jrevX over, jmp L`foo, over: 3,2 */ - { - 1, 1, 0, 0 - }, /* Unused 3,3 */ -/* These are the non reversible branches, all of which have a word - displacement. If I can't reach, branch over a byte branch, to a - jump that will reach. The jumped branch jumps over the reaching - branch, to continue with the flow of the program. It's like playing - leap frog. */ - { - 1, 1, 0, 0 - }, /* Unused 4,0 */ - { - WF, WB, 2, C (4, 2) - }, /* aobl_ W`foo 4,1 */ - { - 0, 0, 10, 0 - }, /*aobl_ W`hop,br over,hop: jmp L^foo,over 4,2*/ - { - 1, 1, 0, 0 - }, /* Unused 4,3 */ -/* Normal displacement mode, no jumping or anything like that. - The relax points to one byte before the address, thats why all - the numbers are up by one. */ - { - BF + 1, BB + 1, 2, C (5, 1) - }, /* B^"foo" 5,0 */ - { - WF + 1, WB + 1, 3, C (5, 2) - }, /* W^"foo" 5,1 */ - { - 0, 0, 5, 0 - }, /* L^"foo" 5,2 */ - { - 1, 1, 0, 0 - }, /* Unused 5,3 */ -}; - -#undef C -#undef BF -#undef BB -#undef WF -#undef WB -/* End relax stuff. */ - -/* Handle of the OPCODE hash table. NULL means any use before - md_begin() will crash. */ -static struct hash_control *op_hash; - -/* Init function. Build the hash table. */ - -void -md_begin (void) -{ - struct tot *tP; - char *errorval = 0; - int synthetic_too = 1; /* If 0, just use real opcodes. */ - - op_hash = hash_new (); - - for (tP = totstrs; *tP->name && !errorval; tP++) - errorval = hash_insert (op_hash, tP->name, &tP->detail); - - if (synthetic_too) - for (tP = synthetic_totstrs; *tP->name && !errorval; tP++) - errorval = hash_insert (op_hash, tP->name, &tP->detail); - - if (errorval) - as_fatal (errorval); -} - -const char *md_shortopts = "ad:STt:V"; - -struct option md_longopts[] = -{ - {NULL, no_argument, NULL, 0} -}; - -size_t md_longopts_size = sizeof (md_longopts); - -int -md_parse_option (int c, char *arg) -{ - switch (c) - { - case 'a': - as_warn (_("The -a option doesn't exist. (Despite what the man page says!")); - break; - - case 'd': - as_warn (_("Displacement length %s ignored!"), arg); - break; - - case 'S': - as_warn (_("SYMBOL TABLE not implemented")); - break; - - case 'T': - as_warn (_("TOKEN TRACE not implemented")); - break; - - case 't': - as_warn (_("I don't need or use temp. file \"%s\"."), arg); - break; - - case 'V': - as_warn (_("I don't use an interpass file! -V ignored")); - break; - - default: - return 0; - } - - return 1; -} - -void -md_show_usage (FILE *stream) -{ - fprintf (stream, _("\ -Tahoe options:\n\ --a ignored\n\ --d LENGTH ignored\n\ --J ignored\n\ --S ignored\n\ --t FILE ignored\n\ --T ignored\n\ --V ignored\n")); -} - -/* The functions in this section take numbers in the machine format, and - munges them into Tahoe byte order. - They exist primarily for cross assembly purpose. - Knows about order of bytes in address. */ - -void -md_number_to_chars (char con[], /* Return 'nbytes' of chars here. */ - valueT value, /* The value of the bits. */ - int nbytes) /* Number of bytes in the output. */ -{ - number_to_chars_bigendian (con, value, nbytes); -} - -void -md_apply_fix (fixS *fixP ATTRIBUTE_UNUSED, - valueT * valP ATTRIBUTE_UNUSED, - segT seg ATTRIBUTE_UNUSED) -{ - /* Should never be called. */ - know (0); -} - -void -md_number_to_disp (char con[]m /* Return 'nbytes' of chars here. */ - long int value, /* The value of the bits. */ - int nbytes) /* Number of bytes in the output. */ -{ - md_number_to_chars (con, value, nbytes); -} - -void -md_number_to_field (char con[], /* Return 'nbytes' of chars here. */ - long int value, /* The value of the bits. */ - int nbytes) /* Number of bytes in the output. */ -{ - md_number_to_chars (con, value, nbytes); -} - -/* Put the bits in an order that a tahoe will understand, despite the ordering - of the native machine. - On Tahoe: first 4 bytes are normal unsigned big endian long, - next three bytes are symbolnum, in kind of 3 byte big endian (least sig. byte last). - The last byte is broken up with bit 7 as pcrel, - bits 6 & 5 as length, - bit 4 as extern and the last nibble as 'undefined'. */ - -void -tc_aout_fix_to_chars (char *where, - fixS *fixP, - relax_addressT segment_address_in_file) -{ - long r_symbolnum; - - know (fixP->fx_addsy != NULL); - - md_number_to_chars (where, - fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file, - 4); - - r_symbolnum = (S_IS_DEFINED (fixP->fx_addsy) - ? S_GET_TYPE (fixP->fx_addsy) - : fixP->fx_addsy->sy_number); - - where[4] = (r_symbolnum >> 16) & 0x0ff; - where[5] = (r_symbolnum >> 8) & 0x0ff; - where[6] = r_symbolnum & 0x0ff; - where[7] = (((is_pcrel (fixP) << 7) & 0x80) - | ((((fixP->fx_type == FX_8 || fixP->fx_type == FX_PCREL8 - ? 0 - : (fixP->fx_type == FX_16 || fixP->fx_type == FX_PCREL16 - ? 1 - : (fixP->fx_type == FX_32 || fixP->fx_type == FX_PCREL32 - ? 2 - : 42)))) << 5) & 0x60) - | ((!S_IS_DEFINED (fixP->fx_addsy) << 4) & 0x10)); -} - -/* Relocate byte stuff. */ - -/* This is for broken word. */ -int md_short_jump_size = 3; - -void -md_create_short_jump (char *ptr, - addressT from_addr, - addressT to_addr, - fragS *frag, - symbolS *to_symbol) -{ - valueT offset; - - offset = to_addr - (from_addr + 1); - *ptr++ = TAHOE_BRW; - md_number_to_chars (ptr, offset, 2); -} - -int md_long_jump_size = 6; -const int md_reloc_size = 8; /* Size of relocation record. */ - -void -md_create_long_jump (char *ptr, - addressT from_addr, - addressT to_addr, - fragS *frag, - symbolS *to_symbol) -{ - valueT offset; - - offset = to_addr - (from_addr + 4); - *ptr++ = TAHOE_JMP; - *ptr++ = TAHOE_PC_REL_LONG; - md_number_to_chars (ptr, offset, 4); -} - -/* md_estimate_size_before_relax(), called just before relax(). - Any symbol that is now undefined will not become defined. - Return the correct fr_subtype in the frag and the growth beyond - fr_fix. */ - -int -md_estimate_size_before_relax (fragS *fragP, segT segment_type) -{ - if (RELAX_LENGTH (fragP->fr_subtype) == STATE_UNDF) - { - if (S_GET_SEGMENT (fragP->fr_symbol) != segment) - { - /* Non-relaxable cases. */ - char *p; - int old_fr_fix; - - old_fr_fix = fragP->fr_fix; - p = fragP->fr_literal + old_fr_fix; - switch (RELAX_STATE (fragP->fr_subtype)) - { - case STATE_PC_RELATIVE: - *p |= TAHOE_PC_OR_LONG; - /* We now know how big it will be, one long word. */ - fragP->fr_fix += 1 + 4; - fix_new (fragP, old_fr_fix + 1, fragP->fr_symbol, - fragP->fr_offset, FX_PCREL32, NULL); - break; - - case STATE_CONDITIONAL_BRANCH: - *fragP->fr_opcode ^= 0x10; /* Reverse sense of branch. */ - *p++ = 6; - *p++ = TAHOE_JMP; - *p++ = TAHOE_PC_REL_LONG; - fragP->fr_fix += 1 + 1 + 1 + 4; - fix_new (fragP, old_fr_fix + 3, fragP->fr_symbol, - fragP->fr_offset, FX_PCREL32, NULL); - break; - - case STATE_BIG_REV_BRANCH: - *fragP->fr_opcode ^= 0x10; /* Reverse sense of branch. */ - *p++ = 0; - *p++ = 6; - *p++ = TAHOE_JMP; - *p++ = TAHOE_PC_REL_LONG; - fragP->fr_fix += 2 + 2 + 4; - fix_new (fragP, old_fr_fix + 4, fragP->fr_symbol, - fragP->fr_offset, FX_PCREL32, NULL); - break; - - case STATE_BIG_NON_REV_BRANCH: - *p++ = 2; - *p++ = 0; - *p++ = TAHOE_BRB; - *p++ = 6; - *p++ = TAHOE_JMP; - *p++ = TAHOE_PC_REL_LONG; - fragP->fr_fix += 2 + 2 + 2 + 4; - fix_new (fragP, old_fr_fix + 6, fragP->fr_symbol, - fragP->fr_offset, FX_PCREL32, NULL); - break; - - case STATE_ALWAYS_BRANCH: - *fragP->fr_opcode = TAHOE_JMP; - *p++ = TAHOE_PC_REL_LONG; - fragP->fr_fix += 1 + 4; - fix_new (fragP, old_fr_fix + 1, fragP->fr_symbol, - fragP->fr_offset, FX_PCREL32, NULL); - break; - - default: - abort (); - } - frag_wane (fragP); - - /* Return the growth in the fixed part of the frag. */ - return fragP->fr_fix - old_fr_fix; - } - - /* Relaxable cases. Set up the initial guess for the variable - part of the frag. */ - switch (RELAX_STATE (fragP->fr_subtype)) - { - case STATE_PC_RELATIVE: - fragP->fr_subtype = ENCODE_RELAX (STATE_PC_RELATIVE, STATE_BYTE); - break; - case STATE_CONDITIONAL_BRANCH: - fragP->fr_subtype = ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_BYTE); - break; - case STATE_BIG_REV_BRANCH: - fragP->fr_subtype = ENCODE_RELAX (STATE_BIG_REV_BRANCH, STATE_WORD); - break; - case STATE_BIG_NON_REV_BRANCH: - fragP->fr_subtype = ENCODE_RELAX (STATE_BIG_NON_REV_BRANCH, STATE_WORD); - break; - case STATE_ALWAYS_BRANCH: - fragP->fr_subtype = ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_BYTE); - break; - } - } - - if (fragP->fr_subtype >= sizeof (md_relax_table) / sizeof (md_relax_table[0])) - abort (); - - /* Return the size of the variable part of the frag. */ - return md_relax_table[fragP->fr_subtype].rlx_length; -} - -/* Called after relax() is finished. - In: Address of frag. - fr_type == rs_machine_dependent. - fr_subtype is what the address relaxed to. - - Out: Any fixSs and constants are set up. - Caller will turn frag into a ".space 0". */ - -void -md_convert_frag (object_headers *headers, segT seg, fragS *fragP) -{ - char *addressP; /* -> _var to change. */ - char *opcodeP; /* -> opcode char(s) to change. */ - short int extension = 0; /* Size of relaxed address. - Added to fr_fix: incl. ALL var chars. */ - symbolS *symbolP; - long int where; - long int address_of_var; - /* Where, in file space, is _var of *fragP? */ - long int target_address; - /* Where, in file space, does addr point? */ - - know (fragP->fr_type == rs_machine_dependent); - where = fragP->fr_fix; - addressP = fragP->fr_literal + where; - opcodeP = fragP->fr_opcode; - symbolP = fragP->fr_symbol; - know (symbolP); - target_address = S_GET_VALUE (symbolP) + fragP->fr_offset; - address_of_var = fragP->fr_address + where; - - switch (fragP->fr_subtype) - { - case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_BYTE): - /* *addressP holds the registers number, plus 0x10, if it's deferred - mode. To set up the right mode, just OR the size of this displacement. */ - /* Byte displacement. */ - *addressP++ |= TAHOE_PC_OR_BYTE; - *addressP = target_address - (address_of_var + 2); - extension = 2; - break; - - case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_WORD): - /* Word displacement. */ - *addressP++ |= TAHOE_PC_OR_WORD; - md_number_to_chars (addressP, target_address - (address_of_var + 3), 2); - extension = 3; - break; - - case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_LONG): - /* Long word displacement. */ - *addressP++ |= TAHOE_PC_OR_LONG; - md_number_to_chars (addressP, target_address - (address_of_var + 5), 4); - extension = 5; - break; - - case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_BYTE): - *addressP = target_address - (address_of_var + 1); - extension = 1; - break; - - case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_WORD): - *opcodeP ^= 0x10; /* Reverse sense of test. */ - *addressP++ = 3; /* Jump over word branch. */ - *addressP++ = TAHOE_BRW; - md_number_to_chars (addressP, target_address - (address_of_var + 4), 2); - extension = 4; - break; - - case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_LONG): - *opcodeP ^= 0x10; /* Reverse sense of test. */ - *addressP++ = 6; - *addressP++ = TAHOE_JMP; - *addressP++ = TAHOE_PC_REL_LONG; - md_number_to_chars (addressP, target_address, 4); - extension = 7; - break; - - case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_BYTE): - *addressP = target_address - (address_of_var + 1); - extension = 1; - break; - - case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_WORD): - *opcodeP = TAHOE_BRW; - md_number_to_chars (addressP, target_address - (address_of_var + 2), 2); - extension = 2; - break; - - case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_LONG): - *opcodeP = TAHOE_JMP; - *addressP++ = TAHOE_PC_REL_LONG; - md_number_to_chars (addressP, target_address - (address_of_var + 5), 4); - extension = 5; - break; - - case ENCODE_RELAX (STATE_BIG_REV_BRANCH, STATE_WORD): - md_number_to_chars (addressP, target_address - (address_of_var + 2), 2); - extension = 2; - break; - - case ENCODE_RELAX (STATE_BIG_REV_BRANCH, STATE_LONG): - *opcodeP ^= 0x10; - *addressP++ = 0; - *addressP++ = 6; - *addressP++ = TAHOE_JMP; - *addressP++ = TAHOE_PC_REL_LONG; - md_number_to_chars (addressP, target_address, 4); - extension = 8; - break; - - case ENCODE_RELAX (STATE_BIG_NON_REV_BRANCH, STATE_WORD): - md_number_to_chars (addressP, target_address - (address_of_var + 2), 2); - extension = 2; - break; - - case ENCODE_RELAX (STATE_BIG_NON_REV_BRANCH, STATE_LONG): - *addressP++ = 0; - *addressP++ = 2; - *addressP++ = TAHOE_BRB; - *addressP++ = 6; - *addressP++ = TAHOE_JMP; - *addressP++ = TAHOE_PC_REL_LONG; - md_number_to_chars (addressP, target_address, 4); - extension = 10; - break; - - default: - BAD_CASE (fragP->fr_subtype); - break; - } - fragP->fr_fix += extension; -} - - -/* This is the stuff for md_assemble. */ -#define FP_REG 13 -#define SP_REG 14 -#define PC_REG 15 -#define BIGGESTREG PC_REG - -/* Parse the string pointed to by START - If it represents a valid register, point START to the character after - the last valid register char, and return the register number (0-15). - If invalid, leave START alone, return -1. - The format has to be exact. I don't do things like eat leading zeros - or the like. - Note: This doesn't check for the next character in the string making - this invalid. Ex: R123 would return 12, it's the callers job to check - what start is point to apon return. - - Valid registers are R1-R15, %1-%15, FP (13), SP (14), PC (15) - Case doesn't matter. */ - -int -tahoe_reg_parse (char **start) /* A pointer to the string to parse. */ -{ - char *regpoint = *start; - int regnum = -1; - - switch (*regpoint++) - { - case '%': /* Registers can start with a %, - R or r, and then a number. */ - case 'R': - case 'r': - if (ISDIGIT (*regpoint)) - { - /* Got the first digit. */ - regnum = *regpoint++ - '0'; - if ((regnum == 1) && ISDIGIT (*regpoint)) - { - /* Its a two digit number. */ - regnum = 10 + (*regpoint++ - '0'); - if (regnum > BIGGESTREG) - regnum = -1; - } - } - break; - case 'F': /* Is it the FP. */ - case 'f': - switch (*regpoint++) - { - case 'p': - case 'P': - regnum = FP_REG; - } - break; - case 's': /* How about the SP. */ - case 'S': - switch (*regpoint++) - { - case 'p': - case 'P': - regnum = SP_REG; - } - break; - case 'p': /* Or the PC even. */ - case 'P': - switch (*regpoint++) - { - case 'c': - case 'C': - regnum = PC_REG; - } - break; - } - - if (regnum != -1) - /* No error, so move string pointer. */ - *start = regpoint; - - return regnum; -} - -/* This chops up an operand and figures out its modes and stuff. - It's a little touchy about extra characters. - Optex to start with one extra character so it can be overwritten for - the backward part of the parsing. - You can't put a bunch of extra characters in side to - make the command look cute. ie: * foo ( r1 ) [ r0 ] - If you like doing a lot of typing, try COBOL! - Actually, this parser is a little weak all around. It's designed to be - used with compliers, so I emphasize correct decoding of valid code quickly - rather that catching every possible error. - Note: This uses the expression function, so save input_line_pointer before - calling. - - Sperry defines the semantics of address modes (and values) - by a two-letter code, explained here. - - letter 1: access type - - a address calculation - no data access, registers forbidden - b branch displacement - m read - let go of bus - write back "modify" - r read - w write - v bit field address: like 'a' but registers are OK - - letter 2: data type (i.e. width, alignment) - - b byte - w word - l longword - q quadword (Even regs < 14 allowed) (if 12, you get a warning) - - unconditional synthetic jbr operand - ? simple synthetic reversible branch operand - ! complex synthetic reversible branch operand - : complex synthetic non-reversible branch operand - - The '-?!:' letter 2's are not for external consumption. They are used - by GAS for psuedo ops relaxing code. - - After parsing topP has: - - top_ndx: -1, or the index register. eg 7=[R7] - top_reg: -1, or register number. eg 7 = R7 or (R7) - top_mode: The addressing mode byte. This byte, defines which of - the 11 modes opcode is. - top_access: Access type wanted for this operand 'b'branch ' ' - no-instruction 'amrvw' - top_width: Operand width expected, one of "bwlq?-:!" - exp_of_operand: The expression as parsed by expression() - top_dispsize: Number of bytes in the displacement if we can figure it - out and it's relevant. - - Need syntax checks built. */ - -void -tip_op (char *optex, /* The users text input, with one leading character. */ - struct top *topP) /* The tahoe instruction with some fields already set: - in: access, width - out: ndx, reg, mode, error, dispsize. */ -{ - int mode = 0; /* This operand's mode. */ - char segfault = *optex; /* To keep the back parsing from freaking. */ - char *point = optex + 1; /* Parsing from front to back. */ - char *end; /* Parsing from back to front. */ - int reg = -1; /* major register, -1 means absent. */ - int imreg = -1; /* Major register in immediate mode. */ - int ndx = -1; /* index register number, -1 means absent. */ - char dec_inc = ' '; /* Is the SP auto-incremented '+' or - auto-decremented '-' or neither ' '. */ - int immediate = 0; /* 1 if '$' immediate mode. */ - int call_width = 0; /* If the caller casts the displacement. */ - int abs_width = 0; /* The width of the absolute displacement. */ - int com_width = 0; /* Displacement width required by branch. */ - int deferred = 0; /* 1 if '*' deferral is used. */ - byte disp_size = 0; /* How big is this operand. 0 == don't know. */ - char *op_bad = ""; /* Bad operand error. */ - char *tp, *temp, c; /* Temporary holders. */ - char access = topP->top_access;/* Save on a deref. */ - char width = topP->top_width; - int really_none = 0; /* Empty expressions evaluate to 0 - but I need to know if it's there or not. */ - expressionS *expP; /* -> expression values for this operand. */ - - /* Does this command restrict the displacement size. */ - if (access == 'b') - com_width = (width == 'b' ? 1 : - (width == 'w' ? 2 : - (width == 'l' ? 4 : 0))); - - *optex = '\0'; /* This is kind of a back stop for all - the searches to fail on if needed. */ - if (*point == '*') - { - /* A dereference? */ - deferred = 1; - point++; - } - - /* Force words into a certain mode. */ - /* Using the ^ operator is ambiguous. If I have an absolute label - called 'w' set to, say 2, and I have the expression 'w^1', do I get - 1, forced to be in word displacement mode, or do I get the value of - 'w' or'ed with 1 (3 in this case). - The default is 'w' as an offset, so that's what I use. - Stick with `, it does the same, and isn't ambig. */ - - if (*point != '\0' && ((point[1] == '^') || (point[1] == '`'))) - switch (*point) - { - case 'b': - case 'B': - case 'w': - case 'W': - case 'l': - case 'L': - if (com_width) - as_warn (_("Casting a branch displacement is bad form, and is ignored.")); - else - { - c = TOLOWER (*point); - call_width = ((c == 'b') ? 1 : - ((c == 'w') ? 2 : 4)); - } - point += 2; - break; - } - - /* Setting immediate mode. */ - if (*point == '$') - { - immediate = 1; - point++; - } - - /* I've pulled off all the easy stuff off the front, move to the end and - yank. */ - - for (end = point; *end != '\0'; end++) /* Move to the end. */ - ; - - if (end != point) /* Null string? */ - end--; - - if (end > point && *end == ' ' && end[-1] != '\'') - end--; /* Hop white space. */ - - /* Is this an index reg. */ - if ((*end == ']') && (end[-1] != '\'')) - { - temp = end; - - /* Find opening brace. */ - for (--end; (*end != '[' && end != point); end--) - ; - - /* If I found the opening brace, get the index register number. */ - if (*end == '[') - { - tp = end + 1; /* tp should point to the start of a reg. */ - ndx = tahoe_reg_parse (&tp); - if (tp != temp) - /* Reg. parse error. */ - ndx = -1; - else - /* Found it, move past brace. */ - end--; - - if (ndx == -1) - { - op_bad = _("Couldn't parse the [index] in this operand."); - end = point; /* Force all the rest of the tests to fail. */ - } - } - else - { - op_bad = _("Couldn't find the opening '[' for the index of this operand."); - end = point; /* Force all the rest of the tests to fail. */ - } - } - - /* Post increment? */ - if (*end == '+') - { - dec_inc = '+'; - /* was: *end--; */ - end--; - } - - /* Register in parens? */ - if ((*end == ')') && (end[-1] != '\'')) - { - temp = end; - - /* Find opening paren. */ - for (--end; (*end != '(' && end != point); end--) - ; - - /* If I found the opening paren, get the register number. */ - if (*end == '(') - { - tp = end + 1; - reg = tahoe_reg_parse (&tp); - if (tp != temp) - { - /* Not a register, but could be part of the expression. */ - reg = -1; - /* Rest the pointer back. */ - end = temp; - } - else - /* Found the reg. move before opening paren. */ - end--; - } - else - { - op_bad = _("Couldn't find the opening '(' for the deref of this operand."); - /* Force all the rest of the tests to fail. */ - end = point; - } - } - - /* Pre decrement? */ - if (*end == '-') - { - if (dec_inc != ' ') - { - op_bad = _("Operand can't be both pre-inc and post-dec."); - end = point; - } - else - { - dec_inc = '-'; - end--; - } - } - - /* Everything between point and end is the 'expression', unless it's - a register name. */ - c = end[1]; - end[1] = '\0'; - - tp = point; - /* Get the immediate register if it is there. */ - imreg = tahoe_reg_parse (&point); - if (*point != '\0') - { - /* If there is junk after point, then the it's not immediate reg. */ - point = tp; - imreg = -1; - } - - if (imreg != -1 && reg != -1) - op_bad = _("I parsed 2 registers in this operand."); - - /* Evaluate whats left of the expression to see if it's valid. - Note again: This assumes that the calling expression has saved - input_line_pointer. (Nag, nag, nag!). */ - if (*op_bad == '\0') - { - /* Statement has no syntax goofs yet: let's sniff the expression. */ - input_line_pointer = point; - expP = &(topP->exp_of_operand); - topP->seg_of_operand = expression (expP); - switch (expP->X_op) - { - case O_absent: - /* No expression. For BSD4.2 compatibility, missing expression is - absolute 0. */ - expP->X_op = O_constant; - expP->X_add_number = 0; - really_none = 1; - case O_constant: - /* For SEG_ABSOLUTE, we shouldn't need to set X_op_symbol, - X_add_symbol to any particular value. */ - /* But, we will program defensively. Since this situation occurs - rarely so it costs us little to do so. */ - expP->X_add_symbol = NULL; - expP->X_op_symbol = NULL; - /* How many bytes are needed to express this abs value? */ - abs_width = - ((((expP->X_add_number & 0xFFFFFF80) == 0) - || ((expP->X_add_number & 0xFFFFFF80) == 0xFFFFFF80)) ? 1 : - (((expP->X_add_number & 0xFFFF8000) == 0) - || ((expP->X_add_number & 0xFFFF8000) == 0xFFFF8000)) ? 2 : 4); - - case O_symbol: - break; - - default: - /* Major bug. We can't handle the case of an operator - expression in a synthetic opcode variable-length - instruction. We don't have a frag type that is smart - enough to relax an operator, and so we just force all - operators to behave like SEG_PASS1s. Clearly, if there is - a demand we can invent a new or modified frag type and - then coding up a frag for this case will be easy. */ - need_pass_2 = 1; - op_bad = _("Can't relocate expression error."); - break; - - case O_big: - /* This is an error. Tahoe doesn't allow any expressions - bigger that a 32 bit long word. Any bigger has to be referenced - by address. */ - op_bad = _("Expression is too large for a 32 bits."); - break; - } - - if (*input_line_pointer != '\0') - op_bad = _("Junk at end of expression."); - } - - end[1] = c; - - /* I'm done, so restore optex. */ - *optex = segfault; - - /* At this point in the game, we (in theory) have all the components of - the operand at least parsed. Now it's time to check for syntax/semantic - errors, and build the mode. - This is what I have: - deferred = 1 if '*' - call_width = 0,1,2,4 - abs_width = 0,1,2,4 - com_width = 0,1,2,4 - immediate = 1 if '$' - ndx = -1 or reg num - dec_inc = '-' or '+' or ' ' - reg = -1 or reg num - imreg = -1 or reg num - topP->exp_of_operand - really_none. */ - /* Is there a displacement size? */ - disp_size = (call_width ? call_width : - (com_width ? com_width : - abs_width ? abs_width : 0)); - - if (*op_bad == '\0') - { - if (imreg != -1) - { - /* Rn */ - mode = TAHOE_DIRECT_REG; - if (deferred - || immediate - || (dec_inc != ' ') - || (reg != -1) - || !really_none) - op_bad = _("Syntax error in direct register mode."); - else if (ndx != -1) - op_bad = _("You can't index a register in direct register mode."); - else if (imreg == SP_REG && access == 'r') - op_bad = - _("SP can't be the source operand with direct register addressing."); - else if (access == 'a') - op_bad = _("Can't take the address of a register."); - else if (access == 'b') - op_bad = _("Direct Register can't be used in a branch."); - else if (width == 'q' && ((imreg % 2) || (imreg > 13))) - op_bad = _("For quad access, the register must be even and < 14."); - else if (call_width) - op_bad = _("You can't cast a direct register."); - - if (*op_bad == '\0') - { - /* No errors, check for warnings. */ - if (width == 'q' && imreg == 12) - as_warn (_("Using reg 14 for quadwords can tromp the FP register.")); - - reg = imreg; - } - - /* We know: imm = -1. */ - } - else if (dec_inc == '-') - { - /* -(SP) */ - mode = TAHOE_AUTO_DEC; - if (deferred || immediate || !really_none) - op_bad = _("Syntax error in auto-dec mode."); - else if (ndx != -1) - op_bad = _("You can't have an index auto dec mode."); - else if (access == 'r') - op_bad = _("Auto dec mode cant be used for reading."); - else if (reg != SP_REG) - op_bad = _("Auto dec only works of the SP register."); - else if (access == 'b') - op_bad = _("Auto dec can't be used in a branch."); - else if (width == 'q') - op_bad = _("Auto dec won't work with quadwords."); - - /* We know: imm = -1, dec_inc != '-'. */ - } - else if (dec_inc == '+') - { - if (immediate || !really_none) - op_bad = _("Syntax error in one of the auto-inc modes."); - else if (deferred) - { - /* *(SP)+ */ - mode = TAHOE_AUTO_INC_DEFERRED; - if (reg != SP_REG) - op_bad = _("Auto inc deferred only works of the SP register."); - else if (ndx != -1) - op_bad = _("You can't have an index auto inc deferred mode."); - else if (access == 'b') - op_bad = _("Auto inc can't be used in a branch."); - } - else - { - /* (SP)+ */ - mode = TAHOE_AUTO_INC; - if (access == 'm' || access == 'w') - op_bad = _("You can't write to an auto inc register."); - else if (reg != SP_REG) - op_bad = _("Auto inc only works of the SP register."); - else if (access == 'b') - op_bad = _("Auto inc can't be used in a branch."); - else if (width == 'q') - op_bad = _("Auto inc won't work with quadwords."); - else if (ndx != -1) - op_bad = _("You can't have an index in auto inc mode."); - } - - /* We know: imm = -1, dec_inc == ' '. */ - } - else if (reg != -1) - { - if ((ndx != -1) && (reg == SP_REG)) - op_bad = _("You can't index the sp register."); - if (deferred) - { - /* *<disp>(Rn) */ - mode = TAHOE_REG_DISP_DEFERRED; - if (immediate) - op_bad = _("Syntax error in register displaced mode."); - } - else if (really_none) - /* (Rn) */ - mode = TAHOE_REG_DEFERRED; - else - /* <disp>(Rn) */ - mode = TAHOE_REG_DISP; - - /* We know: imm = -1, dec_inc == ' ', Reg = -1 */ - } - else - { - if (really_none) - op_bad = _("An offest is needed for this operand."); - if (deferred && immediate) - { - /* *$<ADDR> */ - mode = TAHOE_ABSOLUTE_ADDR; - disp_size = 4; - } - else if (immediate) - { - /* $<disp> */ - mode = TAHOE_IMMEDIATE; - if (ndx != -1) - op_bad = _("You can't index a register in immediate mode."); - if (access == 'a') - op_bad = _("Immediate access can't be used as an address."); - /* ponder the wisdom of a cast because it doesn't do any good. */ - } - else if (deferred) - /* *<disp> */ - mode = TAHOE_DISP_REL_DEFERRED; - else - /* <disp> */ - mode = TAHOE_DISPLACED_RELATIVE; - } - } - - /* At this point, all the errors we can do have be checked for. - We can build the 'top'. */ - topP->top_ndx = ndx; - topP->top_reg = reg; - topP->top_mode = mode; - topP->top_error = op_bad; - topP->top_dispsize = disp_size; -} - -/* This converts a string into a tahoe instruction. - The string must be a bare single instruction in tahoe (with BSD4 frobs) - format. - It provides at most one fatal error message (which stops the scan) - some warning messages as it finds them. - The tahoe instruction is returned in exploded form. - - The exploded instruction is returned to a struct tit of your choice. - #include "tahoe-inst.h" to know what a struct tit is. */ - -static void -tip (struct tit *titP, /* We build an exploded instruction here. */ - char *instring) /* Text of a vax instruction: we modify. */ -{ - struct tot_wot *twP = NULL; /* How to bit-encode this opcode. */ - char *p; /* 1/skip whitespace.2/scan vot_how. */ - char *q; - unsigned char count; /* Counts number of operands seen. */ - struct top *operandp; /* Scan operands in struct tit. */ - char *alloperr = ""; /* Error over all operands. */ - char c; /* Remember char, (we clobber it with '\0' temporarily). */ - char *save_input_line_pointer; - - if (*instring == ' ') - ++instring; /* Skip leading whitespace. */ - for (p = instring; *p && *p != ' '; p++) - ; - - /* Scanned up to end of operation-code. */ - /* Operation-code is ended with whitespace. */ - if (p == instring) - { - titP->tit_error = _("No operator"); - count = 0; - titP->tit_opcode = 0; - } - else - { - c = *p; - *p = '\0'; - - /* Here with instring pointing to what better be an op-name, and p - pointing to character just past that. - We trust instring points to an op-name, with no whitespace. */ - twP = (struct tot_wot *) hash_find (op_hash, instring); - /* Restore char after op-code. */ - *p = c; - if (twP == 0) - { - titP->tit_error = _("Unknown operator"); - count = 0; - titP->tit_opcode = 0; - } - else - { - /* We found a match! So let's pick up as many operands as the - instruction wants, and even gripe if there are too many. - We expect comma to separate each operand. - We let instring track the text, while p tracks a part of the - struct tot. */ - - /* No operands seen yet. */ - count = 0; - /* Point past the operation code. */ - instring = p + (*p != '\0'); - /* tip_op() screws with the input_line_pointer, so save it before - I jump in. */ - save_input_line_pointer = input_line_pointer; - - for (p = twP->args, operandp = titP->tit_operand; - !*alloperr && *p; - operandp++, p += 2) - { - /* Here to parse one operand. Leave instring pointing just - past any one ',' that marks the end of this operand. */ - if (!p[1]) - as_fatal (_("Compiler bug: ODD number of bytes in arg structure %s."), - twP->args); - else if (*instring) - { - for (q = instring; (*q != ',' && *q != '\0'); q++) - /* Jump quoted characters. */ - if (*q == '\'' && q[1] != '\0') - q++; - - c = *q; - /* Q points to ',' or '\0' that ends argument. C is that - character. */ - *q = '\0'; - operandp->top_access = p[0]; - operandp->top_width = p[1]; - tip_op (instring - 1, operandp); - /* Restore input text. */ - *q = c; - - if (*(operandp->top_error)) - alloperr = operandp->top_error; - - /* Next operand (if any). */ - instring = q + (c ? 1 : 0); - /* Won another argument, may have an operr. */ - count++; - } - else - alloperr = _("Not enough operands"); - } - /* Restore the pointer. */ - input_line_pointer = save_input_line_pointer; - - if (!*alloperr) - { - /* Skip whitespace. */ - if (*instring == ' ') - instring ++; - - if (*instring) - alloperr = _("Too many operands"); - } - - titP->tit_error = alloperr; - } - } - - titP->tit_opcode = twP->code; - titP->tit_operands = count; -} - -void -md_assemble (char *instruction_string) -{ - char *p; - struct top *operandP; /* An operand. Scans all operands. */ - expressionS *expP; /* -> expression values for this operand. */ - /* These refer to an instruction operand expression. */ - segT to_seg; /* Target segment of the address. */ - valueT this_add_number; - symbolS *this_add_symbol; /* +ve (minuend) symbol. */ - char *opcodeP; /* Where it is in a frag. */ - int dispsize; /* From top_dispsize: tahoe_operand_width (in bytes). */ - int is_undefined; /* 1 if operand expression's segment not known yet. */ - int pc_rel; /* Is this operand pc relative? */ - - /* Decode the operand. */ - tip (&t, instruction_string); - - /* Check to see if this operand decode properly. - Notice that we haven't made any frags yet. - If it goofed, then this instruction will wedge in any pass, - and we can safely flush it, without causing interpass symbol phase - errors. That is, without changing label values in different passes. */ - - if (*t.tit_error) - as_warn (_("Ignoring statement due to \"%s\""), t.tit_error); - else - { - /* We saw no errors in any operands - try to make frag(s). */ - /* Emit op-code. */ - /* Remember where it is, in case we want to modify the op-code later. */ - opcodeP = frag_more (1); - *opcodeP = t.tit_opcode; - /* Now do each operand. */ - for (operandP = t.tit_operand; - operandP < t.tit_operand + t.tit_operands; - operandP++) - { /* for each operand */ - expP = &(operandP->exp_of_operand); - if (operandP->top_ndx >= 0) - { - /* Indexed addressing byte - Legality of indexed mode already checked: it is OK. */ - FRAG_APPEND_1_CHAR (0x40 + operandP->top_ndx); - } /* if(top_ndx>=0) */ - - /* Here to make main operand frag(s). */ - this_add_number = expP->X_add_number; - this_add_symbol = expP->X_add_symbol; - to_seg = operandP->seg_of_operand; - know (to_seg == SEG_UNKNOWN \ - || to_seg == SEG_ABSOLUTE \ - || to_seg == SEG_DATA \ - || to_seg == SEG_TEXT \ - || to_seg == SEG_BSS); - is_undefined = (to_seg == SEG_UNKNOWN); - /* Do we know how big this operand is? */ - dispsize = operandP->top_dispsize; - pc_rel = 0; - /* Deal with the branch possibilities. (Note, this doesn't include jumps.) */ - if (operandP->top_access == 'b') - { - /* Branches must be expressions. A psuedo branch can also jump to - an absolute address. */ - if (to_seg == now_seg || is_undefined) - { - /* If is_undefined, then it might BECOME now_seg by relax time. */ - if (dispsize) - { - /* I know how big the branch is supposed to be (it's a normal - branch), so I set up the frag, and let GAS do the rest. */ - p = frag_more (dispsize); - fix_new (frag_now, p - frag_now->fr_literal, - this_add_symbol, this_add_number, - size_to_fx (dispsize, 1), - NULL); - } - else - { - /* If we don't know how big it is, then its a synthetic branch, - so we set up a simple relax state. */ - switch (operandP->top_width) - { - case TAHOE_WIDTH_CONDITIONAL_JUMP: - /* Simple (conditional) jump. I may have to reverse the - condition of opcodeP, and then jump to my destination. - I set 1 byte aside for the branch off set, and could need 6 - more bytes for the pc_rel jump. */ - frag_var (rs_machine_dependent, 7, 1, - ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, - is_undefined ? STATE_UNDF : STATE_BYTE), - this_add_symbol, this_add_number, opcodeP); - break; - case TAHOE_WIDTH_ALWAYS_JUMP: - /* Simple (unconditional) jump. I may have to convert this to - a word branch, or an absolute jump. */ - frag_var (rs_machine_dependent, 5, 1, - ENCODE_RELAX (STATE_ALWAYS_BRANCH, - is_undefined ? STATE_UNDF : STATE_BYTE), - this_add_symbol, this_add_number, opcodeP); - break; - /* The smallest size for the next 2 cases is word. */ - case TAHOE_WIDTH_BIG_REV_JUMP: - frag_var (rs_machine_dependent, 8, 2, - ENCODE_RELAX (STATE_BIG_REV_BRANCH, - is_undefined ? STATE_UNDF : STATE_WORD), - this_add_symbol, this_add_number, - opcodeP); - break; - case TAHOE_WIDTH_BIG_NON_REV_JUMP: - frag_var (rs_machine_dependent, 10, 2, - ENCODE_RELAX (STATE_BIG_NON_REV_BRANCH, - is_undefined ? STATE_UNDF : STATE_WORD), - this_add_symbol, this_add_number, - opcodeP); - break; - default: - as_fatal (_("Compliler bug: Got a case (%d) I wasn't expecting."), - operandP->top_width); - } - } - } - else - { - /* to_seg != now_seg && to_seg != seg_unknown (still in branch) - In other words, I'm jumping out of my segment so extend the - branches to jumps, and let GAS fix them. */ - - /* These are "branches" what will always be branches around a jump - to the correct address in real life. - If to_seg is SEG_ABSOLUTE, just encode the branch in, - else let GAS fix the address. */ - - switch (operandP->top_width) - { - /* The theory: - For SEG_ABSOLUTE, then mode is ABSOLUTE_ADDR, jump - to that address (not pc_rel). - For other segs, address is a long word PC rel jump. */ - case TAHOE_WIDTH_CONDITIONAL_JUMP: - /* b<cond> */ - /* To reverse the condition in a TAHOE branch, - complement bit 4 */ - *opcodeP ^= 0x10; - p = frag_more (7); - *p++ = 6; - *p++ = TAHOE_JMP; - *p++ = (operandP->top_mode == - TAHOE_ABSOLUTE_ADDR ? TAHOE_ABSOLUTE_ADDR : - TAHOE_PC_REL_LONG); - fix_new (frag_now, p - frag_now->fr_literal, - this_add_symbol, this_add_number, - (to_seg != SEG_ABSOLUTE) ? FX_PCREL32 : FX_32, NULL); - - /* Now (eg) BLEQ 1f - JMP foo - 1: */ - break; - - case TAHOE_WIDTH_ALWAYS_JUMP: - /* Br, just turn it into a jump. */ - *opcodeP = TAHOE_JMP; - p = frag_more (5); - *p++ = (operandP->top_mode == - TAHOE_ABSOLUTE_ADDR ? TAHOE_ABSOLUTE_ADDR : - TAHOE_PC_REL_LONG); - fix_new (frag_now, p - frag_now->fr_literal, - this_add_symbol, this_add_number, - (to_seg != SEG_ABSOLUTE) ? FX_PCREL32 : FX_32, NULL); - /* Now (eg) JMP foo. */ - break; - - case TAHOE_WIDTH_BIG_REV_JUMP: - p = frag_more (8); - *opcodeP ^= 0x10; - *p++ = 0; - *p++ = 6; - *p++ = TAHOE_JMP; - *p++ = (operandP->top_mode == - TAHOE_ABSOLUTE_ADDR ? TAHOE_ABSOLUTE_ADDR : - TAHOE_PC_REL_LONG); - fix_new (frag_now, p - frag_now->fr_literal, - this_add_symbol, this_add_number, - (to_seg != SEG_ABSOLUTE) ? FX_PCREL32 : FX_32, NULL); - /* Now (eg) ACBx 1f - JMP foo - 1: */ - break; - - case TAHOE_WIDTH_BIG_NON_REV_JUMP: - p = frag_more (10); - *p++ = 0; - *p++ = 2; - *p++ = TAHOE_BRB; - *p++ = 6; - *p++ = TAHOE_JMP; - *p++ = (operandP->top_mode == - TAHOE_ABSOLUTE_ADDR ? TAHOE_ABSOLUTE_ADDR : - TAHOE_PC_REL_LONG); - fix_new (frag_now, p - frag_now->fr_literal, - this_add_symbol, this_add_number, - (to_seg != SEG_ABSOLUTE) ? FX_PCREL32 : FX_32, NULL); - /* Now (eg) xOBxxx 1f - BRB 2f - 1: JMP @#foo - 2: */ - break; - case 'b': - case 'w': - as_warn (_("Real branch displacements must be expressions.")); - break; - default: - as_fatal (_("Complier error: I got an unknown synthetic branch :%c"), - operandP->top_width); - break; - } - } - } - else - { - /* It ain't a branch operand. */ - switch (operandP->top_mode) - { - /* Auto-foo access, only works for one reg (SP) - so the only thing needed is the mode. */ - case TAHOE_AUTO_DEC: - case TAHOE_AUTO_INC: - case TAHOE_AUTO_INC_DEFERRED: - FRAG_APPEND_1_CHAR (operandP->top_mode); - break; - - /* Numbered Register only access. Only thing needed is the - mode + Register number. */ - case TAHOE_DIRECT_REG: - case TAHOE_REG_DEFERRED: - FRAG_APPEND_1_CHAR (operandP->top_mode + operandP->top_reg); - break; - - /* An absolute address. It's size is always 5 bytes. - (mode_type + 4 byte address). */ - case TAHOE_ABSOLUTE_ADDR: - know ((this_add_symbol == NULL)); - p = frag_more (5); - *p = TAHOE_ABSOLUTE_ADDR; - md_number_to_chars (p + 1, this_add_number, 4); - break; - - /* Immediate data. If the size isn't known, then it's an address - + and offset, which is 4 bytes big. */ - case TAHOE_IMMEDIATE: - if (this_add_symbol != NULL) - { - p = frag_more (5); - *p++ = TAHOE_IMMEDIATE_LONGWORD; - fix_new (frag_now, p - frag_now->fr_literal, - this_add_symbol, this_add_number, - FX_32, NULL); - } - else - { - /* It's an integer, and I know it's size. */ - if ((unsigned) this_add_number < 0x40) - /* Will it fit in a literal? */ - FRAG_APPEND_1_CHAR ((byte) this_add_number); - else - { - p = frag_more (dispsize + 1); - switch (dispsize) - { - case 1: - *p++ = TAHOE_IMMEDIATE_BYTE; - *p = (byte) this_add_number; - break; - case 2: - *p++ = TAHOE_IMMEDIATE_WORD; - md_number_to_chars (p, this_add_number, 2); - break; - case 4: - *p++ = TAHOE_IMMEDIATE_LONGWORD; - md_number_to_chars (p, this_add_number, 4); - break; - } - } - } - break; - - /* Distance from the PC. If the size isn't known, we have to relax - into it. The difference between this and disp(sp) is that - this offset is pc_rel, and disp(sp) isn't. - Note the drop through code. */ - - case TAHOE_DISPLACED_RELATIVE: - case TAHOE_DISP_REL_DEFERRED: - operandP->top_reg = PC_REG; - pc_rel = 1; - - /* Register, plus a displacement mode. Save the register number, - and weather its deffered or not, and relax the size if it isn't - known. */ - case TAHOE_REG_DISP: - case TAHOE_REG_DISP_DEFERRED: - if (operandP->top_mode == TAHOE_DISP_REL_DEFERRED - || operandP->top_mode == TAHOE_REG_DISP_DEFERRED) - /* Deffered mode is always 0x10 higher than it's non-deffered sibling. */ - operandP->top_reg += 0x10; - - /* Is this a value out of this segment? - The first part of this conditional is a cludge to make gas - produce the same output as 'as' when there is a lable, in - the current segment, displacing a register. It's strange, - and no one in their right mind would do it, but it's easy - to cludge. */ - if ((dispsize == 0 && !pc_rel) - || (to_seg != now_seg && !is_undefined && to_seg != SEG_ABSOLUTE)) - dispsize = 4; - - if (dispsize == 0) - { - /* We have a SEG_UNKNOWN symbol, or the size isn't cast. - It might turn out to be in the same segment as - the instruction, permitting relaxation. */ - p = frag_var (rs_machine_dependent, 5, 2, - ENCODE_RELAX (STATE_PC_RELATIVE, - is_undefined ? STATE_UNDF : STATE_BYTE), - this_add_symbol, this_add_number, 0); - *p = operandP->top_reg; - } - else - { - /* Either this is an abs, or a cast. */ - p = frag_more (dispsize + 1); - switch (dispsize) - { - case 1: - *p = TAHOE_PC_OR_BYTE + operandP->top_reg; - break; - case 2: - *p = TAHOE_PC_OR_WORD + operandP->top_reg; - break; - case 4: - *p = TAHOE_PC_OR_LONG + operandP->top_reg; - break; - }; - fix_new (frag_now, p + 1 - frag_now->fr_literal, - this_add_symbol, this_add_number, - size_to_fx (dispsize, pc_rel), NULL); - } - break; - default: - as_fatal (_("Barf, bad mode %x\n"), operandP->top_mode); - } - } - } - } -} - -/* We have no need to default values of symbols. */ - -symbolS * -md_undefined_symbol (char *name) -{ - return 0; -} - -/* Round up a section size to the appropriate boundary. */ - -valueT -md_section_align (segT segment, valueT size) -{ - /* Round all sects to multiple of 8. */ - return ((size + 7) & ~7); -} - -/* Exactly what point is a PC-relative offset relative TO? - On the sparc, they're relative to the address of the offset, plus - its size. This gets us to the following instruction. - (??? Is this right? FIXME-SOON) */ - -long -md_pcrel_from (fixS *fixP) -{ - return (((fixP->fx_type == FX_8 - || fixP->fx_type == FX_PCREL8) - ? 1 - : ((fixP->fx_type == FX_16 - || fixP->fx_type == FX_PCREL16) - ? 2 - : ((fixP->fx_type == FX_32 - || fixP->fx_type == FX_PCREL32) - ? 4 - : 0))) + fixP->fx_where + fixP->fx_frag->fr_address); -} - -int -tc_is_pcrel (fixS *fixP) -{ - /* Should never be called. */ - know (0); - return 0; -} diff --git a/gas/config/tc-tahoe.h b/gas/config/tc-tahoe.h deleted file mode 100644 index 8d64757..0000000 --- a/gas/config/tc-tahoe.h +++ /dev/null @@ -1,43 +0,0 @@ -/* This file is tc-tahoe.h - - Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1995, 2000 - 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -#define TC_TAHOE 1 - -#define TARGET_BYTES_BIG_ENDIAN 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) {;} - -#define md_operand(x) - -extern const struct relax_type md_relax_table[]; -#define TC_GENERIC_RELAX_TABLE md_relax_table - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ diff --git a/gas/config/tc-tic30.c b/gas/config/tc-tic30.c index dfdb4b0..b4acccc 100644 --- a/gas/config/tc-tic30.c +++ b/gas/config/tc-tic30.c @@ -38,8 +38,6 @@ static char *ordinal_names[] = "first", "second", "third", "fourth", "fifth" }; -const int md_reloc_size = 0; - const char comment_chars[] = ";"; const char line_comment_chars[] = "*"; const char line_separator_chars[] = ""; diff --git a/gas/config/tc-tic30.h b/gas/config/tc-tic30.h index c81f81d..1001707 100644 --- a/gas/config/tc-tic30.h +++ b/gas/config/tc-tic30.h @@ -48,6 +48,4 @@ extern int tic30_unrecognized_line (int); -#define tc_aout_pre_write_hook {} - #endif diff --git a/gas/config/tc-tic4x.c b/gas/config/tc-tic4x.c index a3ac44e..022ba52 100644 --- a/gas/config/tc-tic4x.c +++ b/gas/config/tc-tic4x.c @@ -257,7 +257,6 @@ const pseudo_typeS int md_short_jump_size = 4; int md_long_jump_size = 4; -const int md_reloc_size = RELSZ; /* Coff headers. */ /* This array holds the chars that always start a comment. If the pre-processor is disabled, these aren't very useful. */ diff --git a/gas/config/tc-tic4x.h b/gas/config/tc-tic4x.h index f135389..fdc6eea 100644 --- a/gas/config/tc-tic4x.h +++ b/gas/config/tc-tic4x.h @@ -22,10 +22,6 @@ #define TC_TIC4X #define TIC4X -#ifndef BFD_ASSEMBLER -#error TMS320C4x requires BFD_ASSEMBLER -#endif - #define TARGET_ARCH bfd_arch_tic4x #define WORKING_DOT_WORD @@ -57,13 +53,6 @@ #define OCTETS_PER_BYTE_POWER 2 #define TARGET_ARCH bfd_arch_tic4x -#define BFD_ARCH TARGET_ARCH - -#define TC_COUNT_RELOC(x) (x->fx_addsy) -#define TC_CONS_RELOC RELOC_32 -#define TC_COFF_FIX2RTYPE(fixP) tc_coff_fix2rtype (fixP) -#define TC_COFF_SIZEMACHDEP(frag) tc_coff_sizemachdep (frag) -#define NEED_FX_R_TYPE #define TIC_NOP_OPCODE 0x0c800000 diff --git a/gas/config/tc-tic54x.c b/gas/config/tc-tic54x.c index da1f4bc..b81041f 100644 --- a/gas/config/tc-tic54x.c +++ b/gas/config/tc-tic54x.c @@ -5549,17 +5549,6 @@ md_pcrel_from (fixP) return 0; } -#if defined OBJ_COFF - -short -tc_coff_fix2rtype (fixP) - fixS *fixP; -{ - return (fixP->fx_r_type); -} - -#endif /* OBJ_COFF */ - /* Mostly little-endian, but longwords (4 octets) get MS word stored first. */ diff --git a/gas/config/tc-tic54x.h b/gas/config/tc-tic54x.h index 39e4058..4d9b2c8 100644 --- a/gas/config/tc-tic54x.h +++ b/gas/config/tc-tic54x.h @@ -29,7 +29,6 @@ #define OCTETS_PER_BYTE_POWER 1 #define TARGET_ARCH bfd_arch_tic54x -#define BFD_ARCH TARGET_ARCH #define WORKING_DOT_WORD 1 @@ -48,10 +47,6 @@ /* affects preprocessor */ #define KEEP_WHITE_AROUND_COLON 1 -/* We need the extra field in the fixup struct to put the relocation in. */ - -#define NEED_FX_R_TYPE - struct bit_info { segT seg; diff --git a/gas/config/tc-tic80.c b/gas/config/tc-tic80.c deleted file mode 100644 index 55d6428..0000000 --- a/gas/config/tc-tic80.c +++ /dev/null @@ -1,894 +0,0 @@ -/* tc-tic80.c -- Assemble for the TI TMS320C80 (MV) - Copyright 1996, 1997, 2000, 2001, 2002, 2005 - 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -#include "as.h" -#include "safe-ctype.h" -#include "opcode/tic80.h" - -#define internal_error(what) \ - as_fatal (_("internal error:%s:%d: %s\n"), __FILE__, __LINE__, what) - -#define internal_error_a(what,arg) \ - as_fatal (_("internal error:%s:%d: %s %ld\n"), __FILE__, __LINE__, what, arg) - -/* Generic assembler global variables which must be defined by all - targets. */ - -/* Characters which always start a comment. */ -const char comment_chars[] = ";"; - -/* Characters which start a comment at the beginning of a line. */ -const char line_comment_chars[] = ";*#"; - -/* Characters which may be used to separate multiple commands on a single - line. The semicolon is such a character by default and should not be - explicitly listed. */ -const char line_separator_chars[] = ""; - -/* Characters which are used to indicate an exponent in a floating - point number. */ -const char EXP_CHARS[] = "eE"; - -/* Characters which mean that a number is a floating point constant, - as in 0f1.0. */ -const char FLT_CHARS[] = "fF"; - -/* This table describes all the machine specific pseudo-ops the assembler - has to support. The fields are: - - pseudo-op name without dot - function to call to execute this pseudo-op - integer arg to pass to the function */ - -const pseudo_typeS md_pseudo_table[] = -{ - { "align", s_align_bytes, 4 }, /* Do byte alignment, default is a 4 byte boundary. */ - { "word", cons, 4 }, /* FIXME: Should this be machine independent? */ - { "bss", s_lcomm_bytes, 1 }, - { "sect", obj_coff_section, 0}, /* For compatibility with TI tools. */ - { "section", obj_coff_section, 0}, /* Standard COFF .section pseudo-op. */ - { NULL, NULL, 0 } -}; - -/* Opcode hash table. */ -static struct hash_control *tic80_hash; - -/* Replace short PC relative instructions with long form when - necessary. Currently this is off by default or when given the - -no-relax option. Turning it on by using the -relax option forces - all PC relative instructions to use the long form, which is why it - is currently not the default. */ -static int tic80_relax = 0; - -int -md_estimate_size_before_relax (fragS *fragP ATTRIBUTE_UNUSED, - segT segment_type ATTRIBUTE_UNUSED) -{ - internal_error (_("Relaxation is a luxury we can't afford")); - return -1; -} - -/* We have no need to default values of symbols. */ - -symbolS * -md_undefined_symbol (char *name ATTRIBUTE_UNUSED) -{ - return NULL; -} - -/* Turn a string in input_line_pointer into a floating point constant - of type TYPE, and store the appropriate bytes in *LITP. The number - of LITTLENUMS emitted is stored in *SIZEP. An error message is - returned, or NULL on OK. */ - -#define MAX_LITTLENUMS 4 - -char * -md_atof (int type, char *litP, int *sizeP) -{ - int prec; - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - char *t; - - switch (type) - { - case 'f': - case 'F': - case 's': - case 'S': - prec = 2; - break; - - case 'd': - case 'D': - case 'r': - case 'R': - prec = 4; - break; - - default: - *sizeP = 0; - return _("bad call to md_atof ()"); - } - - t = atof_ieee (input_line_pointer, type, words); - if (t) - input_line_pointer = t; - - *sizeP = prec * sizeof (LITTLENUM_TYPE); - - for (wordP = words; prec--;) - { - md_number_to_chars (litP, (valueT) (*wordP++), sizeof (LITTLENUM_TYPE)); - litP += sizeof (LITTLENUM_TYPE); - } - - return NULL; -} - -/* Check to see if the constant value in NUM will fit in a field of - width BITS if it has flags FLAGS. */ - -static int -const_overflow (unsigned long num, int bits, int flags) -{ - long min, max; - int retval = 0; - - /* Only need to check fields less than 32 bits wide. */ - if (bits >= 32) - return retval; - - if (flags & TIC80_OPERAND_SIGNED) - { - max = (1 << (bits - 1)) - 1; - min = - (1 << (bits - 1)); - retval = (long) num > max || (long) num < min; - } - else - { - max = (1 << bits) - 1; - retval = num > (unsigned long) max; - } - return retval; -} - -/* get_operands () parses a string of operands and fills in a passed - array of expressions in EXP. - - Note that we use O_absent expressions to record additional information - about the previous non-O_absent expression, such as ":m" or ":s" - modifiers or register numbers enclosed in parens like "(r10)". - - Returns the number of expressions that were placed in EXP. */ - -static int -get_operands (expressionS exp[]) -{ - char *p = input_line_pointer; - int numexp = 0; - int parens = 0; - - while (*p) - { - /* Skip leading whitespace. */ - while (*p == ' ' || *p == '\t' || *p == ',') - p++; - - /* Check to see if we have any operands left to parse. */ - if (*p == 0 || *p == '\n' || *p == '\r') - break; - - /* Notice scaling or direct memory operand modifiers and save them in - an O_absent expression after the expression that they modify. */ - - if (*p == ':') - { - p++; - exp[numexp].X_op = O_absent; - if (*p == 'm') - { - p++; - /* This is a ":m" modifier. */ - exp[numexp].X_add_number = TIC80_OPERAND_M_SI | TIC80_OPERAND_M_LI; - } - else if (*p == 's') - { - p++; - /* This is a ":s" modifier. */ - exp[numexp].X_add_number = TIC80_OPERAND_SCALED; - } - else - as_bad (_("':' not followed by 'm' or 's'")); - - numexp++; - continue; - } - - /* Handle leading '(' on operands that use them, by recording that we - have entered a paren nesting level and then continuing. We complain - about multiple nesting. */ - - if (*p == '(') - { - if (++parens != 1) - as_bad (_("paren nesting")); - - p++; - continue; - } - - /* Handle trailing ')' on operands that use them, by reducing the - nesting level and then continuing. We complain if there were too - many closures. */ - - if (*p == ')') - { - /* Record that we have left a paren group and continue. */ - if (--parens < 0) - as_bad (_("mismatched parenthesis")); - - p++; - continue; - } - - /* Begin operand parsing at the current scan point. */ - input_line_pointer = p; - expression (&exp[numexp]); - - if (exp[numexp].X_op == O_illegal) - as_bad (_("illegal operand")); - else if (exp[numexp].X_op == O_absent) - as_bad (_("missing operand")); - - numexp++; - p = input_line_pointer; - } - - if (parens) - { - exp[numexp].X_op = O_absent; - exp[numexp++].X_add_number = TIC80_OPERAND_PARENS; - } - - /* Mark the end of the valid operands with an illegal expression. */ - exp[numexp].X_op = O_illegal; - - return numexp; -} - -/* find_opcode() gets a pointer to the entry in the opcode table that - matches the instruction being assembled, or returns NULL if no such match - is found. - - First it parses all the operands and save them as expressions. Note that - we use O_absent expressions to record additional information about the - previous non-O_absent expression, such as ":m" or ":s" modifiers or - register numbers enclosed in parens like "(r10)". - - It then looks at all opcodes with the same name and uses the operands to - choose the correct opcode. */ - -static struct tic80_opcode * -find_opcode (struct tic80_opcode *opcode, expressionS myops[]) -{ - int numexp; /* Number of expressions from parsing operands. */ - int expi; /* Index of current expression to match. */ - int opi; /* Index of current operand to match. */ - int match = 0; /* Set to 1 when an operand match is found. */ - struct tic80_opcode *opc = opcode; /* Pointer to current opcode table entry. */ - const struct tic80_opcode *end; /* Pointer to end of opcode table. */ - - /* First parse all the operands so we only have to do it once. There may - be more expressions generated than there are operands. */ - numexp = get_operands (myops); - - /* For each opcode with the same name, try to match it against the parsed - operands. */ - end = tic80_opcodes + tic80_num_opcodes; - while (!match && (opc < end) && (strcmp (opc->name, opcode->name) == 0)) - { - /* Start off assuming a match. If we find a mismatch, then this is - reset and the operand/expr matching loop terminates with match - equal to zero, which allows us to try the next opcode. */ - match = 1; - - /* For each expression, try to match it against the current operand - for the current opcode. Upon any mismatch, we abandon further - matching for the current opcode table entry. */ - for (expi = 0, opi = -1; (expi < numexp) && match; expi++) - { - int bits, flags, X_op, num; - - X_op = myops[expi].X_op; - num = myops[expi].X_add_number; - - /* The O_absent expressions apply to the same operand as the most - recent non O_absent expression. So only increment the operand - index when the current expression is not one of these special - expressions. */ - if (X_op != O_absent) - opi++; - - flags = tic80_operands[opc->operands[opi]].flags; - bits = tic80_operands[opc->operands[opi]].bits; - - switch (X_op) - { - case O_register: - /* Also check that registers that are supposed to be - even actually are even. */ - if (((flags & TIC80_OPERAND_GPR) != (num & TIC80_OPERAND_GPR)) || - ((flags & TIC80_OPERAND_FPA) != (num & TIC80_OPERAND_FPA)) || - ((flags & TIC80_OPERAND_CR) != (num & TIC80_OPERAND_CR)) || - ((flags & TIC80_OPERAND_EVEN) && (num & 1)) || - const_overflow (num & ~TIC80_OPERAND_MASK, bits, flags)) - match = 0; - break; - - case O_constant: - if ((flags & TIC80_OPERAND_ENDMASK) && (num == 32)) - /* Endmask values of 0 and 32 give identical - results. */ - num = 0; - - if ((flags & (TIC80_OPERAND_FPA | TIC80_OPERAND_GPR)) || - const_overflow (num, bits, flags)) - match = 0; - break; - - case O_symbol: - if ((bits < 32) && (flags & TIC80_OPERAND_PCREL) - && !tic80_relax) - { - /* The default is to prefer the short form of PC - relative relocations. This is the only form that - the TI assembler supports. If the -relax option - is given, we never use the short forms. - FIXME: Should be able to choose "best-fit". */ - } - else if ((bits == 32)) - { - /* The default is to prefer the long form of base - relative relocations. This is the only form that - the TI assembler supports. If the -no-relax - option is given, we always use the long form of - PC relative relocations. - FIXME: Should be able to choose "best-fit". */ - } - else - { - /* Symbols that don't match one of the above cases are - rejected as an operand. */ - match = 0; - } - break; - - case O_absent: - /* If this is an O_absent expression, then it may be an - expression that supplies additional information about - the operand, such as ":m" or ":s" modifiers. Check to - see that the operand matches this requirement. */ - if (!((num & flags & TIC80_OPERAND_M_SI) - || (num & flags & TIC80_OPERAND_M_LI) - || (num & flags & TIC80_OPERAND_SCALED))) - match = 0; - break; - - case O_big: - if ((num > 0) || !(flags & TIC80_OPERAND_FLOAT)) - match = 0; - break; - - case O_illegal: - case O_symbol_rva: - case O_uminus: - case O_bit_not: - case O_logical_not: - case O_multiply: - case O_divide: - case O_modulus: - case O_left_shift: - case O_right_shift: - case O_bit_inclusive_or: - case O_bit_or_not: - case O_bit_exclusive_or: - case O_bit_and: - case O_add: - case O_subtract: - case O_eq: - case O_ne: - case O_lt: - case O_le: - case O_ge: - case O_gt: - case O_logical_and: - case O_logical_or: - case O_max: - default: - internal_error_a (_("unhandled expression type"), (long) X_op); - } - } - if (!match) - opc++; - } - - return match ? opc : NULL; - -} - -/* build_insn takes a pointer to the opcode entry in the opcode table - and the array of operand expressions and writes out the instruction. - - Note that the opcode word and extended word may be written to different - frags, with the opcode at the end of one frag and the extension at the - beginning of the next. */ - -static void -build_insn (struct tic80_opcode *opcode, expressionS *opers) -{ - int expi; /* Index of current expression to match. */ - int opi; /* Index of current operand to match. */ - unsigned long insn[2]; /* Instruction and long immediate (if any). */ - char *f; /* Pointer to frag location for insn[0]. */ - fragS *ffrag; /* Frag containing location f. */ - char *fx = NULL; /* Pointer to frag location for insn[1]. */ - fragS *fxfrag; /* Frag containing location fx. */ - - /* Start with the raw opcode bits from the opcode table. */ - insn[0] = opcode->opcode; - insn[1] = 0; - - /* We are going to insert at least one 32 bit opcode so get the - frag now. */ - f = frag_more (4); - ffrag = frag_now; - - /* For each operand expression, insert the appropriate bits into the - instruction. */ - for (expi = 0, opi = -1; opers[expi].X_op != O_illegal; expi++) - { - int bits, shift, flags, X_op, num; - - X_op = opers[expi].X_op; - num = opers[expi].X_add_number; - - /* The O_absent expressions apply to the same operand as the most - recent non O_absent expression. So only increment the operand - index when the current expression is not one of these special - expressions. */ - if (X_op != O_absent) - opi++; - - flags = tic80_operands[opcode->operands[opi]].flags; - bits = tic80_operands[opcode->operands[opi]].bits; - shift = tic80_operands[opcode->operands[opi]].shift; - - switch (X_op) - { - case O_register: - num &= ~TIC80_OPERAND_MASK; - insn[0] = insn[0] | (num << shift); - break; - - case O_constant: - if ((flags & TIC80_OPERAND_ENDMASK) && (num == 32)) - /* Endmask values of 0 and 32 give identical results. */ - num = 0; - else if ((flags & TIC80_OPERAND_BITNUM)) - /* BITNUM values are stored in one's complement form. */ - num = (~num & 0x1F); - - /* Mask off upper bits, just it case it is signed and is - negative. */ - if (bits < 32) - { - num &= (1 << bits) - 1; - insn[0] = insn[0] | (num << shift); - } - else - { - fx = frag_more (4); - fxfrag = frag_now; - insn[1] = num; - } - break; - - case O_symbol: - if (bits == 32) - { - fx = frag_more (4); - fxfrag = frag_now; - insn[1] = 0; - - if (flags & TIC80_OPERAND_PCREL) - fix_new_exp (fxfrag, fx - (fxfrag->fr_literal), - 4, &opers[expi], 1, R_MPPCR); - else - fix_new_exp (fxfrag, fx - (fxfrag->fr_literal), - 4, &opers[expi], 0, R_RELLONGX); - } - else if (flags & TIC80_OPERAND_PCREL) - fix_new_exp (ffrag, f - (ffrag->fr_literal), - 4, /* FIXME! how is this used? */ - &opers[expi], 1, R_MPPCR15W); - else - internal_error (_("symbol reloc that is not PC relative or 32 bits")); - break; - - case O_absent: - /* Each O_absent expression can indicate exactly one - possible modifier. */ - if ((num & TIC80_OPERAND_M_SI) - && (flags & TIC80_OPERAND_M_SI)) - insn[0] = insn[0] | (1 << 17); - else if ((num & TIC80_OPERAND_M_LI) - && (flags & TIC80_OPERAND_M_LI)) - insn[0] = insn[0] | (1 << 15); - else if ((num & TIC80_OPERAND_SCALED) - && (flags & TIC80_OPERAND_SCALED)) - insn[0] = insn[0] | (1 << 11); - else if ((num & TIC80_OPERAND_PARENS) - && (flags & TIC80_OPERAND_PARENS)) - /* No code to generate, just accept and discard this - expression. */ - ; - else - internal_error_a (_("unhandled operand modifier"), - (long) opers[expi].X_add_number); - break; - - case O_big: - fx = frag_more (4); - fxfrag = frag_now; - - { - int precision = 2; - long exponent_bits = 8L; - LITTLENUM_TYPE words[2]; - - /* Value is still in generic_floating_point_number. */ - gen_to_words (words, precision, exponent_bits); - insn[1] = (words[0] << 16) | words[1]; - } - break; - - case O_illegal: - case O_symbol_rva: - case O_uminus: - case O_bit_not: - case O_logical_not: - case O_multiply: - case O_divide: - case O_modulus: - case O_left_shift: - case O_right_shift: - case O_bit_inclusive_or: - case O_bit_or_not: - case O_bit_exclusive_or: - case O_bit_and: - case O_add: - case O_subtract: - case O_eq: - case O_ne: - case O_lt: - case O_le: - case O_ge: - case O_gt: - case O_logical_and: - case O_logical_or: - case O_max: - default: - internal_error_a (_("unhandled expression"), (long) X_op); - break; - } - } - - /* Write out the instruction, either 4 or 8 bytes. */ - - md_number_to_chars (f, insn[0], 4); - if (fx != NULL) - md_number_to_chars (fx, insn[1], 4); -} - -/* This is the main entry point for the machine-dependent assembler. Gas - calls this function for each input line which does not contain a - pseudoop. - - STR points to a NULL terminated machine dependent instruction. This - function is supposed to emit the frags/bytes it assembles to. */ - -void -md_assemble (char *str) -{ - char *scan; - char *input_line_save; - struct tic80_opcode *opcode; - expressionS myops[16]; - - /* Ensure there is something there to assemble. */ - assert (str); - - /* Drop any leading whitespace. */ - while (ISSPACE (*str)) - str++; - - /* Isolate the mnemonic from the rest of the string by finding the first - whitespace character and zapping it to a null byte. */ - for (scan = str; *scan != '\000' && !ISSPACE (*scan); scan++) - ; - - if (*scan != '\000') - *scan++ = '\000'; - - /* Try to find this mnemonic in the hash table. */ - if ((opcode = (struct tic80_opcode *) hash_find (tic80_hash, str)) == NULL) - { - as_bad (_("Invalid mnemonic: '%s'"), str); - return; - } - - str = scan; - while (ISSPACE (*scan)) - scan++; - - input_line_save = input_line_pointer; - input_line_pointer = str; - - opcode = find_opcode (opcode, myops); - if (opcode == NULL) - as_bad (_("Invalid operands: '%s'"), input_line_save); - - input_line_pointer = input_line_save; - build_insn (opcode, myops); -} - -/* This function is called once at the start of assembly, after the command - line arguments have been parsed and all the machine independent - initializations have been completed. - - It should set up all the tables, etc., that the machine dependent part of - the assembler will need. */ - -void -md_begin (void) -{ - char *prev_name = ""; - register const struct tic80_opcode *op; - register const struct tic80_opcode *op_end; - const struct predefined_symbol *pdsp; - extern int coff_flags; /* Defined in obj-coff.c */ - - /* Set F_AR32WR in coff_flags, which will end up in the file header - f_flags field. */ - - coff_flags |= F_AR32WR; /* TIc80 is 32 bit little endian. */ - - /* Insert unique names into hash table. The TIc80 instruction set - has many identical opcode names that have different opcodes based - on the operands. This hash table then provides a quick index to - the first opcode with a particular name in the opcode table. */ - - tic80_hash = hash_new (); - op_end = tic80_opcodes + tic80_num_opcodes; - for (op = tic80_opcodes; op < op_end; op++) - { - if (strcmp (prev_name, op->name) != 0) - { - prev_name = (char *) op->name; - hash_insert (tic80_hash, op->name, (char *) op); - } - } - - /* Insert the predefined symbols into the symbol table. We use - symbol_create rather than symbol_new so that these symbols don't - end up in the object files' symbol table. Note that the values - of the predefined symbols include some upper bits that - distinguish the type of the symbol (register, bitnum, condition - code, etc) and these bits must be masked away before actually - inserting the values into the instruction stream. For registers - we put these bits in the symbol table since we use them later and - there is no question that they aren't part of the register - number. For constants we can't do that since the constant can be - any value, so they are masked off before putting them into the - symbol table. */ - - pdsp = NULL; - while ((pdsp = tic80_next_predefined_symbol (pdsp)) != NULL) - { - segT segment; - valueT valu; - int symtype; - - symtype = PDS_VALUE (pdsp) & TIC80_OPERAND_MASK; - switch (symtype) - { - case TIC80_OPERAND_GPR: - case TIC80_OPERAND_FPA: - case TIC80_OPERAND_CR: - segment = reg_section; - valu = PDS_VALUE (pdsp); - break; - case TIC80_OPERAND_CC: - case TIC80_OPERAND_BITNUM: - segment = absolute_section; - valu = PDS_VALUE (pdsp) & ~TIC80_OPERAND_MASK; - break; - default: - internal_error_a (_("unhandled predefined symbol bits"), - (long) symtype); - break; - } - symbol_table_insert (symbol_create (PDS_NAME (pdsp), segment, valu, - &zero_address_frag)); - } -} - -/* The assembler adds md_shortopts to the string passed to getopt. */ - -const char *md_shortopts = ""; - -/* The assembler adds md_longopts to the machine independent long options - that are passed to getopt. */ - -struct option md_longopts[] = -{ -#define OPTION_RELAX (OPTION_MD_BASE) - {"relax", no_argument, NULL, OPTION_RELAX}, - -#define OPTION_NO_RELAX (OPTION_RELAX + 1) - {"no-relax", no_argument, NULL, OPTION_NO_RELAX}, - - {NULL, no_argument, NULL, 0} -}; - -size_t md_longopts_size = sizeof (md_longopts); - -/* The md_parse_option function will be called whenever getopt returns an - unrecognized code, presumably indicating a special code value which - appears in md_longopts for machine specific command line options. */ - -int -md_parse_option (int c, char *arg ATTRIBUTE_UNUSED) -{ - switch (c) - { - case OPTION_RELAX: - tic80_relax = 1; - break; - case OPTION_NO_RELAX: - tic80_relax = 0; - break; - default: - return 0; - } - return 1; -} - -/* The md_show_usage function will be called whenever a usage message is - printed. It should print a description of the machine specific options - found in md_longopts. */ - -void -md_show_usage (FILE *stream) -{ - fprintf (stream, "\ -TIc80 options:\n\ --relax alter PC relative branch instructions to use long form when needed\n\ --no-relax always use short PC relative branch instructions, error on overflow\n"); -} - -/* Attempt to simplify or even eliminate a fixup. The return value is - ignored; perhaps it was once meaningful, but now it is historical. - To indicate that a fixup has been eliminated, set fixP->fx_done. */ - -void -md_apply_fix (fixS *fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED) -{ - long val = * (long *) valP; - char *dest = fixP->fx_frag->fr_literal + fixP->fx_where; - int overflow; - - switch (fixP->fx_r_type) - { - case R_RELLONGX: - md_number_to_chars (dest, (valueT) val, 4); - break; - case R_MPPCR: - val >>= 2; - val += 1; /* Target address computed from inst start. */ - md_number_to_chars (dest, (valueT) val, 4); - break; - case R_MPPCR15W: - overflow = (val < -65536L) || (val > 65532L); - if (overflow) - as_bad_where (fixP->fx_file, fixP->fx_line, - _("PC offset 0x%lx outside range 0x%lx-0x%lx"), - val, -65536L, 65532L); - else - { - val >>= 2; - *dest++ = val & 0xFF; - val >>= 8; - *dest = (*dest & 0x80) | (val & 0x7F); - } - break; - - case R_ABS: - md_number_to_chars (dest, (valueT) val, fixP->fx_size); - break; - - default: - internal_error_a (_("unhandled relocation type in fixup"), - (long) fixP->fx_r_type); - break; - } - - if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0) - fixP->fx_done = 1; -} - -/* Functions concerning relocs. */ - -/* The location from which a PC relative jump should be calculated, - given a PC relative reloc. - - For the TIc80, this is the address of the 32 bit opcode containing - the PC relative field. */ - -long -md_pcrel_from (fixS *fixP) -{ - return (fixP->fx_frag->fr_address + fixP->fx_where); -} - -/* Called after relax() is finished. - In: Address of frag. - fr_type == rs_machine_dependent. - fr_subtype is what the address relaxed to. - - Out: Any fixSs and constants are set up. - Caller will turn frag into a ".space 0". */ - -void -md_convert_frag (object_headers *headers ATTRIBUTE_UNUSED, - segT seg ATTRIBUTE_UNUSED, - fragS *fragP ATTRIBUTE_UNUSED) -{ - internal_error (_("md_convert_frag() not implemented yet")); - abort (); -} - -void -tc_coff_symbol_emit_hook (symbolS *ignore ATTRIBUTE_UNUSED) -{ -} - -#if defined OBJ_COFF - -short -tc_coff_fix2rtype (fixS *fixP) -{ - return (fixP->fx_r_type); -} - -#endif /* OBJ_COFF */ diff --git a/gas/config/tc-tic80.h b/gas/config/tc-tic80.h deleted file mode 100644 index e830748..0000000 --- a/gas/config/tc-tic80.h +++ /dev/null @@ -1,61 +0,0 @@ -/* This file is tc-tic80.h - Copyright 1996, 1997, 2000, 2002, 2005 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -#define TC_TIC80 - -#define TARGET_BYTES_BIG_ENDIAN 0 - -#define TARGET_ARCH bfd_arch_tic80 -#define TARGET_FORMAT "coff-tic80" -#define BFD_ARCH TARGET_ARCH - -/* We need the extra field in the fixup struct to put the relocation in. */ - -#define NEED_FX_R_TYPE - -/* Define md_number_to_chars as the appropriate standard big endian or - little endian function. Should we someday support endianness as a - runtime decision, this will need to change. */ - -#define md_number_to_chars number_to_chars_littleendian - -/* Define away the call to md_operand in the expression parsing code. - This is called whenever the expression parser can't parse the input - and gives the assembler backend a chance to deal with it instead. */ - -#define md_operand(x) - -#ifdef OBJ_COFF - -/* COFF specific definitions. */ - -#define COFF_MAGIC TIC80_ARCH_MAGIC - -/* Whether a reloc should be output. */ - -#define TC_COUNT_RELOC(fixp) ((fixp) -> fx_addsy != NULL) - -/* This macro translates between an internal fix and a coff reloc type. */ - -#define TC_COFF_FIX2RTYPE(fixP) tc_coff_fix2rtype(fixP) - -extern short tc_coff_fix2rtype (struct fix *); - -#endif /* OBJ_COFF */ diff --git a/gas/config/tc-v850.h b/gas/config/tc-v850.h index 639971e..f9ec804 100644 --- a/gas/config/tc-v850.h +++ b/gas/config/tc-v850.h @@ -25,10 +25,6 @@ #define TARGET_BYTES_BIG_ENDIAN 0 -#ifndef BFD_ASSEMBLER - #error V850 support requires BFD_ASSEMBLER -#endif - /* The target BFD architecture. */ #define TARGET_ARCH bfd_arch_v850 diff --git a/gas/config/tc-vax.c b/gas/config/tc-vax.c index 0e0fbfa..bd09752 100644 --- a/gas/config/tc-vax.c +++ b/gas/config/tc-vax.c @@ -30,10 +30,6 @@ #include "elf/vax.h" #endif -#if defined (OBJ_AOUT) && !defined (BFD_ASSEMBLER) && defined (TE_NetBSD) -#include <netinet/in.h> -#endif - /* These chars start a comment anywhere in a source file (except inside another comment */ const char comment_chars[] = "#"; @@ -322,12 +318,11 @@ md_apply_fix (fixP, valueP, seg) segT seg ATTRIBUTE_UNUSED; { valueT value = * valueP; -#ifdef BFD_ASSEMBLER + if (((fixP->fx_addsy == NULL && fixP->fx_subsy == NULL) && fixP->fx_r_type != BFD_RELOC_32_PLT_PCREL && fixP->fx_r_type != BFD_RELOC_32_GOT_PCREL) || fixP->fx_r_type == NO_RELOC) -#endif number_to_chars_littleendian (fixP->fx_where + fixP->fx_frag->fr_literal, value, fixP->fx_size); @@ -751,13 +746,8 @@ md_assemble (instruction_string) this_add_number = expP->X_add_number; this_add_symbol = expP->X_add_symbol; to_seg = *segP; -#ifdef BFD_ASSEMBLER is_undefined = (to_seg == undefined_section); is_absolute = (to_seg == absolute_section); -#else - is_undefined = (to_seg == SEG_UNKNOWN); - is_absolute = (to_seg == SEG_ABSOLUTE); -#endif at = operandP->vop_mode & 1; length = (operandP->vop_short == 'b' ? 1 : (operandP->vop_short == 'w' @@ -834,11 +824,7 @@ md_assemble (instruction_string) p = frag_more (nbytes); /* Conventional relocation. */ fix_new (frag_now, p - frag_now->fr_literal, nbytes, -#ifdef BFD_ASSEMBLER section_symbol (absolute_section), -#else - &abs_symbol, -#endif this_add_number, 1, NO_RELOC); } else @@ -922,11 +908,7 @@ md_assemble (instruction_string) know (!(opcode_as_number & VIT_OPCODE_SYNTHETIC)); p = frag_more (nbytes); fix_new (frag_now, p - frag_now->fr_literal, nbytes, -#ifdef BFD_ASSEMBLER section_symbol (absolute_section), -#else - &abs_symbol, -#endif this_add_number, 1, NO_RELOC); } else @@ -1442,19 +1424,11 @@ md_estimate_size_before_relax (fragP, segment) * Out: Any fixSs and constants are set up. * Caller will turn frag into a ".space 0". */ -#ifdef BFD_ASSEMBLER void md_convert_frag (headers, seg, fragP) bfd *headers ATTRIBUTE_UNUSED; segT seg ATTRIBUTE_UNUSED; fragS *fragP; -#else -void -md_convert_frag (headers, seg, fragP) - object_headers *headers ATTRIBUTE_UNUSED; - segT seg ATTRIBUTE_UNUSED; - fragS *fragP; -#endif { char *addressP; /* -> _var to change. */ char *opcodeP; /* -> opcode char(s) to change. */ @@ -1619,42 +1593,6 @@ md_ri_to_chars (the_bytes, ri) #endif /* comment */ -#ifdef OBJ_AOUT -#ifndef BFD_ASSEMBLER -void -tc_aout_fix_to_chars (where, fixP, segment_address_in_file) - char *where; - fixS *fixP; - relax_addressT segment_address_in_file; -{ - /* - * In: length of relocation (or of address) in chars: 1, 2 or 4. - * Out: GNU LD relocation length code: 0, 1, or 2. - */ - - static const unsigned char nbytes_r_length[] = {42, 0, 1, 42, 2}; - long r_symbolnum; - - know (fixP->fx_addsy != NULL); - - md_number_to_chars (where, - fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file, - 4); - - r_symbolnum = (S_IS_DEFINED (fixP->fx_addsy) - ? S_GET_TYPE (fixP->fx_addsy) - : fixP->fx_addsy->sy_number); - - where[6] = (r_symbolnum >> 16) & 0x0ff; - where[5] = (r_symbolnum >> 8) & 0x0ff; - where[4] = r_symbolnum & 0x0ff; - where[7] = ((((!S_IS_DEFINED (fixP->fx_addsy)) << 3) & 0x08) - | ((nbytes_r_length[fixP->fx_size] << 1) & 0x06) - | (((fixP->fx_pcrel << 0) & 0x01) & 0x0f)); -} -#endif /* !BFD_ASSEMBLER */ -#endif /* OBJ_AOUT */ - /* * BUGS, GRIPES, APOLOGIA, etc. * @@ -3279,7 +3217,6 @@ mumble (text, value) int md_short_jump_size = 3; int md_long_jump_size = 6; -const int md_reloc_size = 8; /* Size of relocation record */ void md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol) @@ -3462,21 +3399,6 @@ md_pcrel_from (fixP) return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address; } -#ifdef OBJ_AOUT -#ifndef BFD_ASSEMBLER -void -tc_headers_hook(headers) - object_headers *headers; -{ -#ifdef TE_NetBSD - N_SET_INFO(headers->header, OMAGIC, M_VAX4K_NETBSD, 0); - headers->header.a_info = htonl (headers->header.a_info); -#endif -} -#endif /* !BFD_ASSEMBLER */ -#endif /* OBJ_AOUT */ - -#ifdef BFD_ASSEMBLER arelent * tc_gen_reloc (section, fixp) asection *section ATTRIBUTE_UNUSED; @@ -3552,6 +3474,5 @@ tc_gen_reloc (section, fixp) return reloc; } -#endif /* BFD_ASSEMBLER */ /* end of tc-vax.c */ diff --git a/gas/config/tc-vax.h b/gas/config/tc-vax.h index fdf23f6..10294c9 100644 --- a/gas/config/tc-vax.h +++ b/gas/config/tc-vax.h @@ -1,5 +1,5 @@ /* tc-vax.h -- Header file for tc-vax.c. - Copyright 1987, 1991, 1992, 1993, 1995, 1996, 1997, 2000, 2002 + Copyright 1987, 1991, 1992, 1993, 1995, 1996, 1997, 2000, 2002, 2005 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -40,18 +40,11 @@ #define TARGET_FORMAT "elf32-vax" #endif -#define BFD_ARCH bfd_arch_vax /* for non-BFD_ASSEMBLER */ -#define TARGET_ARCH bfd_arch_vax /* BFD_ASSEMBLER */ +#define TARGET_ARCH bfd_arch_vax -#ifdef BFD_ASSEMBLER #define NO_RELOC BFD_RELOC_NONE -#else -#define NO_RELOC 0 -#endif #define NOP_OPCODE 0x01 -#define tc_aout_pre_write_hook(x) {;} /* not used */ -#define tc_crawl_symbol_chain(a) {;} /* not used */ #define md_operand(x) long md_chars_to_number PARAMS ((unsigned char *, int)); @@ -59,7 +52,6 @@ long md_chars_to_number PARAMS ((unsigned char *, int)); extern const struct relax_type md_relax_table[]; #define TC_GENERIC_RELAX_TABLE md_relax_table -#ifdef BFD_ASSEMBLER /* Values passed to md_apply_fix don't include symbol values. */ #define MD_APPLY_SYM_VALUE(FIX) 0 @@ -73,7 +65,6 @@ extern const struct relax_type md_relax_table[]; && (S_GET_SEGMENT ((FIX)->fx_subsy) \ == S_GET_SEGMENT ((FIX)->fx_addsy))) \ || S_IS_LOCAL ((FIX)->fx_addsy))) -#endif /* * Local Variables: diff --git a/gas/config/tc-w65.c b/gas/config/tc-w65.c deleted file mode 100644 index 05c95dc..0000000 --- a/gas/config/tc-w65.c +++ /dev/null @@ -1,1080 +0,0 @@ -/* tc-w65.c -- Assemble code for the W65816 - Copyright 1995, 1998, 2000, 2001, 2002, 2005 - 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -/* Written By Steve Chamberlain <sac@cygnus.com>. */ - -#include <stdio.h> -#include "as.h" -#include "bfd.h" -#include "subsegs.h" -#define DEFINE_TABLE -#include "../opcodes/w65-opc.h" - -const char comment_chars[] = "!"; -const char line_separator_chars[] = ";"; -const char line_comment_chars[] = "!#"; - -/* This table describes all the machine specific pseudo-ops the assembler - has to support. The fields are: - - pseudo-op name without dot - function to call to execute this pseudo-op - Integer arg to pass to the function. */ - -#define OP_BCC 0x90 -#define OP_BCS 0xB0 -#define OP_BEQ 0xF0 -#define OP_BMI 0x30 -#define OP_BNE 0xD0 -#define OP_BPL 0x10 -#define OP_BRA 0x80 -#define OP_BRL 0x82 -#define OP_BVC 0x50 -#define OP_BVS 0x70 - -static int M; /* M flag. */ -static int X; /* X flag. */ - -/* This function is called once, at assembler startup time. This - should set up all the tables, etc that the MD part of the assembler - needs. */ - -static void -s_longa (int xmode) -{ - int *p = xmode ? &X : &M; - - while (*input_line_pointer == ' ') - input_line_pointer++; - if (strncmp (input_line_pointer, "on", 2) == 0) - { - input_line_pointer += 2; - *p = 0; - } - else if (strncmp (input_line_pointer, "off", 3) == 0) - { - *p = 1; - input_line_pointer += 3; - } - else - as_bad (_("need on or off.")); - demand_empty_rest_of_line (); -} - -const pseudo_typeS md_pseudo_table[] = -{ - {"int", cons, 2}, - {"word", cons, 2}, - {"longa", s_longa, 0}, - {"longi", s_longa, 1}, - {0, 0, 0} -}; - -const char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant. */ -/* As in 0f12.456 */ -/* or 0d1.2345e12 */ -const char FLT_CHARS[] = "rRsSfFdDxXpP"; - -/* Opcode mnemonics */ -static struct hash_control *opcode_hash_control; - -#define C(a, b) ENCODE_RELAX(a,b) -#define ENCODE_RELAX(what, length) (((what) << 2) + (length)) - -#define GET_WHAT(x) (((x) >> 2)) - -#define BYTE_DISP 1 -#define WORD_DISP 2 -#define UNDEF_BYTE_DISP 0 -#define UNDEF_WORD_DISP 3 -#define COND_BRANCH 1 -#define UNCOND_BRANCH 2 -#define END 3 - -#define BYTE_F 127 /* How far we can branch forwards. */ -#define BYTE_B -126 /* How far we can branch backwards. */ -#define WORD_F 32767 -#define WORD_B 32768 - -relax_typeS md_relax_table[C (END, 0)] = -{ - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - - /* COND_BRANCH */ - { 0, 0, 0, 0 }, /* UNDEF_BYTE_DISP */ - { BYTE_F, BYTE_B, 2, C (COND_BRANCH, WORD_DISP) }, /* BYTE_DISP */ - { WORD_F, WORD_B, 5, 0 }, /* WORD_DISP */ - { 0, 0, 5, 0 }, /* UNDEF_WORD_DISP */ - - /* UNCOND_BRANCH */ - { 0, 0, 0, 0 }, /* UNDEF_BYTE_DISP */ - { BYTE_F, BYTE_B, 2, C (UNCOND_BRANCH, WORD_DISP) }, /* BYTE_DISP */ - { WORD_F, WORD_B, 3, 0 }, /* WORD_DISP */ - { 0, 0, 3, 0 } /* UNDEF_WORD_DISP */ -}; - -void -md_begin (void) -{ - const struct opinfo *opcode; - char *prev_name = ""; - - opcode_hash_control = hash_new (); - - /* Insert unique names into hash table. */ - for (opcode = optable; opcode->name; opcode++) - { - if (strcmp (prev_name, opcode->name)) - { - prev_name = opcode->name; - hash_insert (opcode_hash_control, opcode->name, (char *) opcode); - } - } - - flag_signed_overflow_ok = 1; -} - -static expressionS immediate; /* Absolute expression. */ -static expressionS immediate1; /* Absolute expression. */ -int expr_size; -int expr_shift; -int tc_cons_reloc; - -void -w65_expression (expressionS *dest) -{ - expr_size = 0; - expr_shift = 0; - tc_cons_reloc = 0; - while (*input_line_pointer == ' ') - input_line_pointer++; - - if (*input_line_pointer == '<') - { - expr_size = 1; - input_line_pointer++; - } - else if (*input_line_pointer == '>') - { - expr_shift = 1; - input_line_pointer++; - } - else if (*input_line_pointer == '^') - { - expr_shift = 2; - input_line_pointer++; - } - - expr (0, dest); -} - -int amode; - -static char * -parse_exp (char *s) -{ - char *save; - char *new; - - save = input_line_pointer; - input_line_pointer = s; - w65_expression (&immediate); - if (immediate.X_op == O_absent) - as_bad (_("missing operand")); - new = input_line_pointer; - input_line_pointer = save; - return new; -} - -static char * -get_operands (const struct opinfo *info, char *ptr) -{ - int override_len = 0; - int bytes = 0; - - while (*ptr == ' ') - ptr++; - - if (ptr[0] == '#') - { - ptr++; - switch (info->amode) - { - case ADDR_IMMTOI: - bytes = X ? 1 : 2; - amode = ADDR_IMMTOI; - break; - case ADDR_IMMTOA: - bytes = M ? 1 : 2; - amode = ADDR_IMMTOA; - break; - case ADDR_IMMCOP: - bytes = 1; - amode = ADDR_IMMCOP; - break; - case ADDR_DIR: - bytes = 2; - amode = ADDR_ABS; - break; - default: - abort (); - break; - } - ptr = parse_exp (ptr); - } - else if (ptr[0] == '!') - { - ptr = parse_exp (ptr + 1); - if (ptr[0] == ',') - { - if (ptr[1] == 'y') - { - amode = ADDR_ABS_IDX_Y; - bytes = 2; - ptr += 2; - } - else if (ptr[1] == 'x') - { - amode = ADDR_ABS_IDX_X; - bytes = 2; - ptr += 2; - } - else - as_bad (_("syntax error after <exp")); - } - else - { - amode = ADDR_ABS; - bytes = 2; - } - } - else if (ptr[0] == '>') - { - ptr = parse_exp (ptr + 1); - if (ptr[0] == ',' && ptr[1] == 'x') - { - amode = ADDR_ABS_LONG_IDX_X; - bytes = 3; - ptr += 2; - } - else - { - amode = ADDR_ABS_LONG; - bytes = 3; - } - } - else if (ptr[0] == '<') - { - ptr = parse_exp (ptr + 1); - if (ptr[0] == ',') - { - if (ptr[1] == 'y') - { - amode = ADDR_DIR_IDX_Y; - ptr += 2; - bytes = 2; - } - else if (ptr[1] == 'x') - { - amode = ADDR_DIR_IDX_X; - ptr += 2; - bytes = 2; - } - else - as_bad (_("syntax error after <exp")); - } - else - { - amode = ADDR_DIR; - bytes = 1; - } - } - else if (ptr[0] == 'a') - amode = ADDR_ACC; - else if (ptr[0] == '(') - { - /* Look for (exp),y - (<exp),y - (exp,x) - (<exp,x) - (exp) - (!exp) - (exp) - (<exp) - (exp,x) - (!exp,x) - (exp,s) - (exp,s),y */ - - ptr++; - if (ptr[0] == '<') - { - override_len = 1; - ptr++; - } - else if (ptr[0] == '!') - { - override_len = 2; - ptr++; - } - else if (ptr[0] == '>') - { - override_len = 3; - ptr++; - } - else - override_len = 0; - - ptr = parse_exp (ptr); - - if (ptr[0] == ',') - { - ptr++; - if (ptr[0] == 'x' && ptr[1] == ')') - { - ptr += 2; - - if (override_len == 1) - { - amode = ADDR_DIR_IDX_IND_X; - bytes = 2; - } - else - { - amode = ADDR_ABS_IND_IDX; - bytes = 2; - } - } - else if (ptr[0] == 's' && ptr[1] == ')' - && ptr[2] == ',' && ptr[3] == 'y') - { - amode = ADDR_STACK_REL_INDX_IDX; - bytes = 1; - ptr += 4; - } - } - else if (ptr[0] == ')') - { - if (ptr[1] == ',' && ptr[2] == 'y') - { - amode = ADDR_DIR_IND_IDX_Y; - ptr += 3; - bytes = 2; - } - else - { - if (override_len == 1) - { - amode = ADDR_DIR_IND; - bytes = 1; - } - else - { - amode = ADDR_ABS_IND; - bytes = 2; - } - ptr++; - } - } - } - else if (ptr[0] == '[') - { - ptr = parse_exp (ptr + 1); - - if (ptr[0] == ']') - { - ptr++; - if (ptr[0] == ',' && ptr[1] == 'y') - { - bytes = 1; - amode = ADDR_DIR_IND_IDX_Y_LONG; - ptr += 2; - } - else - { - if (info->code == O_jmp) - { - bytes = 2; - amode = ADDR_ABS_IND_LONG; - } - else - { - bytes = 1; - amode = ADDR_DIR_IND_LONG; - } - } - } - } - else - { - ptr = parse_exp (ptr); - if (ptr[0] == ',') - { - if (ptr[1] == 'y') - { - if (override_len == 1) - { - bytes = 1; - amode = ADDR_DIR_IDX_Y; - } - else - { - amode = ADDR_ABS_IDX_Y; - bytes = 2; - } - ptr += 2; - } - else if (ptr[1] == 'x') - { - if (override_len == 1) - { - amode = ADDR_DIR_IDX_X; - bytes = 1; - } - else - { - amode = ADDR_ABS_IDX_X; - bytes = 2; - } - ptr += 2; - } - else if (ptr[1] == 's') - { - bytes = 1; - amode = ADDR_STACK_REL; - ptr += 2; - } - else - { - bytes = 1; - immediate1 = immediate; - ptr = parse_exp (ptr + 1); - amode = ADDR_BLOCK_MOVE; - } - } - else - { - switch (info->amode) - { - case ADDR_PC_REL: - amode = ADDR_PC_REL; - bytes = 1; - break; - case ADDR_PC_REL_LONG: - amode = ADDR_PC_REL_LONG; - bytes = 2; - break; - default: - if (override_len == 1) - { - amode = ADDR_DIR; - bytes = 1; - } - else if (override_len == 3) - { - bytes = 3; - amode = ADDR_ABS_LONG; - } - else - { - amode = ADDR_ABS; - bytes = 2; - } - } - } - } - - switch (bytes) - { - case 1: - switch (expr_shift) - { - case 0: - if (amode == ADDR_DIR) - tc_cons_reloc = R_W65_DP; - else - tc_cons_reloc = R_W65_ABS8; - break; - case 1: - tc_cons_reloc = R_W65_ABS8S8; - break; - case 2: - tc_cons_reloc = R_W65_ABS8S16; - break; - } - break; - case 2: - switch (expr_shift) - { - case 0: - tc_cons_reloc = R_W65_ABS16; - break; - case 1: - tc_cons_reloc = R_W65_ABS16S8; - break; - case 2: - tc_cons_reloc = R_W65_ABS16S16; - break; - } - } - return ptr; -} - -/* Passed a pointer to a list of opcodes which use different - addressing modes, return the opcode which matches the opcodes - provided. */ - -static const struct opinfo * -get_specific (const struct opinfo *opcode) -{ - int ocode = opcode->code; - - for (; opcode->code == ocode; opcode++) - if (opcode->amode == amode) - return opcode; - - return 0; -} - -/* Now we know what sort of opcodes it is, let's build the bytes. */ - -static void -build_Mytes (const struct opinfo *opcode) -{ - int size; - int type; - int pcrel; - char *output; - - if (opcode->amode == ADDR_IMPLIED) - output = frag_more (1); - - else if (opcode->amode == ADDR_PC_REL) - { - int type; - - /* This is a relaxable insn, so we do some special handling. */ - type = opcode->val == OP_BRA ? UNCOND_BRANCH : COND_BRANCH; - output = frag_var (rs_machine_dependent, - md_relax_table[C (type, WORD_DISP)].rlx_length, - md_relax_table[C (type, BYTE_DISP)].rlx_length, - C (type, UNDEF_BYTE_DISP), - immediate.X_add_symbol, - immediate.X_add_number, - 0); - } - else - { - switch (opcode->amode) - { - GETINFO (size, type, pcrel); - default: - abort (); - } - - /* If something special was done in the expression modify the - reloc type. */ - if (tc_cons_reloc) - type = tc_cons_reloc; - - /* 1 byte for the opcode + the bytes for the addrmode. */ - output = frag_more (size + 1); - - if (opcode->amode == ADDR_BLOCK_MOVE) - { - /* Two relocs for this one. */ - fix_new_exp (frag_now, - output + 1 - frag_now->fr_literal, - 1, - &immediate, - 0, - R_W65_ABS8S16); - - fix_new_exp (frag_now, - output + 2 - frag_now->fr_literal, - 1, - &immediate1, - 0, - R_W65_ABS8S16); - } - else if (type >= 0 - && opcode->amode != ADDR_IMPLIED - && opcode->amode != ADDR_ACC - && opcode->amode != ADDR_STACK) - { - fix_new_exp (frag_now, - output + 1 - frag_now->fr_literal, - size, - &immediate, - pcrel, - type); - } - } - output[0] = opcode->val; -} - -/* This is the guts of the machine-dependent assembler. STR points to - a machine dependent instruction. This function is supposed to emit - the frags/bytes it assembles to. */ - -void -md_assemble (char *str) -{ - const struct opinfo *opcode; - char name[20]; - - /* Drop leading whitespace */ - while (*str == ' ') - str++; - - /* All opcodes are three letters. */ - name[0] = str[0]; - name[1] = str[1]; - name[2] = str[2]; - name[3] = 0; - - tc_cons_reloc = 0; - str += 3; - opcode = (struct opinfo *) hash_find (opcode_hash_control, name); - - if (opcode == NULL) - { - as_bad (_("unknown opcode")); - return; - } - - if (opcode->amode != ADDR_IMPLIED - && opcode->amode != ADDR_STACK) - { - get_operands (opcode, str); - opcode = get_specific (opcode); - } - - if (opcode == 0) - { - /* Couldn't find an opcode which matched the operands. */ - - char *where = frag_more (1); - - where[0] = 0x0; - where[1] = 0x0; - as_bad (_("invalid operands for opcode")); - return; - } - - build_Mytes (opcode); -} - -symbolS * -md_undefined_symbol (char *name ATTRIBUTE_UNUSED) -{ - return 0; -} - -/* Various routines to kill one day. */ -/* Equal to MAX_PRECISION in atof-ieee.c. */ -#define MAX_LITTLENUMS 6 - -/* Turn a string in input_line_pointer into a floating point constant - of type TYPE, and store the appropriate bytes in *LITP. The number - of LITTLENUMS emitted is stored in *SIZEP. An error message is - returned, or NULL on OK. */ - -char * -md_atof (int type, char *litP, int *sizeP) -{ - int prec; - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - char *t; - - switch (type) - { - case 'f': - case 'F': - case 's': - case 'S': - prec = 2; - break; - - case 'd': - case 'D': - case 'r': - case 'R': - prec = 4; - break; - - case 'x': - case 'X': - prec = 6; - break; - - case 'p': - case 'P': - prec = 6; - break; - - default: - *sizeP = 0; - return _("Bad call to MD_NTOF()"); - } - t = atof_ieee (input_line_pointer, type, words); - if (t) - input_line_pointer = t; - - *sizeP = prec * sizeof (LITTLENUM_TYPE); - for (wordP = words + prec - 1; prec--;) - { - md_number_to_chars (litP, (valueT) (*wordP--), sizeof (LITTLENUM_TYPE)); - litP += sizeof (LITTLENUM_TYPE); - } - return 0; -} - -int -md_parse_option (int c ATTRIBUTE_UNUSED, char *a ATTRIBUTE_UNUSED) -{ - return 0; -} - -/* Called after relaxing, change the frags so they know how big they - are. */ - -void -md_convert_frag (object_headers *headers ATTRIBUTE_UNUSED, - segT seg ATTRIBUTE_UNUSED, - fragS *fragP) -{ - int disp_size = 0; - int inst_size = 0; - unsigned char *buffer = - (unsigned char *) (fragP->fr_fix + fragP->fr_literal); - - switch (fragP->fr_subtype) - { - case C (COND_BRANCH, BYTE_DISP): - case C (UNCOND_BRANCH, BYTE_DISP): - disp_size = 1; - inst_size = 1; - break; - - /* Conditional branches to a known 16 bit displacement. */ - case C (COND_BRANCH, WORD_DISP): - switch (buffer[0]) - { - case OP_BCC: - case OP_BCS: - case OP_BEQ: - case OP_BMI: - case OP_BNE: - case OP_BPL: - case OP_BVS: - case OP_BVC: - /* Invert the sense of the test. */ - buffer[0] ^= 0x20; - buffer[1] = 3; /* Jump over following brl. */ - buffer[2] = OP_BRL; - buffer[3] = 0; - buffer[4] = 0; - disp_size = 2; - inst_size = 3; - break; - default: - abort (); - } - break; - case C (UNCOND_BRANCH, WORD_DISP): - /* Unconditional branches to a known 16 bit displacement. */ - - switch (buffer[0]) - { - case OP_BRA: - buffer[0] = OP_BRL; - disp_size = 2; - inst_size = 1; - break; - default: - abort (); - } - break; - /* Got to create a branch over a reloc here. */ - case C (COND_BRANCH, UNDEF_WORD_DISP): - buffer[0] ^= 0x20; /* Invert test. */ - buffer[1] = 3; - buffer[2] = OP_BRL; - buffer[3] = 0; - buffer[4] = 0; - fix_new (fragP, - fragP->fr_fix + 3, - 4, - fragP->fr_symbol, - fragP->fr_offset, - 0, - R_W65_PCR16); - - fragP->fr_fix += disp_size + inst_size; - fragP->fr_var = 0; - break; - case C (UNCOND_BRANCH, UNDEF_WORD_DISP): - buffer[0] = OP_BRL; - buffer[1] = 0; - buffer[2] = 0; - fix_new (fragP, - fragP->fr_fix + 1, - 4, - fragP->fr_symbol, - fragP->fr_offset, - 0, - R_W65_PCR16); - - fragP->fr_fix += disp_size + inst_size; - fragP->fr_var = 0; - break; - default: - abort (); - } - if (inst_size) - { - /* Get the address of the end of the instruction. */ - int next_inst = (fragP->fr_fix + fragP->fr_address - + disp_size + inst_size); - int targ_addr = (S_GET_VALUE (fragP->fr_symbol) + - fragP->fr_offset); - int disp = targ_addr - next_inst; - - md_number_to_chars ((char *) buffer + inst_size, disp, disp_size); - fragP->fr_fix += disp_size + inst_size; - fragP->fr_var = 0; - } -} - -valueT -md_section_align (segT seg, valueT size) -{ - return ((size + (1 << section_alignment[(int) seg]) - 1) - & (-1 << section_alignment[(int) seg])); -} - -void -md_apply_fix (fixS *fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED) -{ - long val = * (long *) valP; - char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; - int addr = fixP->fx_frag->fr_address + fixP->fx_where; - - if (fixP->fx_r_type == 0) - { - if (fixP->fx_size == 1) - fixP->fx_r_type = R_W65_ABS8; - else - fixP->fx_r_type = R_W65_ABS16; - } - - switch (fixP->fx_r_type) - { - case R_W65_ABS8S16: - val >>= 8; - case R_W65_ABS8S8: - val >>= 8; - case R_W65_ABS8: - *buf++ = val; - break; - case R_W65_ABS16S16: - val >>= 8; - case R_W65_ABS16S8: - val >>= 8; - case R_W65_ABS16: - *buf++ = val >> 0; - *buf++ = val >> 8; - break; - case R_W65_ABS24: - *buf++ = val >> 0; - *buf++ = val >> 8; - *buf++ = val >> 16; - break; - case R_W65_PCR8: - *buf++ = val - addr - 1; - break; - case R_W65_PCR16: - val = val - addr - 1; - *buf++ = val; - *buf++ = val >> 8; - break; - case R_W65_DP: - *buf++ = val; - break; - - default: - abort (); - } - - if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0) - fixP->fx_done = 1; -} - -/* Put number into target byte order. */ - -void -md_number_to_chars (char *ptr, valueT use, int nbytes) -{ - number_to_chars_littleendian (ptr, use, nbytes); -} - -long -md_pcrel_from (fixS *fixP) -{ - int gap = fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address - 1; - return gap; -} - -void -tc_coff_symbol_emit_hook (symbolS *x ATTRIBUTE_UNUSED) -{ -} - -short -tc_coff_fix2rtype (fixS *fix_ptr) -{ - return fix_ptr->fx_r_type; -} - -void -tc_reloc_mangle (fixS *fix_ptr, - struct internal_reloc *intr, - bfd_vma base) - -{ - symbolS *symbol_ptr; - - symbol_ptr = fix_ptr->fx_addsy; - - /* If this relocation is attached to a symbol then it's ok - to output it */ - if (fix_ptr->fx_r_type == RELOC_32) - { - /* Cons likes to create reloc32's whatever the size of the reloc. */ - switch (fix_ptr->fx_size) - { - case 2: - intr->r_type = R_IMM16; - break; - case 1: - intr->r_type = R_IMM8; - break; - default: - abort (); - } - } - else - { - if (fix_ptr->fx_size == 4) - intr->r_type = R_W65_ABS24; - else - intr->r_type = fix_ptr->fx_r_type; - } - - intr->r_vaddr = fix_ptr->fx_frag->fr_address + fix_ptr->fx_where + base; - intr->r_offset = fix_ptr->fx_offset; - - /* Turn the segment of the symbol into an offset. */ - if (symbol_ptr) - { - symbolS *dot; - - dot = segment_info[S_GET_SEGMENT (symbol_ptr)].dot; - if (dot) - { - intr->r_offset += S_GET_VALUE (symbol_ptr); - intr->r_symndx = dot->sy_number; - } - else - intr->r_symndx = symbol_ptr->sy_number; - } - else - intr->r_symndx = -1; -} - -int -tc_coff_sizemachdep (fragS *frag) -{ - return md_relax_table[frag->fr_subtype].rlx_length; -} - -/* Called just before address relaxation, return the length by which a - fragment must grow to reach it's destination. */ - -int -md_estimate_size_before_relax (fragS *fragP, segT segment_type) -{ - int what; - - switch (fragP->fr_subtype) - { - default: - abort (); - - case C (COND_BRANCH, UNDEF_BYTE_DISP): - case C (UNCOND_BRANCH, UNDEF_BYTE_DISP): - what = GET_WHAT (fragP->fr_subtype); - /* Used to be a branch to somewhere which was unknown. */ - if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type) - /* Got a symbol and it's defined in this segment, become byte - sized - maybe it will fix up. */ - fragP->fr_subtype = C (what, BYTE_DISP); - else - /* Its got a segment, but its not ours, so it will always be - long. */ - fragP->fr_subtype = C (what, UNDEF_WORD_DISP); - break; - - case C (COND_BRANCH, BYTE_DISP): - case C (COND_BRANCH, WORD_DISP): - case C (COND_BRANCH, UNDEF_WORD_DISP): - case C (UNCOND_BRANCH, BYTE_DISP): - case C (UNCOND_BRANCH, WORD_DISP): - case C (UNCOND_BRANCH, UNDEF_WORD_DISP): - /* When relaxing a section for the second time, we don't need to - do anything besides return the current size. */ - break; - } - - fragP->fr_var = md_relax_table[fragP->fr_subtype].rlx_length; - return fragP->fr_var; -} - -const char *md_shortopts = ""; -struct option md_longopts[] = -{ -#define OPTION_RELAX (OPTION_MD_BASE) - {NULL, no_argument, NULL, 0} -}; - -void -md_show_usage (FILE *stream ATTRIBUTE_UNUSED) -{ -} - -size_t md_longopts_size = sizeof (md_longopts); diff --git a/gas/config/tc-w65.h b/gas/config/tc-w65.h deleted file mode 100644 index 19bb15b..0000000 --- a/gas/config/tc-w65.h +++ /dev/null @@ -1,60 +0,0 @@ -/* This file is tc-w65.h - Copyright 1995, 1997, 1998, 2000, 2001, 2002, 2005 - 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -#define TC_W65 - -#define TARGET_BYTES_BIG_ENDIAN 0 - -struct internal_reloc; -struct fix; - -#define WORKING_DOT_WORD - -/* This macro translates between an internal fix and a coff reloc type. */ -#define TC_COFF_FIX2RTYPE(fixP) tc_coff_fix2rtype (fixP) - -#define BFD_ARCH bfd_arch_w65 -#define COFF_MAGIC 0x6500 - -#define IGNORE_NONSTANDARD_ESCAPES - -#define TC_RELOC_MANGLE(s,a,b,c) tc_reloc_mangle (a,b,c) -extern void tc_reloc_mangle (struct fix *, struct internal_reloc *, bfd_vma); - -#define LISTING_HEADER "W65816 GAS " -#define NEED_FX_R_TYPE 1 -#define RELOC_32 1234 - -#define TC_COFF_SIZEMACHDEP(frag) tc_coff_sizemachdep (frag) -int tc_coff_sizemachdep (fragS *); - -#define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) w65_expression (EXP) -void w65_expression (expressionS *); - -#define TC_COUNT_RELOC(x) (1) -#define TC_CONS_RELOC tc_cons_reloc -#define DONT_OVERFLOW -int tc_cons_reloc; - -#define md_operand(x) - -extern struct relax_type md_relax_table[]; -#define TC_GENERIC_RELAX_TABLE md_relax_table diff --git a/gas/config/tc-xstormy16.h b/gas/config/tc-xstormy16.h index df750be..5425874 100644 --- a/gas/config/tc-xstormy16.h +++ b/gas/config/tc-xstormy16.h @@ -20,11 +20,6 @@ #define TC_XSTORMY16 -#ifndef BFD_ASSEMBLER -/* Leading space so will compile with cc. */ - #error XSTORMY16 support requires BFD_ASSEMBLER -#endif - #define LISTING_HEADER "XSTORMY16 GAS " /* The target BFD architecture. */ diff --git a/gas/config/tc-xtensa.h b/gas/config/tc-xtensa.h index fd72712..35717f0 100644 --- a/gas/config/tc-xtensa.h +++ b/gas/config/tc-xtensa.h @@ -1,5 +1,5 @@ /* tc-xtensa.h -- Header file for tc-xtensa.c. - Copyright (C) 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -23,10 +23,6 @@ struct fix; -#ifndef BFD_ASSEMBLER -#error Xtensa support requires BFD_ASSEMBLER -#endif - #ifndef OBJ_ELF #error Xtensa support requires ELF object format #endif diff --git a/gas/config/tc-z8k.c b/gas/config/tc-z8k.c index ca80fe3..3b0f6d8 100644 --- a/gas/config/tc-z8k.c +++ b/gas/config/tc-z8k.c @@ -36,7 +36,6 @@ const char line_separator_chars[] = ";"; extern int machine; extern int coff_flags; int segmented_mode; -const int md_reloc_size; /* This is non-zero if target was set from the command line. */ static int z8k_target_from_cmdline; @@ -1260,12 +1259,6 @@ md_assemble (char *str) } } -void -tc_crawl_symbol_chain (object_headers *headers ATTRIBUTE_UNUSED) -{ - printf (_("call to tc_crawl_symbol_chain \n")); -} - /* We have no need to default values of symbols. */ symbolS * @@ -1274,12 +1267,6 @@ md_undefined_symbol (char *name ATTRIBUTE_UNUSED) return 0; } -void -tc_headers_hook (object_headers *headers ATTRIBUTE_UNUSED) -{ - printf (_("call to tc_headers_hook \n")); -} - /* Various routines to kill one day. */ /* Equal to MAX_PRECISION in atof-ieee.c. */ #define MAX_LITTLENUMS 6 diff --git a/gas/config/tc-z8k.h b/gas/config/tc-z8k.h index f7c6e69..e48098c 100644 --- a/gas/config/tc-z8k.h +++ b/gas/config/tc-z8k.h @@ -1,6 +1,6 @@ /* This file is tc-z8k.h Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1995, 1997, 1998, - 2000, 2002, 2003 + 2000, 2002, 2003, 2005 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -27,16 +27,7 @@ struct internal_reloc; #define WORKING_DOT_WORD -#ifndef BFD_ASSEMBLER -#define LOCAL_LABEL(x) 0 -#endif - -/* This macro translates between an internal fix and a coff reloc type. */ -#define TC_COFF_FIX2RTYPE(fixP) abort (); - -#define BFD_ARCH bfd_arch_z8k #define COFF_MAGIC 0x8000 -#define TC_COUNT_RELOC(x) (1) #define IGNORE_NONSTANDARD_ESCAPES #undef WARN_SIGNED_OVERFLOW_WORD @@ -45,7 +36,6 @@ extern void tc_reloc_mangle PARAMS ((struct fix *, struct internal_reloc *, bfd_vma)); #define LISTING_HEADER "Zilog Z8000 GAS " -#define NEED_FX_R_TYPE 1 #define RELOC_32 1234 #define md_operand(x) diff --git a/gas/config/te-aux.h b/gas/config/te-aux.h deleted file mode 100644 index 38445d9..0000000 --- a/gas/config/te-aux.h +++ /dev/null @@ -1,17 +0,0 @@ -#define TE_AUX - -/* From obj-coff.h: - This internal_lineno crap is to stop namespace pollution from the - bfd internal coff headerfile. */ -#define internal_lineno bfd_internal_lineno -#include "coff/aux-coff.h" /* override bits in coff/internal.h */ -#undef internal_lineno - -#define COFF_NOLOAD_PROBLEM -#define KEEP_RELOC_INFO - -#include "obj-format.h" - -#ifndef LOCAL_LABELS_FB -#define LOCAL_LABELS_FB 1 -#endif diff --git a/gas/config/te-delt88.h b/gas/config/te-delt88.h deleted file mode 100644 index 1505183..0000000 --- a/gas/config/te-delt88.h +++ /dev/null @@ -1,13 +0,0 @@ -/* This file is te-delta88.h. */ - -#define TE_DELTA88 1 - -#define COFF_NOLOAD_PROBLEM 1 - -/* Added these, because if we don't know what we're targeting we may - need an assembler version of libgcc, and that will use local - labels. */ -#define LOCAL_LABELS_DOLLAR 1 -#define LOCAL_LABELS_FB 1 - -#include "obj-format.h" diff --git a/gas/config/te-delta.h b/gas/config/te-delta.h deleted file mode 100644 index f88b71e..0000000 --- a/gas/config/te-delta.h +++ /dev/null @@ -1,14 +0,0 @@ -#define TE_DELTA - -#include "obj-format.h" - -#define COFF_NOLOAD_PROBLEM 1 -#define COFF_COMMON_ADDEND 1 - -/* Added these, because if we don't know what we're targeting we may - need an assembler version of libgcc, and that will use local - labels. */ -#define LOCAL_LABELS_DOLLAR 1 -#define LOCAL_LABELS_FB 1 - -/* end of te-delta.h */ diff --git a/gas/config/te-dpx2.h b/gas/config/te-dpx2.h deleted file mode 100644 index 5daeb9f..0000000 --- a/gas/config/te-dpx2.h +++ /dev/null @@ -1,12 +0,0 @@ -/* Machine specific defines for the dpx2 machine. */ - -/* The magic number is not the usual MC68MAGIC. */ -#define COFF_MAGIC MC68KBCSMAGIC - -#define REGISTER_PREFIX_OPTIONAL 1 - -#define TARGET_FORMAT "coff-m68k-un" - -#include "obj-format.h" - -/* end of te-dpx2.h */ diff --git a/gas/config/te-hp300.h b/gas/config/te-hp300.h deleted file mode 100644 index 0358d11..0000000 --- a/gas/config/te-hp300.h +++ /dev/null @@ -1,27 +0,0 @@ -/* te-hp300.h -- hpux 9000/300 target environment declarations. - Copyright 1987, 1990, 1991, 1992, 1993, 1995, 2000 - 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -#define LOCAL_LABELS_DOLLAR 1 -#define LOCAL_LABELS_FB 1 - -#include "obj-format.h" - -/* end of te-hp300.h */ diff --git a/gas/config/te-ic960.h b/gas/config/te-ic960.h deleted file mode 100644 index 36deb66..0000000 --- a/gas/config/te-ic960.h +++ /dev/null @@ -1,37 +0,0 @@ -/* This file is te-ic960.h - Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1997, 2000 - 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, 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -/* This file is te-ic960.h and is intended to define ic960 environment - specific differences. */ - -#define OBJ_COFF_OMIT_OPTIONAL_HEADER - -#ifndef BFD_ASSEMBLER -#define LOCAL_LABEL(name) ((name[0] =='L') \ - || (name[0] =='.' \ - && (name[1]=='C' \ - || name[1]=='I' \ - || name[1]=='.'))) -#endif - -#include "obj-format.h" - -/* end of te-ic960.h */ diff --git a/gas/config/vms-a-conf.h b/gas/config/vms-a-conf.h deleted file mode 100644 index 688fc68..0000000 --- a/gas/config/vms-a-conf.h +++ /dev/null @@ -1,129 +0,0 @@ -/* vms-alpha-conf.h. Generated manually from conf.in, - and used by config-gas-alpha.com when constructing config.h. */ - -/* Define if using alloca.c. */ -#ifdef __GNUC__ -#undef C_ALLOCA -#else -#define C_ALLOCA -#endif - -/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. - This function is required for alloca.c support on those systems. */ -#undef CRAY_STACKSEG_END - -/* Define if you have <alloca.h> and it should be used (not on Ultrix). */ -#undef HAVE_ALLOCA_H - -/* Define as __inline if that's what the C compiler calls it. */ -#ifdef __GNUC__ -#undef inline -#else -#define inline -#endif - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown - */ -#define STACK_DIRECTION (-1) - -/* Should gas use high-level BFD interfaces? */ -#define BFD_ASSEMBLER - -/* Some assert/preprocessor combinations are incapable of handling - certain kinds of constructs in the argument of assert. For example, - quoted strings (if requoting isn't done right) or newlines. */ -#ifdef __GNUC__ -#undef BROKEN_ASSERT -#else -#define BROKEN_ASSERT -#endif - -/* If we aren't doing cross-assembling, some operations can be optimized, - since byte orders and value sizes don't need to be adjusted. */ -#undef CROSS_COMPILE - -/* Some gas code wants to know these parameters. */ -#define TARGET_ALIAS "alpha-vms" -#define TARGET_CPU "alpha" -#define TARGET_CANONICAL "alpha-dec-vms" -#define TARGET_OS "openVMS/Alpha" -#define TARGET_VENDOR "dec" - -/* Sometimes the system header files don't declare malloc and realloc. */ -#undef NEED_DECLARATION_MALLOC - -/* Sometimes the system header files don't declare free. */ -#undef NEED_DECLARATION_FREE - -/* Sometimes errno.h doesn't declare errno itself. */ -#undef NEED_DECLARATION_ERRNO - -#undef MANY_SEGMENTS - -/* Needed only for sparc configuration */ -#undef sparcv9 - -/* Define if you have the remove function. */ -#define HAVE_REMOVE - -/* Define if you have the unlink function. */ -#undef HAVE_UNLINK - -/* Define if you have the <errno.h> header file. */ -#define HAVE_ERRNO_H - -/* Define if you have the <memory.h> header file. */ -#undef HAVE_MEMORY_H - -/* Define if you have the <stdarg.h> header file. */ -#define HAVE_STDARG_H - -/* Define if you have the <stdlib.h> header file. */ -#define HAVE_STDLIB_H - -/* Define if you have the <string.h> header file. */ -#define HAVE_STRING_H - -/* Define if you have the <strings.h> header file. */ -#undef HAVE_STRINGS_H - -/* Define if you have the <sys/types.h> header file. */ -#ifdef __GNUC__ -#define HAVE_SYS_TYPES_H -#else -#undef HAVE_SYS_TYPES_H -#endif - -/* Define if you have the <unistd.h> header file. */ -#define HAVE_UNISTD_H /* config-gas.com will make one if necessary */ - -/* Define if you have the <varargs.h> header file. */ -#undef HAVE_VARARGS_H - -/* VMS-specific: we need to set up EXIT_xxx here because the default - values in as.h are inappropriate for VMS, but we also want to prevent - as.h's inclusion of <stdlib.h> from triggering redefinition warnings. - <stdlib.h> guards itself against multiple inclusion, so including it - here turns as.h's later #include into a no-op. (We can't simply use - #ifndef HAVE_STDLIB_H here, because the <stdlib.h> in several older - gcc-vms distributions neglects to define these two required macros.) */ -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif -#if __DECC -#undef EXIT_SUCCESS -#undef EXIT_FAILURE -#define EXIT_SUCCESS 1 /* SS$_NORMAL, STS$K_SUCCESS */ -#define EXIT_FAILURE 0x10000002 /* (STS$K_ERROR | STS$M_INHIB_MSG) */ -#endif - -#include <unixlib.h> -#if __DECC -extern int strcasecmp (); -extern int strncasecmp (); -#endif |