92 |
return (bfd_vma) v; |
return (bfd_vma) v; |
93 |
} |
} |
94 |
|
|
95 |
/* Disassemble this for me please... (debugging). */ |
/* Disassemble this for me please... (debugging). 'flags' is only used |
96 |
void disas(FILE *out, void *code, unsigned long size, enum disas_type type) |
for i386: non zero means 16 bit code */ |
97 |
|
void disas(FILE *out, void *code, unsigned long size, int is_host, int flags) |
98 |
{ |
{ |
99 |
uint8_t *pc; |
uint8_t *pc; |
100 |
int count; |
int count; |
107 |
disasm_info.buffer_vma = (unsigned long)code; |
disasm_info.buffer_vma = (unsigned long)code; |
108 |
disasm_info.buffer_length = size; |
disasm_info.buffer_length = size; |
109 |
|
|
110 |
if (type == DISAS_TARGET) { |
if (is_host) { |
111 |
#ifdef WORDS_BIGENDIAN |
#ifdef WORDS_BIGENDIAN |
112 |
disasm_info.endian = BFD_ENDIAN_BIG; |
disasm_info.endian = BFD_ENDIAN_BIG; |
113 |
#else |
#else |
129 |
return; |
return; |
130 |
#endif |
#endif |
131 |
} else { |
} else { |
132 |
/* Currently only source supported in x86. */ |
#ifdef TARGET_WORDS_BIGENDIAN |
133 |
|
disasm_info.endian = BFD_ENDIAN_BIG; |
134 |
|
#else |
135 |
disasm_info.endian = BFD_ENDIAN_LITTLE; |
disasm_info.endian = BFD_ENDIAN_LITTLE; |
136 |
if (type == DISAS_I386_I386) |
#endif |
137 |
|
#if defined(TARGET_I386) |
138 |
|
if (!flags) |
139 |
disasm_info.mach = bfd_mach_i386_i386; |
disasm_info.mach = bfd_mach_i386_i386; |
140 |
else |
else |
141 |
disasm_info.mach = bfd_mach_i386_i8086; |
disasm_info.mach = bfd_mach_i386_i8086; |
142 |
print_insn = print_insn_i386; |
print_insn = print_insn_i386; |
143 |
|
#elif defined(TARGET_ARM) |
144 |
|
print_insn = print_insn_arm; |
145 |
|
#else |
146 |
|
fprintf(out, "Asm output not supported on this arch\n"); |
147 |
|
return; |
148 |
|
#endif |
149 |
} |
} |
150 |
|
|
151 |
for (pc = code; pc < (uint8_t *)code + size; pc += count) { |
for (pc = code; pc < (uint8_t *)code + size; pc += count) { |
153 |
#ifdef __arm__ |
#ifdef __arm__ |
154 |
/* since data are included in the code, it is better to |
/* since data are included in the code, it is better to |
155 |
display code data too */ |
display code data too */ |
156 |
if (type == DISAS_TARGET) { |
if (is_host) { |
157 |
fprintf(out, "%08x ", (int)bfd_getl32((const bfd_byte *)pc)); |
fprintf(out, "%08x ", (int)bfd_getl32((const bfd_byte *)pc)); |
158 |
} |
} |
159 |
#endif |
#endif |