Mercurial > hg > truffle
annotate src/share/tools/hsdis/hsdis.c @ 1972:f95d63e2154a
6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg
author | stefank |
---|---|
date | Tue, 23 Nov 2010 13:22:55 -0800 |
parents | c18cbe5936b8 |
children | 50c0f22d6d0e |
rev | line source |
---|---|
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
1 /* |
1972 | 2 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
4 * |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
8 * |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
13 * accompanied this code). |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
14 * |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
18 * |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
21 * questions. |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
22 * |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
23 */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
24 |
1972 | 25 #include "precompiled.hpp" |
26 | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
27 /* hsdis.c -- dump a range of addresses as native instructions |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
28 This implements the plugin protocol required by the |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
29 HotSpot PrintAssembly option. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
30 */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
31 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
32 #include "hsdis.h" |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
33 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
34 #include <sysdep.h> |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
35 #include <libiberty.h> |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
36 #include <bfd.h> |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
37 #include <dis-asm.h> |
720
67a2f5ba5582
6684007: PrintAssembly plugin not available for linux or windows
never
parents:
100
diff
changeset
|
38 #include <inttypes.h> |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
39 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
40 #ifndef bool |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
41 #define bool int |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
42 #define true 1 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
43 #define false 0 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
44 #endif /*bool*/ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
45 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
46 /* short names for stuff in hsdis.h */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
47 typedef decode_instructions_event_callback_ftype event_callback_t; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
48 typedef decode_instructions_printf_callback_ftype printf_callback_t; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
49 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
50 /* disassemble_info.application_data object */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
51 struct hsdis_app_data { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
52 /* the arguments to decode_instructions */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
53 uintptr_t start; uintptr_t end; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
54 event_callback_t event_callback; void* event_stream; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
55 printf_callback_t printf_callback; void* printf_stream; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
56 bool losing; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
57 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
58 /* the architecture being disassembled */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
59 const char* arch_name; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
60 const bfd_arch_info_type* arch_info; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
61 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
62 /* the disassembler we are going to use: */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
63 disassembler_ftype dfn; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
64 struct disassemble_info dinfo; /* the actual struct! */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
65 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
66 char mach_option[64]; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
67 char insn_options[256]; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
68 }; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
69 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
70 #define DECL_APP_DATA(dinfo) \ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
71 struct hsdis_app_data* app_data = (struct hsdis_app_data*) (dinfo)->application_data |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
72 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
73 #define DECL_EVENT_CALLBACK(app_data) \ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
74 event_callback_t event_callback = (app_data)->event_callback; \ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
75 void* event_stream = (app_data)->event_stream |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
76 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
77 #define DECL_PRINTF_CALLBACK(app_data) \ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
78 printf_callback_t printf_callback = (app_data)->printf_callback; \ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
79 void* printf_stream = (app_data)->printf_stream |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
80 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
81 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
82 static void print_help(struct hsdis_app_data* app_data, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
83 const char* msg, const char* arg); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
84 static void setup_app_data(struct hsdis_app_data* app_data, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
85 const char* options); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
86 static const char* format_insn_close(const char* close, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
87 disassemble_info* dinfo, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
88 char* buf, size_t bufsize); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
89 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
90 void* |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
91 #ifdef DLL_ENTRY |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
92 DLL_ENTRY |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
93 #endif |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
94 decode_instructions(void* start_pv, void* end_pv, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
95 event_callback_t event_callback_arg, void* event_stream_arg, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
96 printf_callback_t printf_callback_arg, void* printf_stream_arg, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
97 const char* options) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
98 struct hsdis_app_data app_data; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
99 memset(&app_data, 0, sizeof(app_data)); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
100 app_data.start = (uintptr_t) start_pv; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
101 app_data.end = (uintptr_t) end_pv; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
102 app_data.event_callback = event_callback_arg; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
103 app_data.event_stream = event_stream_arg; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
104 app_data.printf_callback = printf_callback_arg; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
105 app_data.printf_stream = printf_stream_arg; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
106 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
107 setup_app_data(&app_data, options); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
108 char buf[128]; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
109 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
110 { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
111 /* now reload everything from app_data: */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
112 DECL_EVENT_CALLBACK(&app_data); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
113 DECL_PRINTF_CALLBACK(&app_data); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
114 uintptr_t start = app_data.start; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
115 uintptr_t end = app_data.end; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
116 uintptr_t p = start; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
117 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
118 (*event_callback)(event_stream, "insns", (void*)start); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
119 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
120 (*event_callback)(event_stream, "mach name='%s'", |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
121 (void*) app_data.arch_info->printable_name); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
122 if (app_data.dinfo.bytes_per_line != 0) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
123 (*event_callback)(event_stream, "format bytes-per-line='%p'/", |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
124 (void*)(intptr_t) app_data.dinfo.bytes_per_line); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
125 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
126 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
127 while (p < end && !app_data.losing) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
128 (*event_callback)(event_stream, "insn", (void*) p); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
129 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
130 /* reset certain state, so we can read it with confidence */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
131 app_data.dinfo.insn_info_valid = 0; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
132 app_data.dinfo.branch_delay_insns = 0; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
133 app_data.dinfo.data_size = 0; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
134 app_data.dinfo.insn_type = 0; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
135 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
136 int size = (*app_data.dfn)((bfd_vma) p, &app_data.dinfo); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
137 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
138 if (size > 0) p += size; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
139 else app_data.losing = true; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
140 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
141 const char* insn_close = format_insn_close("/insn", &app_data.dinfo, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
142 buf, sizeof(buf)); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
143 (*event_callback)(event_stream, insn_close, (void*) p); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
144 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
145 /* follow each complete insn by a nice newline */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
146 (*printf_callback)(printf_stream, "\n"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
147 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
148 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
149 (*event_callback)(event_stream, "/insns", (void*) p); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
150 return (void*) p; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
151 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
152 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
153 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
154 /* take the address of the function, for luck, and also test the typedef: */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
155 const decode_instructions_ftype decode_instructions_address = &decode_instructions; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
156 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
157 static const char* format_insn_close(const char* close, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
158 disassemble_info* dinfo, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
159 char* buf, size_t bufsize) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
160 if (!dinfo->insn_info_valid) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
161 return close; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
162 enum dis_insn_type itype = dinfo->insn_type; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
163 int dsize = dinfo->data_size, delays = dinfo->branch_delay_insns; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
164 if ((itype == dis_nonbranch && (dsize | delays) == 0) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
165 || (strlen(close) + 3*20 > bufsize)) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
166 return close; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
167 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
168 const char* type = "unknown"; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
169 switch (itype) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
170 case dis_nonbranch: type = NULL; break; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
171 case dis_branch: type = "branch"; break; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
172 case dis_condbranch: type = "condbranch"; break; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
173 case dis_jsr: type = "jsr"; break; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
174 case dis_condjsr: type = "condjsr"; break; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
175 case dis_dref: type = "dref"; break; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
176 case dis_dref2: type = "dref2"; break; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
177 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
178 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
179 strcpy(buf, close); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
180 char* p = buf; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
181 if (type) sprintf(p += strlen(p), " type='%s'", type); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
182 if (dsize) sprintf(p += strlen(p), " dsize='%d'", dsize); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
183 if (delays) sprintf(p += strlen(p), " delay='%d'", delays); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
184 return buf; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
185 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
186 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
187 /* handler functions */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
188 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
189 static int |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
190 hsdis_read_memory_func(bfd_vma memaddr, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
191 bfd_byte* myaddr, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
192 unsigned int length, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
193 struct disassemble_info* dinfo) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
194 uintptr_t memaddr_p = (uintptr_t) memaddr; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
195 DECL_APP_DATA(dinfo); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
196 if (memaddr_p + length > app_data->end) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
197 /* read is out of bounds */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
198 return EIO; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
199 } else { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
200 memcpy(myaddr, (bfd_byte*) memaddr_p, length); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
201 return 0; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
202 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
203 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
204 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
205 static void |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
206 hsdis_print_address_func(bfd_vma vma, struct disassemble_info* dinfo) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
207 /* the actual value to print: */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
208 void* addr_value = (void*) (uintptr_t) vma; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
209 DECL_APP_DATA(dinfo); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
210 DECL_EVENT_CALLBACK(app_data); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
211 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
212 /* issue the event: */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
213 void* result = |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
214 (*event_callback)(event_stream, "addr/", addr_value); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
215 if (result == NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
216 /* event declined */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
217 generic_print_address(vma, dinfo); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
218 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
219 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
220 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
221 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
222 /* configuration */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
223 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
224 static void set_optional_callbacks(struct hsdis_app_data* app_data); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
225 static void parse_caller_options(struct hsdis_app_data* app_data, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
226 const char* caller_options); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
227 static const char* native_arch_name(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
228 static enum bfd_endian native_endian(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
229 static const bfd_arch_info_type* find_arch_info(const char* arch_nane); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
230 static bfd* get_native_bfd(const bfd_arch_info_type* arch_info, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
231 /* to avoid malloc: */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
232 bfd* empty_bfd, bfd_target* empty_xvec); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
233 static void init_disassemble_info_from_bfd(struct disassemble_info* dinfo, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
234 void *stream, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
235 fprintf_ftype fprintf_func, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
236 bfd* bfd, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
237 char* disassembler_options); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
238 static void parse_fake_insn(disassembler_ftype dfn, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
239 struct disassemble_info* dinfo); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
240 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
241 static void setup_app_data(struct hsdis_app_data* app_data, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
242 const char* caller_options) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
243 /* Make reasonable defaults for null callbacks. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
244 A non-null stream for a null callback is assumed to be a FILE* for output. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
245 Events are rendered as XML. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
246 */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
247 set_optional_callbacks(app_data); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
248 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
249 /* Look into caller_options for anything interesting. */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
250 if (caller_options != NULL) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
251 parse_caller_options(app_data, caller_options); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
252 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
253 /* Discover which architecture we are going to disassemble. */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
254 app_data->arch_name = &app_data->mach_option[0]; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
255 if (app_data->arch_name[0] == '\0') |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
256 app_data->arch_name = native_arch_name(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
257 app_data->arch_info = find_arch_info(app_data->arch_name); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
258 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
259 /* Make a fake bfd to hold the arch. and byteorder info. */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
260 struct { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
261 bfd_target empty_xvec; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
262 bfd empty_bfd; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
263 } buf; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
264 bfd* native_bfd = get_native_bfd(app_data->arch_info, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
265 /* to avoid malloc: */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
266 &buf.empty_bfd, &buf.empty_xvec); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
267 init_disassemble_info_from_bfd(&app_data->dinfo, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
268 app_data->printf_stream, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
269 app_data->printf_callback, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
270 native_bfd, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
271 app_data->insn_options); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
272 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
273 /* Finish linking together the various callback blocks. */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
274 app_data->dinfo.application_data = (void*) app_data; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
275 app_data->dfn = disassembler(native_bfd); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
276 app_data->dinfo.print_address_func = hsdis_print_address_func; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
277 app_data->dinfo.read_memory_func = hsdis_read_memory_func; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
278 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
279 if (app_data->dfn == NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
280 const char* bad = app_data->arch_name; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
281 static bool complained; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
282 if (bad == &app_data->mach_option[0]) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
283 print_help(app_data, "bad mach=%s", bad); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
284 else if (!complained) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
285 print_help(app_data, "bad native mach=%s; please port hsdis to this platform", bad); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
286 complained = true; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
287 /* must bail out */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
288 app_data->losing = true; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
289 return; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
290 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
291 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
292 parse_fake_insn(app_data->dfn, &app_data->dinfo); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
293 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
294 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
295 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
296 /* ignore all events, return a null */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
297 static void* null_event_callback(void* ignore_stream, const char* ignore_event, void* arg) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
298 return NULL; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
299 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
300 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
301 /* print all events as XML markup */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
302 static void* xml_event_callback(void* stream, const char* event, void* arg) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
303 FILE* fp = (FILE*) stream; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
304 #define NS_PFX "dis:" |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
305 if (event[0] != '/') { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
306 /* issue the tag, with or without a formatted argument */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
307 fprintf(fp, "<"NS_PFX); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
308 fprintf(fp, event, arg); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
309 fprintf(fp, ">"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
310 } else { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
311 ++event; /* skip slash */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
312 const char* argp = strchr(event, ' '); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
313 if (argp == NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
314 /* no arguments; just issue the closing tag */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
315 fprintf(fp, "</"NS_PFX"%s>", event); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
316 } else { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
317 /* split out the closing attributes as <dis:foo_done attr='val'/> */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
318 int event_prefix = (argp - event); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
319 fprintf(fp, "<"NS_PFX"%.*s_done", event_prefix, event); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
320 fprintf(fp, argp, arg); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
321 fprintf(fp, "/></"NS_PFX"%.*s>", event_prefix, event); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
322 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
323 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
324 return NULL; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
325 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
326 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
327 static void set_optional_callbacks(struct hsdis_app_data* app_data) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
328 if (app_data->printf_callback == NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
329 int (*fprintf_callback)(FILE*, const char*, ...) = &fprintf; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
330 FILE* fprintf_stream = stdout; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
331 app_data->printf_callback = (printf_callback_t) fprintf_callback; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
332 if (app_data->printf_stream == NULL) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
333 app_data->printf_stream = (void*) fprintf_stream; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
334 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
335 if (app_data->event_callback == NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
336 if (app_data->event_stream == NULL) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
337 app_data->event_callback = &null_event_callback; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
338 else |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
339 app_data->event_callback = &xml_event_callback; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
340 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
341 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
342 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
343 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
344 static void parse_caller_options(struct hsdis_app_data* app_data, const char* caller_options) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
345 char* iop_base = app_data->insn_options; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
346 char* iop_limit = iop_base + sizeof(app_data->insn_options) - 1; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
347 char* iop = iop_base; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
348 const char* p; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
349 for (p = caller_options; p != NULL; ) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
350 const char* q = strchr(p, ','); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
351 size_t plen = (q == NULL) ? strlen(p) : ((q++) - p); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
352 if (plen == 4 && strncmp(p, "help", plen) == 0) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
353 print_help(app_data, NULL, NULL); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
354 } else if (plen >= 5 && strncmp(p, "mach=", 5) == 0) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
355 char* mach_option = app_data->mach_option; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
356 size_t mach_size = sizeof(app_data->mach_option); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
357 mach_size -= 1; /*leave room for the null*/ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
358 if (plen > mach_size) plen = mach_size; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
359 strncpy(mach_option, p, plen); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
360 mach_option[plen] = '\0'; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
361 } else if (plen > 6 && strncmp(p, "hsdis-", 6)) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
362 // do not pass these to the next level |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
363 } else { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
364 /* just copy it; {i386,sparc}-dis.c might like to see it */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
365 if (iop > iop_base && iop < iop_limit) (*iop++) = ','; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
366 if (iop + plen > iop_limit) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
367 plen = iop_limit - iop; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
368 strncpy(iop, p, plen); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
369 iop += plen; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
370 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
371 p = q; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
372 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
373 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
374 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
375 static void print_help(struct hsdis_app_data* app_data, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
376 const char* msg, const char* arg) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
377 DECL_PRINTF_CALLBACK(app_data); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
378 if (msg != NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
379 (*printf_callback)(printf_stream, "hsdis: "); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
380 (*printf_callback)(printf_stream, msg, arg); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
381 (*printf_callback)(printf_stream, "\n"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
382 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
383 (*printf_callback)(printf_stream, "hsdis output options:\n"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
384 if (printf_callback == (printf_callback_t) &fprintf) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
385 disassembler_usage((FILE*) printf_stream); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
386 else |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
387 disassembler_usage(stderr); /* better than nothing */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
388 (*printf_callback)(printf_stream, " mach=<arch> select disassembly mode\n"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
389 #if defined(LIBARCH_i386) || defined(LIBARCH_amd64) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
390 (*printf_callback)(printf_stream, " mach=i386 select 32-bit mode\n"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
391 (*printf_callback)(printf_stream, " mach=x86-64 select 64-bit mode\n"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
392 (*printf_callback)(printf_stream, " suffix always print instruction suffix\n"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
393 #endif |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
394 (*printf_callback)(printf_stream, " help print this message\n"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
395 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
396 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
397 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
398 /* low-level bfd and arch stuff that binutils doesn't do for us */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
399 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
400 static const bfd_arch_info_type* find_arch_info(const char* arch_name) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
401 const bfd_arch_info_type* arch_info = bfd_scan_arch(arch_name); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
402 if (arch_info == NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
403 extern const bfd_arch_info_type bfd_default_arch_struct; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
404 arch_info = &bfd_default_arch_struct; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
405 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
406 return arch_info; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
407 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
408 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
409 static const char* native_arch_name() { |
720
67a2f5ba5582
6684007: PrintAssembly plugin not available for linux or windows
never
parents:
100
diff
changeset
|
410 const char* res = NULL; |
67a2f5ba5582
6684007: PrintAssembly plugin not available for linux or windows
never
parents:
100
diff
changeset
|
411 #ifdef LIBARCH_i386 |
67a2f5ba5582
6684007: PrintAssembly plugin not available for linux or windows
never
parents:
100
diff
changeset
|
412 res = "i386"; |
67a2f5ba5582
6684007: PrintAssembly plugin not available for linux or windows
never
parents:
100
diff
changeset
|
413 #endif |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
414 #ifdef LIBARCH_amd64 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
415 res = "i386:x86-64"; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
416 #endif |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
417 #ifdef LIBARCH_sparc |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
418 res = "sparc:v8plusb"; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
419 #endif |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
420 #ifdef LIBARCH_sparcv9 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
421 res = "sparc:v9b"; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
422 #endif |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
423 if (res == NULL) |
720
67a2f5ba5582
6684007: PrintAssembly plugin not available for linux or windows
never
parents:
100
diff
changeset
|
424 res = "architecture not set in Makefile!"; |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
425 return res; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
426 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
427 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
428 static enum bfd_endian native_endian() { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
429 int32_t endian_test = 'x'; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
430 if (*(const char*) &endian_test == 'x') |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
431 return BFD_ENDIAN_LITTLE; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
432 else |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
433 return BFD_ENDIAN_BIG; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
434 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
435 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
436 static bfd* get_native_bfd(const bfd_arch_info_type* arch_info, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
437 bfd* empty_bfd, bfd_target* empty_xvec) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
438 memset(empty_bfd, 0, sizeof(*empty_bfd)); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
439 memset(empty_xvec, 0, sizeof(*empty_xvec)); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
440 empty_xvec->flavour = bfd_target_unknown_flavour; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
441 empty_xvec->byteorder = native_endian(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
442 empty_bfd->xvec = empty_xvec; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
443 empty_bfd->arch_info = arch_info; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
444 return empty_bfd; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
445 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
446 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
447 static int read_zero_data_only(bfd_vma ignore_p, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
448 bfd_byte* myaddr, unsigned int length, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
449 struct disassemble_info *ignore_info) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
450 memset(myaddr, 0, length); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
451 return 0; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
452 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
453 static int print_to_dev_null(void* ignore_stream, const char* ignore_format, ...) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
454 return 0; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
455 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
456 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
457 /* Prime the pump by running the selected disassembler on a null input. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
458 This forces the machine-specific disassembler to divulge invariant |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
459 information like bytes_per_line. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
460 */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
461 static void parse_fake_insn(disassembler_ftype dfn, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
462 struct disassemble_info* dinfo) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
463 typedef int (*read_memory_ftype) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
464 (bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
465 struct disassemble_info *info); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
466 read_memory_ftype read_memory_func = dinfo->read_memory_func; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
467 fprintf_ftype fprintf_func = dinfo->fprintf_func; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
468 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
469 dinfo->read_memory_func = &read_zero_data_only; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
470 dinfo->fprintf_func = &print_to_dev_null; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
471 (*dfn)(0, dinfo); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
472 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
473 // put it back: |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
474 dinfo->read_memory_func = read_memory_func; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
475 dinfo->fprintf_func = fprintf_func; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
476 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
477 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
478 static void init_disassemble_info_from_bfd(struct disassemble_info* dinfo, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
479 void *stream, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
480 fprintf_ftype fprintf_func, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
481 bfd* abfd, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
482 char* disassembler_options) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
483 init_disassemble_info(dinfo, stream, fprintf_func); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
484 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
485 dinfo->flavour = bfd_get_flavour(abfd); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
486 dinfo->arch = bfd_get_arch(abfd); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
487 dinfo->mach = bfd_get_mach(abfd); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
488 dinfo->disassembler_options = disassembler_options; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
489 dinfo->octets_per_byte = bfd_octets_per_byte (abfd); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
490 dinfo->skip_zeroes = sizeof(void*) * 2; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
491 dinfo->skip_zeroes_at_end = sizeof(void*)-1; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
492 dinfo->disassembler_needs_relocs = FALSE; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
493 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
494 if (bfd_big_endian(abfd)) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
495 dinfo->display_endian = dinfo->endian = BFD_ENDIAN_BIG; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
496 else if (bfd_little_endian(abfd)) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
497 dinfo->display_endian = dinfo->endian = BFD_ENDIAN_LITTLE; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
498 else |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
499 dinfo->endian = native_endian(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
500 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
501 disassemble_init_for_target(dinfo); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
502 } |