aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Turner <digit@android.com>2010-09-09 22:56:10 +0200
committerDavid 'Digit' Turner <digit@android.com>2010-09-13 00:30:34 -0700
commit75fb4a08de4abce11ee7cf81bcddd5193eb0438d (patch)
tree47261e30e1472132e72f041d7dc1d6cae95d2a07
parent6a9ef1773bf874dea493ff3861782a1e577b67dd (diff)
downloadexternal_qemu-75fb4a08de4abce11ee7cf81bcddd5193eb0438d.zip
external_qemu-75fb4a08de4abce11ee7cf81bcddd5193eb0438d.tar.gz
external_qemu-75fb4a08de4abce11ee7cf81bcddd5193eb0438d.tar.bz2
upstream: disas update.
-rw-r--r--arm-dis.c17
-rw-r--r--dis-asm.h5
-rw-r--r--disas.c20
-rw-r--r--disas.h6
-rw-r--r--i386-dis.c61
5 files changed, 69 insertions, 40 deletions
diff --git a/arm-dis.c b/arm-dis.c
index 2c67d8f..fe7ac99 100644
--- a/arm-dis.c
+++ b/arm-dis.c
@@ -60,10 +60,8 @@
#define FPU_VFP_EXT_V3 0
#define FPU_NEON_EXT_V1 0
-int floatformat_ieee_single_little;
/* Assume host uses ieee float. */
-static void floatformat_to_double (int *ignored, unsigned char *data,
- double *dest)
+static void floatformat_to_double (unsigned char *data, double *dest)
{
union {
uint32_t i;
@@ -2517,7 +2515,6 @@ print_insn_neon (struct disassemble_info *info, long given, bfd_boolean thumb)
{
func (stream, "<illegal constant %.8x:%x:%x>",
bits, cmode, op);
- size = 32;
break;
}
switch (size)
@@ -2543,9 +2540,7 @@ print_insn_neon (struct disassemble_info *info, long given, bfd_boolean thumb)
valbytes[2] = (value >> 16) & 0xff;
valbytes[3] = (value >> 24) & 0xff;
- floatformat_to_double
- (&floatformat_ieee_single_little, valbytes,
- &fvalue);
+ floatformat_to_double (valbytes, &fvalue);
func (stream, "#%.7g\t; 0x%.8lx", fvalue,
value);
@@ -3153,14 +3148,14 @@ print_insn_thumb16 (bfd_vma pc, struct disassemble_info *info, long given)
if (started)
func (stream, ", ");
started = 1;
- func (stream, arm_regnames[14] /* "lr" */);
+ func (stream, "%s", arm_regnames[14] /* "lr" */);
}
if (domaskpc)
{
if (started)
func (stream, ", ");
- func (stream, arm_regnames[15] /* "pc" */);
+ func (stream, "%s", arm_regnames[15] /* "pc" */);
}
func (stream, "}");
@@ -3703,7 +3698,7 @@ print_insn_thumb32 (bfd_vma pc, struct disassemble_info *info, long given)
}
else
{
- func (stream, psr_name (given & 0xff));
+ func (stream, "%s", psr_name (given & 0xff));
}
break;
@@ -3711,7 +3706,7 @@ print_insn_thumb32 (bfd_vma pc, struct disassemble_info *info, long given)
if ((given & 0xff) == 0)
func (stream, "%cPSR", (given & 0x100000) ? 'S' : 'C');
else
- func (stream, psr_name (given & 0xff));
+ func (stream, "%s", psr_name (given & 0xff));
break;
case '0': case '1': case '2': case '3': case '4':
diff --git a/dis-asm.h b/dis-asm.h
index 5f6f06c..9b9657e 100644
--- a/dis-asm.h
+++ b/dis-asm.h
@@ -219,6 +219,9 @@ enum bfd_architecture
#define bfd_mach_cris_v32 32
#define bfd_mach_cris_v10_v32 1032
bfd_arch_microblaze, /* Xilinx MicroBlaze. */
+ bfd_arch_ia64, /* HP/Intel ia64 */
+#define bfd_mach_ia64_elf64 64
+#define bfd_mach_ia64_elf32 32
bfd_arch_last
};
#define bfd_mach_s390_31 31
@@ -401,6 +404,7 @@ extern int print_insn_ppc (bfd_vma, disassemble_info*);
extern int print_insn_s390 (bfd_vma, disassemble_info*);
extern int print_insn_crisv32 (bfd_vma, disassemble_info*);
extern int print_insn_microblaze (bfd_vma, disassemble_info*);
+extern int print_insn_ia64 (bfd_vma, disassemble_info*);
#if 0
/* Fetch the disassembler for a given BFD, if that support is available. */
@@ -468,6 +472,7 @@ extern int generic_symbol_at_address (bfd_vma, struct disassemble_info *);
/* from libbfd */
+bfd_vma bfd_getl64 (const bfd_byte *addr);
bfd_vma bfd_getl32 (const bfd_byte *addr);
bfd_vma bfd_getb32 (const bfd_byte *addr);
bfd_vma bfd_getl16 (const bfd_byte *addr);
diff --git a/disas.c b/disas.c
index ce342bc..79a98de 100644
--- a/disas.c
+++ b/disas.c
@@ -73,6 +73,21 @@ generic_symbol_at_address (bfd_vma addr, struct disassemble_info *info)
return 1;
}
+bfd_vma bfd_getl64 (const bfd_byte *addr)
+{
+ unsigned long long v;
+
+ v = (unsigned long long) addr[0];
+ v |= (unsigned long long) addr[1] << 8;
+ v |= (unsigned long long) addr[2] << 16;
+ v |= (unsigned long long) addr[3] << 24;
+ v |= (unsigned long long) addr[4] << 32;
+ v |= (unsigned long long) addr[5] << 40;
+ v |= (unsigned long long) addr[6] << 48;
+ v |= (unsigned long long) addr[7] << 56;
+ return (bfd_vma) v;
+}
+
bfd_vma bfd_getl32 (const bfd_byte *addr)
{
unsigned long v;
@@ -278,6 +293,8 @@ void disas(FILE *out, void *code, unsigned long size)
print_insn = print_insn_s390;
#elif defined(__hppa__)
print_insn = print_insn_hppa;
+#elif defined(__ia64__)
+ print_insn = print_insn_ia64;
#else
fprintf(out, "0x%lx: Asm output not supported on this arch\n",
(long) code);
@@ -393,6 +410,9 @@ void monitor_disas(Monitor *mon, CPUState *env,
#else
print_insn = print_insn_little_mips;
#endif
+#elif defined(TARGET_SH4)
+ disasm_info.mach = bfd_mach_sh4;
+ print_insn = print_insn_sh;
#else
monitor_printf(mon, "0x" TARGET_FMT_lx
": Asm output not supported on this arch\n", pc);
diff --git a/disas.h b/disas.h
index f63462c..6a9332d 100644
--- a/disas.h
+++ b/disas.h
@@ -3,6 +3,7 @@
#include "qemu-common.h"
+#ifdef NEED_CPU_H
/* Disassemble this for me please... (debugging). */
void disas(FILE *out, void *code, unsigned long size);
void target_disas(FILE *out, target_ulong code, target_ulong size, int flags);
@@ -15,12 +16,17 @@ void monitor_disas(Monitor *mon, CPUState *env,
/* Look up symbol for debugging purpose. Returns "" if unknown. */
const char *lookup_symbol(target_ulong orig_addr);
+#endif
struct syminfo;
struct elf32_sym;
struct elf64_sym;
+#if defined(CONFIG_USER_ONLY)
+typedef const char *(*lookup_symbol_t)(struct syminfo *s, target_ulong orig_addr);
+#else
typedef const char *(*lookup_symbol_t)(struct syminfo *s, target_phys_addr_t orig_addr);
+#endif
struct syminfo {
lookup_symbol_t lookup_symbol;
diff --git a/i386-dis.c b/i386-dis.c
index b2af033..c4a81c9 100644
--- a/i386-dis.c
+++ b/i386-dis.c
@@ -155,7 +155,8 @@
#include <setjmp.h>
-static int fetch_data (struct disassemble_info *, bfd_byte *);
+static int fetch_data2(struct disassemble_info *, bfd_byte *);
+static int fetch_data(struct disassemble_info *, bfd_byte *);
static void ckprefix (void);
static const char *prefix_name (int, int);
static int print_insn (bfd_vma, disassemble_info *);
@@ -280,12 +281,8 @@ static int used_prefixes;
/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
to ADDR (exclusive) are valid. Returns 1 for success, longjmps
on error. */
-#define FETCH_DATA(info, addr) \
- ((addr) <= ((struct dis_private *) (info->private_data))->max_fetched \
- ? 1 : fetch_data ((info), (addr)))
-
static int
-fetch_data (struct disassemble_info *info, bfd_byte *addr)
+fetch_data2(struct disassemble_info *info, bfd_byte *addr)
{
int status;
struct dis_private *priv = (struct dis_private *) info->private_data;
@@ -313,6 +310,17 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr)
return 1;
}
+static int
+fetch_data(struct disassemble_info *info, bfd_byte *addr)
+{
+ if (addr <= ((struct dis_private *) (info->private_data))->max_fetched) {
+ return 1;
+ } else {
+ return fetch_data2(info, addr);
+ }
+}
+
+
#define XX { NULL, 0 }
#define Eb { OP_E, b_mode }
@@ -3320,7 +3328,7 @@ ckprefix (void)
rex_used = 0;
while (1)
{
- FETCH_DATA (the_info, codep + 1);
+ fetch_data(the_info, codep + 1);
newrex = 0;
switch (*codep)
{
@@ -3684,7 +3692,7 @@ print_insn (bfd_vma pc, disassemble_info *info)
insn_codep = codep;
sizeflag = priv.orig_sizeflag;
- FETCH_DATA (info, codep + 1);
+ fetch_data(info, codep + 1);
two_source_ops = (*codep == 0x62) || (*codep == 0xc8);
if (((prefixes & PREFIX_FWAIT)
@@ -3706,7 +3714,7 @@ print_insn (bfd_vma pc, disassemble_info *info)
if (*codep == 0x0f)
{
unsigned char threebyte;
- FETCH_DATA (info, codep + 2);
+ fetch_data(info, codep + 2);
threebyte = *++codep;
dp = &dis386_twobyte[threebyte];
need_modrm = twobyte_has_modrm[*codep];
@@ -3717,7 +3725,7 @@ print_insn (bfd_vma pc, disassemble_info *info)
codep++;
if (dp->name == NULL && dp->op[0].bytemode == IS_3BYTE_OPCODE)
{
- FETCH_DATA (info, codep + 2);
+ fetch_data(info, codep + 2);
op = *codep++;
switch (threebyte)
{
@@ -3802,7 +3810,7 @@ print_insn (bfd_vma pc, disassemble_info *info)
}
else if (need_modrm)
{
- FETCH_DATA (info, codep + 1);
+ fetch_data(info, codep + 1);
modrm.mod = (*codep >> 6) & 3;
modrm.reg = (*codep >> 3) & 7;
modrm.rm = *codep & 7;
@@ -4968,7 +4976,7 @@ OP_E (int bytemode, int sizeflag)
if (base == 4)
{
havesib = 1;
- FETCH_DATA (the_info, codep + 1);
+ fetch_data(the_info, codep + 1);
index = (*codep >> 3) & 7;
if (address_mode == mode_64bit || index != 0x4)
/* When INDEX == 0x4 in 32 bit mode, SCALE is ignored. */
@@ -4993,7 +5001,7 @@ OP_E (int bytemode, int sizeflag)
}
break;
case 1:
- FETCH_DATA (the_info, codep + 1);
+ fetch_data (the_info, codep + 1);
disp = *codep++;
if ((disp & 0x80) != 0)
disp -= 0x100;
@@ -5104,7 +5112,7 @@ OP_E (int bytemode, int sizeflag)
}
break;
case 1:
- FETCH_DATA (the_info, codep + 1);
+ fetch_data(the_info, codep + 1);
disp = *codep++;
if ((disp & 0x80) != 0)
disp -= 0x100;
@@ -5226,7 +5234,7 @@ get64 (void)
unsigned int a;
unsigned int b;
- FETCH_DATA (the_info, codep + 8);
+ fetch_data(the_info, codep + 8);
a = *codep++ & 0xff;
a |= (*codep++ & 0xff) << 8;
a |= (*codep++ & 0xff) << 16;
@@ -5248,7 +5256,7 @@ get32 (void)
{
bfd_signed_vma x = 0;
- FETCH_DATA (the_info, codep + 4);
+ fetch_data(the_info, codep + 4);
x = *codep++ & (bfd_signed_vma) 0xff;
x |= (*codep++ & (bfd_signed_vma) 0xff) << 8;
x |= (*codep++ & (bfd_signed_vma) 0xff) << 16;
@@ -5261,7 +5269,7 @@ get32s (void)
{
bfd_signed_vma x = 0;
- FETCH_DATA (the_info, codep + 4);
+ fetch_data(the_info, codep + 4);
x = *codep++ & (bfd_signed_vma) 0xff;
x |= (*codep++ & (bfd_signed_vma) 0xff) << 8;
x |= (*codep++ & (bfd_signed_vma) 0xff) << 16;
@@ -5277,7 +5285,7 @@ get16 (void)
{
int x = 0;
- FETCH_DATA (the_info, codep + 2);
+ fetch_data(the_info, codep + 2);
x = *codep++ & 0xff;
x |= (*codep++ & 0xff) << 8;
return x;
@@ -5418,7 +5426,7 @@ OP_I (int bytemode, int sizeflag)
switch (bytemode)
{
case b_mode:
- FETCH_DATA (the_info, codep + 1);
+ fetch_data(the_info, codep + 1);
op = *codep++;
mask = 0xff;
break;
@@ -5480,7 +5488,7 @@ OP_I64 (int bytemode, int sizeflag)
switch (bytemode)
{
case b_mode:
- FETCH_DATA (the_info, codep + 1);
+ fetch_data(the_info, codep + 1);
op = *codep++;
mask = 0xff;
break;
@@ -5520,16 +5528,14 @@ static void
OP_sI (int bytemode, int sizeflag)
{
bfd_signed_vma op;
- bfd_signed_vma mask = -1;
switch (bytemode)
{
case b_mode:
- FETCH_DATA (the_info, codep + 1);
+ fetch_data(the_info, codep + 1);
op = *codep++;
if ((op & 0x80) != 0)
op -= 0x100;
- mask = 0xffffffff;
break;
case v_mode:
USED_REX (REX_W);
@@ -5538,11 +5544,9 @@ OP_sI (int bytemode, int sizeflag)
else if (sizeflag & DFLAG)
{
op = get32s ();
- mask = 0xffffffff;
}
else
{
- mask = 0xffffffff;
op = get16 ();
if ((op & 0x8000) != 0)
op -= 0x10000;
@@ -5551,7 +5555,6 @@ OP_sI (int bytemode, int sizeflag)
break;
case w_mode:
op = get16 ();
- mask = 0xffffffff;
if ((op & 0x8000) != 0)
op -= 0x10000;
break;
@@ -5575,7 +5578,7 @@ OP_J (int bytemode, int sizeflag)
switch (bytemode)
{
case b_mode:
- FETCH_DATA (the_info, codep + 1);
+ fetch_data(the_info, codep + 1);
disp = *codep++;
if ((disp & 0x80) != 0)
disp -= 0x100;
@@ -6097,7 +6100,7 @@ OP_3DNowSuffix (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
{
const char *mnemonic;
- FETCH_DATA (the_info, codep + 1);
+ fetch_data(the_info, codep + 1);
/* AMD 3DNow! instructions are specified by an opcode suffix in the
place where an 8-bit immediate would normally go. ie. the last
byte of the instruction. */
@@ -6133,7 +6136,7 @@ OP_SIMD_Suffix (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
{
unsigned int cmp_type;
- FETCH_DATA (the_info, codep + 1);
+ fetch_data(the_info, codep + 1);
obufp = obuf + strlen (obuf);
cmp_type = *codep++ & 0xff;
if (cmp_type < 8)