diff options
author | Nick Clifton <nickc@redhat.com> | 2009-01-02 14:21:54 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2009-01-02 14:21:54 +0000 |
commit | 4ef2cf8be8a20090d7709672b0227e24172df3b3 (patch) | |
tree | 8f4d659bafddd3e0e794ac99ba15767aa6151552 /opcodes | |
parent | e8f957fddddb3c42590910f524c0e96b2d9ea897 (diff) | |
download | fsf-binutils-gdb-4ef2cf8be8a20090d7709672b0227e24172df3b3.zip fsf-binutils-gdb-4ef2cf8be8a20090d7709672b0227e24172df3b3.tar.gz fsf-binutils-gdb-4ef2cf8be8a20090d7709672b0227e24172df3b3.tar.bz2 |
* or32-opc.c (or32_print_register, or32_print_immediate,
disassemble_insn): Don't rely on undefined sprintf behaviour.
* itbl-ops.c (itbl_disassemble): Don't rely on undefined sprintf
behaviour.
Diffstat (limited to 'opcodes')
-rw-r--r-- | opcodes/ChangeLog | 5 | ||||
-rw-r--r-- | opcodes/or32-opc.c | 30 |
2 files changed, 26 insertions, 9 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 4b4f7ba..c6c6d6b 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,8 @@ +2009-01-02 Matthias Klose <doko@ubuntu.com> + + * or32-opc.c (or32_print_register, or32_print_immediate, + disassemble_insn): Don't rely on undefined sprintf behaviour. + 2008-12-30 Martin Schwidefsky <schwidefskyy@de.ibm.com> * s390-opc.txt: Add ptff instruction. diff --git a/opcodes/or32-opc.c b/opcodes/or32-opc.c index aa94c13..24ab5cf 100644 --- a/opcodes/or32-opc.c +++ b/opcodes/or32-opc.c @@ -1,5 +1,5 @@ /* Table of opcodes for the OpenRISC 1000 ISA. - Copyright 2002, 2004, 2005, 2007, 2008 Free Software Foundation, Inc. + Copyright 2002, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. Contributed by Damjan Lampret (lampret@opencores.org). This file is part of the GNU opcodes library. @@ -951,8 +951,10 @@ static void or32_print_register (char param_ch, char *encoding, unsigned long insn) { int regnum = or32_extract(param_ch, encoding, insn); - - sprintf (disassembled, "%sr%d", disassembled, regnum); + char s_regnum[20]; + + sprintf (s_regnum, "r%d", regnum); + strcat (disassembled, s_regnum); } /* Print immediate. Used only by print_insn. */ @@ -961,18 +963,20 @@ static void or32_print_immediate (char param_ch, char *encoding, unsigned long insn) { int imm = or32_extract (param_ch, encoding, insn); + char s_imm[20]; imm = extend_imm (imm, param_ch); - + if (letter_signed (param_ch)) { if (imm < 0) - sprintf (disassembled, "%s%d", disassembled, imm); + sprintf (s_imm, "%d", imm); else - sprintf (disassembled, "%s0x%x", disassembled, imm); + sprintf (s_imm, "0x%x", imm); } else - sprintf (disassembled, "%s%#x", disassembled, imm); + sprintf (s_imm, "%#x", imm); + strcat (disassembled, s_imm); } /* Disassemble one instruction from insn to disassemble. @@ -1005,14 +1009,22 @@ disassemble_insn (unsigned long insn) if (strchr (opcode->encoding, *s)) or32_print_immediate (*s, opcode->encoding, insn); else - sprintf (disassembled, "%s%c", disassembled, *s); + { + char s_encoding[2] = { *s, '\0' }; + + strcat (disassembled, s_encoding); + } + } } } else { + char s_insn[20]; + /* This used to be %8x for binutils. */ - sprintf (disassembled, "%s.word 0x%08lx", disassembled, insn); + sprintf (s_insn, ".word 0x%08lx", insn); + strcat (disassembled, s_insn); } return insn_len (insn); |