Don't leave DLX the_insn uninitialised

In particular the_insn.reloc must be initialised, otherwise the early
exit cases for bad opcodes will result in cascading errors if
write_object_file is called after an error.

	* config/tc-dlx.c (machine_ip): Move initialisation of the_insn
	earlier.
This commit is contained in:
Alan Modra
2014-06-16 10:02:59 +09:30
parent 1ab668bf2a
commit 97d24fbbf5
2 changed files with 10 additions and 12 deletions

View File

@ -1,3 +1,8 @@
2014-06-16 Alan Modra <amodra@gmail.com>
* config/tc-dlx.c (machine_ip): Move initialisation of the_insn
earlier.
2014-06-16 Alan Modra <amodra@gmail.com> 2014-06-16 Alan Modra <amodra@gmail.com>
* config/tc-i386.c (reloc): Don't avoid pcrel check for * config/tc-i386.c (reloc): Don't avoid pcrel check for

View File

@ -666,6 +666,9 @@ machine_ip (char *str)
expressionS *operand = &the_operand; expressionS *operand = &the_operand;
unsigned int reg, reg_shift = 0; 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 /* Fixup the opcode string to all lower cases, and also
allow numerical digits. */ allow numerical digits. */
s = str; s = str;
@ -690,19 +693,12 @@ machine_ip (char *str)
return; return;
} }
/* Hash the opcode, insn will have the string from opcode table. /* Hash the opcode, insn will have the string from opcode table. */
also initialized the_insn struct. */
if ((insn = (struct machine_opcode *) hash_find (op_hash, str)) == NULL) if ((insn = (struct machine_opcode *) hash_find (op_hash, str)) == NULL)
{ {
/* Handle the ret and return macro here. */ /* Handle the ret and return macro here. */
if ((strcmp (str, "ret") == 0) || (strcmp (str, "return") == 0)) if ((strcmp (str, "ret") == 0) || (strcmp (str, "return") == 0))
{ the_insn.opcode = JROP | 0x03e00000; /* 0x03e00000 = r31 << 21 */
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 */
}
else else
as_bad (_("Unknown opcode `%s'."), str); as_bad (_("Unknown opcode `%s'."), str);
@ -710,9 +706,6 @@ machine_ip (char *str)
} }
opcode = insn->opcode; 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. */ /* Set the sip reloc HI16 flag. */
if (!set_dlx_skip_hi16_flag (1)) if (!set_dlx_skip_hi16_flag (1))