5 |
#include "elf.h" |
#include "elf.h" |
6 |
#include <errno.h> |
#include <errno.h> |
7 |
|
|
8 |
|
#include "cpu.h" |
9 |
|
#include "exec-all.h" |
10 |
|
|
11 |
/* Filled in by elfload.c. Simplistic, but will do for now. */ |
/* Filled in by elfload.c. Simplistic, but will do for now. */ |
12 |
unsigned int disas_num_syms; |
unsigned int disas_num_syms; |
13 |
void *disas_symtab; |
void *disas_symtab; |
22 |
int length; |
int length; |
23 |
struct disassemble_info *info; |
struct disassemble_info *info; |
24 |
{ |
{ |
25 |
if (memaddr < info->buffer_vma |
if (memaddr < info->buffer_vma |
26 |
|| memaddr + length > info->buffer_vma + info->buffer_length) |
|| memaddr + length > info->buffer_vma + info->buffer_length) |
27 |
/* Out of bounds. Use EIO because GDB uses it. */ |
/* Out of bounds. Use EIO because GDB uses it. */ |
28 |
return EIO; |
return EIO; |
29 |
memcpy (myaddr, info->buffer + (memaddr - info->buffer_vma), length); |
memcpy (myaddr, info->buffer + (memaddr - info->buffer_vma), length); |
30 |
return 0; |
return 0; |
31 |
} |
} |
32 |
|
|
33 |
|
#if !defined(CONFIG_USER_ONLY) |
34 |
|
/* Get LENGTH bytes from info's buffer, at target address memaddr. |
35 |
|
Transfer them to myaddr. */ |
36 |
|
static int |
37 |
|
target_read_memory (memaddr, myaddr, length, info) |
38 |
|
bfd_vma memaddr; |
39 |
|
bfd_byte *myaddr; |
40 |
|
int length; |
41 |
|
struct disassemble_info *info; |
42 |
|
{ |
43 |
|
int i; |
44 |
|
for(i = 0; i < length; i++) { |
45 |
|
myaddr[i] = ldub_code((void *)((long)memaddr)); |
46 |
|
} |
47 |
|
return 0; |
48 |
|
} |
49 |
|
#endif |
50 |
|
|
51 |
/* Print an error message. We can assume that this is in response to |
/* Print an error message. We can assume that this is in response to |
52 |
an error return from buffer_read_memory. */ |
an error return from buffer_read_memory. */ |
53 |
void |
void |
124 |
|
|
125 |
INIT_DISASSEMBLE_INFO(disasm_info, out, fprintf); |
INIT_DISASSEMBLE_INFO(disasm_info, out, fprintf); |
126 |
|
|
127 |
|
#if !defined(CONFIG_USER_ONLY) |
128 |
|
if (!is_host) { |
129 |
|
disasm_info.read_memory_func = target_read_memory; |
130 |
|
} |
131 |
|
#endif |
132 |
|
|
133 |
disasm_info.buffer = code; |
disasm_info.buffer = code; |
134 |
disasm_info.buffer_vma = (unsigned long)code; |
disasm_info.buffer_vma = (unsigned long)code; |
135 |
disasm_info.buffer_length = size; |
disasm_info.buffer_length = size; |