X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gas%2Fconfig%2Ftc-dlx.c;h=3f64025575d84fd804c47b5e7117654204b6cc5a;hb=c4612b92e38e9495970afc703f222f99d27c1b4d;hp=25841ed1eed2f9f7702ec961e3a91177335f29d7;hpb=df7b86aa4cb63ce86e60949b8160438bc0f9e389;p=deliverable%2Fbinutils-gdb.git diff --git a/gas/config/tc-dlx.c b/gas/config/tc-dlx.c index 25841ed1ee..3f64025575 100644 --- a/gas/config/tc-dlx.c +++ b/gas/config/tc-dlx.c @@ -1,6 +1,5 @@ /* tc-dlx.c -- Assemble for the DLX - Copyright 2002, 2003, 2004, 2005, 2007, 2009, 2010, 2012 - Free Software Foundation, Inc. + Copyright (C) 2002-2020 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -25,6 +24,8 @@ #include "safe-ctype.h" #include "tc-dlx.h" #include "opcode/dlx.h" +#include "elf/dlx.h" +#include "bfd/elf32-dlx.h" /* Make it easier to clone this machine desc into another one. */ #define machine_opcode dlx_opcode @@ -53,7 +54,7 @@ struct machine_it int pcrel; int size; int reloc_offset; /* Offset of reloc within insn. */ - int reloc; + bfd_reloc_code_real_type reloc; int HI; int LO; } @@ -85,7 +86,7 @@ const char EXP_CHARS[] = "eE"; const char FLT_CHARS[] = "rRsSfFdDxXpP"; static void -insert_sreg (char *regname, int regnum) +insert_sreg (const char *regname, int regnum) { /* Must be large enough to hold the names of the special registers. */ char buf[80]; @@ -154,7 +155,7 @@ match_sft_register (char *name) #define MAX_REG_NO 35 /* Currently we have 35 software registers defined - we borrowed from MIPS. */ - static char *soft_reg[] = + static const char *soft_reg[] = { "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "t9", @@ -231,11 +232,10 @@ s_proc (int end_p) return; } - name = input_line_pointer; - delim1 = get_symbol_end (); + delim1 = get_symbol_name (&name); name = xstrdup (name); *input_line_pointer = delim1; - SKIP_WHITESPACE (); + SKIP_WHITESPACE_AFTER_NAME (); if (*input_line_pointer != ',') { @@ -245,7 +245,12 @@ s_proc (int end_p) /* Missing entry point, use function's name with the leading char prepended. */ if (leading_char) - asprintf (&label, "%c%s", leading_char, name); + { + unsigned len = strlen (name) + 1; + label = XNEWVEC (char, len + 1); + label[0] = leading_char; + memcpy (label + 1, name, len); + } else label = name; } @@ -253,10 +258,9 @@ s_proc (int end_p) { ++input_line_pointer; SKIP_WHITESPACE (); - label = input_line_pointer; - delim2 = get_symbol_end (); + delim2 = get_symbol_name (&label); label = xstrdup (label); - *input_line_pointer = delim2; + (void) restore_line_pointer (delim2); } current_name = name; @@ -662,6 +666,9 @@ machine_ip (char *str) expressionS *operand = &the_operand; unsigned int reg, reg_shift = 0; + memset (&the_insn, '\0', sizeof (the_insn)); + the_insn.reloc = NO_RELOC; + /* Fixup the opcode string to all lower cases, and also allow numerical digits. */ s = str; @@ -686,19 +693,12 @@ machine_ip (char *str) return; } - /* Hash the opcode, insn will have the string from opcode table. - also initialized the_insn struct. */ + /* Hash the opcode, insn will have the string from opcode table. */ if ((insn = (struct machine_opcode *) hash_find (op_hash, str)) == NULL) { /* Handle the ret and return macro here. */ if ((strcmp (str, "ret") == 0) || (strcmp (str, "return") == 0)) - { - memset (&the_insn, '\0', sizeof (the_insn)); - the_insn.reloc = NO_RELOC; - the_insn.pcrel = 0; - the_insn.opcode = - (unsigned long)(JROP | 0x03e00000); /* 0x03e00000 = r31 << 21 */ - } + the_insn.opcode = JROP | 0x03e00000; /* 0x03e00000 = r31 << 21 */ else as_bad (_("Unknown opcode `%s'."), str); @@ -706,9 +706,6 @@ machine_ip (char *str) } opcode = insn->opcode; - memset (&the_insn, '\0', sizeof (the_insn)); - the_insn.reloc = NO_RELOC; - the_insn.pcrel = 0; /* Set the sip reloc HI16 flag. */ if (!set_dlx_skip_hi16_flag (1)) @@ -779,10 +776,11 @@ machine_ip (char *str) /* Macro move operand/reg. */ if (operand->X_op == O_register) { - /* Its a register. */ + /* It's a register. */ reg_shift = 21; goto general_reg; } + /* Fall through. */ /* The immediate 16 bits literal, bit 0-15. */ case 'i': @@ -806,7 +804,7 @@ machine_ip (char *str) continue; } - the_insn.reloc = (the_insn.HI) ? RELOC_DLX_HI16 + the_insn.reloc = (the_insn.HI) ? RELOC_DLX_HI16 : (the_insn.LO ? RELOC_DLX_LO16 : RELOC_DLX_16); the_insn.reloc_offset = 2; the_insn.size = 2; @@ -935,7 +933,7 @@ md_assemble (char *str) switch (fixP->fx_r_type) { case RELOC_DLX_REL26: - bitP = malloc (sizeof (bit_fixS)); + bitP = XNEW (bit_fixS); bitP->fx_bit_size = 26; bitP->fx_bit_offset = 25; bitP->fx_bit_base = the_insn.opcode & 0xFC000000; @@ -947,7 +945,7 @@ md_assemble (char *str) break; case RELOC_DLX_LO16: case RELOC_DLX_REL16: - bitP = malloc (sizeof (bit_fixS)); + bitP = XNEW (bit_fixS); bitP->fx_bit_size = 16; bitP->fx_bit_offset = 15; bitP->fx_bit_base = the_insn.opcode & 0xFFFF0000; @@ -958,7 +956,7 @@ md_assemble (char *str) fixP->fx_bit_fixP = bitP; break; case RELOC_DLX_HI16: - bitP = malloc (sizeof (bit_fixS)); + bitP = XNEW (bit_fixS); bitP->fx_bit_size = 16; bitP->fx_bit_offset = 15; bitP->fx_bit_base = the_insn.opcode & 0xFFFF0000; @@ -979,7 +977,7 @@ md_assemble (char *str) but I'm not sure. Dlx will not use it anyway, so I just leave it here for now. */ -char * +const char * md_atof (int type, char *litP, int *sizeP) { return ieee_md_atof (type, litP, sizeP, TRUE); @@ -1016,10 +1014,6 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) free (fixP->fx_bit_fixP); fixP->fx_bit_fixP = NULL; } -#ifdef DEBUG - else - know ((fixP->fx_bit_fixP != NULL)); -#endif break; case RELOC_DLX_HI16: @@ -1029,10 +1023,6 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) free (fixP->fx_bit_fixP); fixP->fx_bit_fixP = NULL; } -#ifdef DEBUG - else - know ((fixP->fx_bit_fixP != NULL)); -#endif break; case RELOC_DLX_REL26: @@ -1042,10 +1032,6 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) free (fixP->fx_bit_fixP); fixP->fx_bit_fixP = NULL; } -#ifdef DEBUG - else - know ((fixP->fx_bit_fixP != NULL)); -#endif break; case BFD_RELOC_VTABLE_INHERIT: @@ -1068,6 +1054,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) number_to_chars_bigendian (place, val, fixP->fx_size); if (fixP->fx_addsy == NULL) fixP->fx_done = 1; + if (fixP->fx_bit_fixP != NULL) + fixP->fx_no_overflow = 1; } const char *md_shortopts = ""; @@ -1081,7 +1069,7 @@ size_t md_longopts_size = sizeof (md_longopts); int md_parse_option (int c ATTRIBUTE_UNUSED, - char *arg ATTRIBUTE_UNUSED) + const char *arg ATTRIBUTE_UNUSED) { return 0; } @@ -1192,7 +1180,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, { arelent * reloc; - reloc = xmalloc (sizeof (arelent)); + reloc = XNEW (arelent); reloc->howto = bfd_reloc_type_lookup (stdoutput, fixP->fx_r_type); if (reloc->howto == NULL) @@ -1206,7 +1194,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, gas_assert (!fixP->fx_pcrel == !reloc->howto->pc_relative); - reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *)); + reloc->sym_ptr_ptr = XNEW (asymbol *); *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy); reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;