X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=opcodes%2Favr-dis.c;h=976c37176f13b917d1e9e36da8332880a5472e7f;hb=bfa149ac1ebbb9258b9fcfa64d2ec158503a3575;hp=15300844183c74810969c8733a39bcfd3f0097bd;hpb=47b0e7ad8c60ea4b45b22ad5cb376f068991bc88;p=deliverable%2Fbinutils-gdb.git diff --git a/opcodes/avr-dis.c b/opcodes/avr-dis.c index 1530084418..976c37176f 100644 --- a/opcodes/avr-dis.c +++ b/opcodes/avr-dis.c @@ -1,21 +1,25 @@ /* Disassemble AVR instructions. - Copyright 1999, 2000, 2002, 2004, 2005 Free Software Foundation, Inc. + Copyright 1999, 2000, 2002, 2004, 2005, 2006, 2007, 2008 + Free Software Foundation, Inc. Contributed by Denis Chertykov - This program is free software; you can redistribute it and/or modify + This file is part of libopcodes. + + This library 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 of the License, or - (at your option) any later version. + the Free Software Foundation; either version 3, or (at your option) + any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + It is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ #include #include "sysdep.h" @@ -42,6 +46,8 @@ const struct avr_opcodes_s avr_opcodes[] = {NULL, NULL, NULL, 0, 0, 0} }; +static const char * comment_start = "0x"; + static int avr_operand (unsigned int insn, unsigned int insn2, unsigned int pc, int constraint, char *buf, char *comment, int regs, int *sym, bfd_vma *sym_addr) @@ -103,7 +109,7 @@ avr_operand (unsigned int insn, unsigned int insn2, unsigned int pc, int constra case 0x100e: xyz = "-X"; break; default: xyz = "??"; ok = 0; } - sprintf (buf, xyz); + strcpy (buf, xyz); if (AVR_UNDEF_P (insn)) sprintf (comment, _("undefined")); @@ -139,7 +145,11 @@ avr_operand (unsigned int insn, unsigned int insn2, unsigned int pc, int constra case 'h': *sym = 1; *sym_addr = ((((insn & 1) | ((insn & 0x1f0) >> 3)) << 16) | insn2) * 2; - sprintf (buf, "0x"); + /* See PR binutils/2454. Ideally we would like to display the hex + value of the address only once, but this would mean recoding + objdump_print_address() which would affect many targets. */ + sprintf (buf, "%#lx", (unsigned long) *sym_addr); + strcpy (comment, comment_start); break; case 'L': @@ -148,17 +158,18 @@ avr_operand (unsigned int insn, unsigned int insn2, unsigned int pc, int constra sprintf (buf, ".%+-8d", rel_addr); *sym = 1; *sym_addr = pc + 2 + rel_addr; - sprintf (comment, "0x"); + strcpy (comment, comment_start); } break; case 'l': { int rel_addr = ((((insn >> 3) & 0x7f) ^ 0x40) - 0x40) * 2; + sprintf (buf, ".%+-8d", rel_addr); *sym = 1; *sym_addr = pc + 2 + rel_addr; - sprintf (comment, "0x"); + strcpy (comment, comment_start); } break; @@ -261,10 +272,17 @@ print_insn_avr (bfd_vma addr, disassemble_info *info) int sym_op1 = 0, sym_op2 = 0; bfd_vma sym_addr1, sym_addr2; + if (!initialized) { unsigned int nopcodes; + /* PR 4045: Try to avoid duplicating the 0x prefix that + objdump_print_addr() will put on addresses when there + is no symbol table available. */ + if (info->symtab_size == 0) + comment_start = " "; + nopcodes = sizeof (avr_opcodes) / sizeof (struct avr_opcodes_s); avr_bin_masks = xmalloc (nopcodes * sizeof (unsigned int));