jrose@535: /* simonis@6456: * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. jrose@535: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jrose@535: * jrose@535: * This code is free software; you can redistribute it and/or modify it jrose@535: * under the terms of the GNU General Public License version 2 only, as jrose@535: * published by the Free Software Foundation. jrose@535: * jrose@535: * This code is distributed in the hope that it will be useful, but WITHOUT jrose@535: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jrose@535: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jrose@535: * version 2 for more details (a copy is included in the LICENSE file that jrose@535: * accompanied this code). jrose@535: * jrose@535: * You should have received a copy of the GNU General Public License version jrose@535: * 2 along with this work; if not, write to the Free Software Foundation, jrose@535: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jrose@535: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. jrose@535: * jrose@535: */ jrose@535: jrose@535: /* hsdis.c -- dump a range of addresses as native instructions jrose@535: This implements the plugin protocol required by the jrose@535: HotSpot PrintAssembly option. jrose@535: */ jrose@535: anoll@5152: #include /* required by bfd.h */ jrose@535: #include jrose@535: #include jrose@535: #include never@1155: #include minqi@4093: #include minqi@4093: #include minqi@4093: #include "hsdis.h" jrose@535: jrose@535: #ifndef bool jrose@535: #define bool int jrose@535: #define true 1 jrose@535: #define false 0 jrose@535: #endif /*bool*/ jrose@535: jrose@535: /* short names for stuff in hsdis.h */ jrose@535: typedef decode_instructions_event_callback_ftype event_callback_t; jrose@535: typedef decode_instructions_printf_callback_ftype printf_callback_t; jrose@535: jrose@535: /* disassemble_info.application_data object */ jrose@535: struct hsdis_app_data { minqi@4093: /* virtual address of data */ minqi@4093: uintptr_t start_va, end_va; minqi@4093: /* the instructions to be decoded */ minqi@4093: unsigned char* buffer; minqi@4093: uintptr_t length; jrose@535: event_callback_t event_callback; void* event_stream; jrose@535: printf_callback_t printf_callback; void* printf_stream; jrose@535: bool losing; minqi@4093: bool do_newline; jrose@535: jrose@535: /* the architecture being disassembled */ jrose@535: const char* arch_name; jrose@535: const bfd_arch_info_type* arch_info; jrose@535: jrose@535: /* the disassembler we are going to use: */ jrose@535: disassembler_ftype dfn; jrose@535: struct disassemble_info dinfo; /* the actual struct! */ jrose@535: jrose@535: char mach_option[64]; jrose@535: char insn_options[256]; jrose@535: }; jrose@535: minqi@4093: static void* decode(struct hsdis_app_data* app_data, const char* options); minqi@4093: jrose@535: #define DECL_APP_DATA(dinfo) \ jrose@535: struct hsdis_app_data* app_data = (struct hsdis_app_data*) (dinfo)->application_data jrose@535: jrose@535: #define DECL_EVENT_CALLBACK(app_data) \ jrose@535: event_callback_t event_callback = (app_data)->event_callback; \ jrose@535: void* event_stream = (app_data)->event_stream jrose@535: jrose@535: #define DECL_PRINTF_CALLBACK(app_data) \ jrose@535: printf_callback_t printf_callback = (app_data)->printf_callback; \ jrose@535: void* printf_stream = (app_data)->printf_stream jrose@535: jrose@535: jrose@535: static void print_help(struct hsdis_app_data* app_data, jrose@535: const char* msg, const char* arg); jrose@535: static void setup_app_data(struct hsdis_app_data* app_data, jrose@535: const char* options); jrose@535: static const char* format_insn_close(const char* close, jrose@535: disassemble_info* dinfo, jrose@535: char* buf, size_t bufsize); jrose@535: jrose@535: void* jrose@535: #ifdef DLL_ENTRY jrose@535: DLL_ENTRY jrose@535: #endif minqi@4093: decode_instructions_virtual(uintptr_t start_va, uintptr_t end_va, minqi@4093: unsigned char* buffer, uintptr_t length, minqi@4093: event_callback_t event_callback_arg, void* event_stream_arg, minqi@4093: printf_callback_t printf_callback_arg, void* printf_stream_arg, minqi@4244: const char* options, int newline) { minqi@4093: struct hsdis_app_data app_data; minqi@4093: memset(&app_data, 0, sizeof(app_data)); minqi@4093: app_data.start_va = start_va; minqi@4093: app_data.end_va = end_va; minqi@4093: app_data.buffer = buffer; minqi@4093: app_data.length = length; minqi@4093: app_data.event_callback = event_callback_arg; minqi@4093: app_data.event_stream = event_stream_arg; minqi@4093: app_data.printf_callback = printf_callback_arg; minqi@4093: app_data.printf_stream = printf_stream_arg; minqi@4244: app_data.do_newline = newline == 0 ? false : true; minqi@4093: minqi@4093: return decode(&app_data, options); minqi@4093: } minqi@4093: minqi@4093: /* This is the compatability interface for older version of hotspot */ minqi@4093: void* minqi@4093: #ifdef DLL_ENTRY minqi@4093: DLL_ENTRY minqi@4093: #endif jrose@535: decode_instructions(void* start_pv, void* end_pv, jrose@535: event_callback_t event_callback_arg, void* event_stream_arg, jrose@535: printf_callback_t printf_callback_arg, void* printf_stream_arg, jrose@535: const char* options) { minqi@4093: decode_instructions_virtual((uintptr_t)start_pv, minqi@4093: (uintptr_t)end_pv, minqi@4093: (unsigned char*)start_pv, minqi@4093: (uintptr_t)end_pv - (uintptr_t)start_pv, minqi@4093: event_callback_arg, minqi@4093: event_stream_arg, minqi@4093: printf_callback_arg, minqi@4093: printf_stream_arg, minqi@4244: options, false); minqi@4093: } jrose@535: minqi@4093: static void* decode(struct hsdis_app_data* app_data, const char* options) { minqi@4093: setup_app_data(app_data, options); jrose@535: char buf[128]; jrose@535: jrose@535: { jrose@535: /* now reload everything from app_data: */ minqi@4093: DECL_EVENT_CALLBACK(app_data); minqi@4093: DECL_PRINTF_CALLBACK(app_data); minqi@4093: uintptr_t start = app_data->start_va; minqi@4093: uintptr_t end = app_data->end_va; jrose@535: uintptr_t p = start; jrose@535: jrose@535: (*event_callback)(event_stream, "insns", (void*)start); jrose@535: jrose@535: (*event_callback)(event_stream, "mach name='%s'", minqi@4093: (void*) app_data->arch_info->printable_name); minqi@4093: if (app_data->dinfo.bytes_per_line != 0) { jrose@535: (*event_callback)(event_stream, "format bytes-per-line='%p'/", minqi@4093: (void*)(intptr_t) app_data->dinfo.bytes_per_line); jrose@535: } jrose@535: minqi@4093: while (p < end && !app_data->losing) { jrose@535: (*event_callback)(event_stream, "insn", (void*) p); jrose@535: jrose@535: /* reset certain state, so we can read it with confidence */ minqi@4093: app_data->dinfo.insn_info_valid = 0; minqi@4093: app_data->dinfo.branch_delay_insns = 0; minqi@4093: app_data->dinfo.data_size = 0; minqi@4093: app_data->dinfo.insn_type = 0; jrose@535: minqi@4093: int size = (*app_data->dfn)((bfd_vma) p, &app_data->dinfo); jrose@535: jrose@535: if (size > 0) p += size; minqi@4093: else app_data->losing = true; jrose@535: minqi@4093: if (!app_data->losing) { minqi@4093: const char* insn_close = format_insn_close("/insn", &app_data->dinfo, minqi@4093: buf, sizeof(buf)); minqi@4244: (*event_callback)(event_stream, insn_close, (void*) p); jrose@535: minqi@4093: if (app_data->do_newline) { minqi@4093: /* follow each complete insn by a nice newline */ minqi@4093: (*printf_callback)(printf_stream, "\n"); minqi@4093: } minqi@4093: } jrose@535: } jrose@535: minqi@4244: if (app_data->losing) (*event_callback)(event_stream, "/insns", (void*) p); jrose@535: return (void*) p; jrose@535: } jrose@535: } jrose@535: jrose@535: /* take the address of the function, for luck, and also test the typedef: */ minqi@4244: const decode_func_vtype decode_func_virtual_address = &decode_instructions_virtual; minqi@4244: const decode_func_stype decode_func_address = &decode_instructions; jrose@535: jrose@535: static const char* format_insn_close(const char* close, jrose@535: disassemble_info* dinfo, jrose@535: char* buf, size_t bufsize) { jrose@535: if (!dinfo->insn_info_valid) jrose@535: return close; jrose@535: enum dis_insn_type itype = dinfo->insn_type; jrose@535: int dsize = dinfo->data_size, delays = dinfo->branch_delay_insns; jrose@535: if ((itype == dis_nonbranch && (dsize | delays) == 0) jrose@535: || (strlen(close) + 3*20 > bufsize)) jrose@535: return close; jrose@535: jrose@535: const char* type = "unknown"; jrose@535: switch (itype) { jrose@535: case dis_nonbranch: type = NULL; break; jrose@535: case dis_branch: type = "branch"; break; jrose@535: case dis_condbranch: type = "condbranch"; break; jrose@535: case dis_jsr: type = "jsr"; break; jrose@535: case dis_condjsr: type = "condjsr"; break; jrose@535: case dis_dref: type = "dref"; break; jrose@535: case dis_dref2: type = "dref2"; break; jrose@535: } jrose@535: jrose@535: strcpy(buf, close); jrose@535: char* p = buf; jrose@535: if (type) sprintf(p += strlen(p), " type='%s'", type); jrose@535: if (dsize) sprintf(p += strlen(p), " dsize='%d'", dsize); jrose@535: if (delays) sprintf(p += strlen(p), " delay='%d'", delays); jrose@535: return buf; jrose@535: } jrose@535: jrose@535: /* handler functions */ jrose@535: jrose@535: static int jrose@535: hsdis_read_memory_func(bfd_vma memaddr, jrose@535: bfd_byte* myaddr, jrose@535: unsigned int length, jrose@535: struct disassemble_info* dinfo) { jrose@535: DECL_APP_DATA(dinfo); minqi@4093: /* convert the virtual address memaddr into an address within memory buffer */ minqi@4093: uintptr_t offset = ((uintptr_t) memaddr) - app_data->start_va; minqi@4093: if (offset + length > app_data->length) { jrose@535: /* read is out of bounds */ jrose@535: return EIO; jrose@535: } else { minqi@4093: memcpy(myaddr, (bfd_byte*) (app_data->buffer + offset), length); jrose@535: return 0; jrose@535: } jrose@535: } jrose@535: jrose@535: static void jrose@535: hsdis_print_address_func(bfd_vma vma, struct disassemble_info* dinfo) { jrose@535: /* the actual value to print: */ jrose@535: void* addr_value = (void*) (uintptr_t) vma; jrose@535: DECL_APP_DATA(dinfo); jrose@535: DECL_EVENT_CALLBACK(app_data); jrose@535: jrose@535: /* issue the event: */ jrose@535: void* result = jrose@535: (*event_callback)(event_stream, "addr/", addr_value); jrose@535: if (result == NULL) { jrose@535: /* event declined */ jrose@535: generic_print_address(vma, dinfo); jrose@535: } jrose@535: } jrose@535: jrose@535: jrose@535: /* configuration */ jrose@535: jrose@535: static void set_optional_callbacks(struct hsdis_app_data* app_data); jrose@535: static void parse_caller_options(struct hsdis_app_data* app_data, jrose@535: const char* caller_options); jrose@535: static const char* native_arch_name(); jrose@535: static enum bfd_endian native_endian(); jrose@535: static const bfd_arch_info_type* find_arch_info(const char* arch_nane); jrose@535: static bfd* get_native_bfd(const bfd_arch_info_type* arch_info, jrose@535: /* to avoid malloc: */ jrose@535: bfd* empty_bfd, bfd_target* empty_xvec); jrose@535: static void init_disassemble_info_from_bfd(struct disassemble_info* dinfo, jrose@535: void *stream, jrose@535: fprintf_ftype fprintf_func, jrose@535: bfd* bfd, jrose@535: char* disassembler_options); jrose@535: static void parse_fake_insn(disassembler_ftype dfn, jrose@535: struct disassemble_info* dinfo); jrose@535: jrose@535: static void setup_app_data(struct hsdis_app_data* app_data, jrose@535: const char* caller_options) { jrose@535: /* Make reasonable defaults for null callbacks. jrose@535: A non-null stream for a null callback is assumed to be a FILE* for output. jrose@535: Events are rendered as XML. jrose@535: */ jrose@535: set_optional_callbacks(app_data); jrose@535: jrose@535: /* Look into caller_options for anything interesting. */ jrose@535: if (caller_options != NULL) jrose@535: parse_caller_options(app_data, caller_options); jrose@535: jrose@535: /* Discover which architecture we are going to disassemble. */ jrose@535: app_data->arch_name = &app_data->mach_option[0]; jrose@535: if (app_data->arch_name[0] == '\0') jrose@535: app_data->arch_name = native_arch_name(); jrose@535: app_data->arch_info = find_arch_info(app_data->arch_name); jrose@535: jrose@535: /* Make a fake bfd to hold the arch. and byteorder info. */ jrose@535: struct { jrose@535: bfd_target empty_xvec; jrose@535: bfd empty_bfd; jrose@535: } buf; jrose@535: bfd* native_bfd = get_native_bfd(app_data->arch_info, jrose@535: /* to avoid malloc: */ jrose@535: &buf.empty_bfd, &buf.empty_xvec); jrose@535: init_disassemble_info_from_bfd(&app_data->dinfo, jrose@535: app_data->printf_stream, jrose@535: app_data->printf_callback, jrose@535: native_bfd, simonis@6456: /* On PowerPC we get warnings, if we pass empty options */ simonis@6456: (caller_options == NULL) ? NULL : app_data->insn_options); jrose@535: jrose@535: /* Finish linking together the various callback blocks. */ jrose@535: app_data->dinfo.application_data = (void*) app_data; jrose@535: app_data->dfn = disassembler(native_bfd); jrose@535: app_data->dinfo.print_address_func = hsdis_print_address_func; jrose@535: app_data->dinfo.read_memory_func = hsdis_read_memory_func; jrose@535: jrose@535: if (app_data->dfn == NULL) { jrose@535: const char* bad = app_data->arch_name; jrose@535: static bool complained; jrose@535: if (bad == &app_data->mach_option[0]) jrose@535: print_help(app_data, "bad mach=%s", bad); jrose@535: else if (!complained) jrose@535: print_help(app_data, "bad native mach=%s; please port hsdis to this platform", bad); jrose@535: complained = true; jrose@535: /* must bail out */ jrose@535: app_data->losing = true; jrose@535: return; jrose@535: } jrose@535: jrose@535: parse_fake_insn(app_data->dfn, &app_data->dinfo); jrose@535: } jrose@535: jrose@535: jrose@535: /* ignore all events, return a null */ jrose@535: static void* null_event_callback(void* ignore_stream, const char* ignore_event, void* arg) { jrose@535: return NULL; jrose@535: } jrose@535: jrose@535: /* print all events as XML markup */ jrose@535: static void* xml_event_callback(void* stream, const char* event, void* arg) { jrose@535: FILE* fp = (FILE*) stream; jrose@535: #define NS_PFX "dis:" jrose@535: if (event[0] != '/') { jrose@535: /* issue the tag, with or without a formatted argument */ jrose@535: fprintf(fp, "<"NS_PFX); jrose@535: fprintf(fp, event, arg); jrose@535: fprintf(fp, ">"); jrose@535: } else { jrose@535: ++event; /* skip slash */ jrose@535: const char* argp = strchr(event, ' '); jrose@535: if (argp == NULL) { jrose@535: /* no arguments; just issue the closing tag */ jrose@535: fprintf(fp, "", event); jrose@535: } else { jrose@535: /* split out the closing attributes as */ jrose@535: int event_prefix = (argp - event); jrose@535: fprintf(fp, "<"NS_PFX"%.*s_done", event_prefix, event); jrose@535: fprintf(fp, argp, arg); jrose@535: fprintf(fp, "/>", event_prefix, event); jrose@535: } jrose@535: } jrose@535: return NULL; jrose@535: } jrose@535: jrose@535: static void set_optional_callbacks(struct hsdis_app_data* app_data) { jrose@535: if (app_data->printf_callback == NULL) { jrose@535: int (*fprintf_callback)(FILE*, const char*, ...) = &fprintf; jrose@535: FILE* fprintf_stream = stdout; jrose@535: app_data->printf_callback = (printf_callback_t) fprintf_callback; jrose@535: if (app_data->printf_stream == NULL) jrose@535: app_data->printf_stream = (void*) fprintf_stream; jrose@535: } jrose@535: if (app_data->event_callback == NULL) { jrose@535: if (app_data->event_stream == NULL) jrose@535: app_data->event_callback = &null_event_callback; jrose@535: else jrose@535: app_data->event_callback = &xml_event_callback; jrose@535: } jrose@535: jrose@535: } jrose@535: jrose@535: static void parse_caller_options(struct hsdis_app_data* app_data, const char* caller_options) { jrose@535: char* iop_base = app_data->insn_options; jrose@535: char* iop_limit = iop_base + sizeof(app_data->insn_options) - 1; jrose@535: char* iop = iop_base; jrose@535: const char* p; jrose@535: for (p = caller_options; p != NULL; ) { jrose@535: const char* q = strchr(p, ','); jrose@535: size_t plen = (q == NULL) ? strlen(p) : ((q++) - p); jrose@535: if (plen == 4 && strncmp(p, "help", plen) == 0) { jrose@535: print_help(app_data, NULL, NULL); jrose@535: } else if (plen >= 5 && strncmp(p, "mach=", 5) == 0) { jrose@535: char* mach_option = app_data->mach_option; jrose@535: size_t mach_size = sizeof(app_data->mach_option); jrose@535: mach_size -= 1; /*leave room for the null*/ jrose@535: if (plen > mach_size) plen = mach_size; jrose@535: strncpy(mach_option, p, plen); jrose@535: mach_option[plen] = '\0'; kvn@3565: } else if (plen > 6 && strncmp(p, "hsdis-", 6) == 0) { jrose@535: // do not pass these to the next level jrose@535: } else { jrose@535: /* just copy it; {i386,sparc}-dis.c might like to see it */ jrose@535: if (iop > iop_base && iop < iop_limit) (*iop++) = ','; jrose@535: if (iop + plen > iop_limit) jrose@535: plen = iop_limit - iop; jrose@535: strncpy(iop, p, plen); jrose@535: iop += plen; jrose@535: } jrose@535: p = q; jrose@535: } jrose@535: } jrose@535: jrose@535: static void print_help(struct hsdis_app_data* app_data, jrose@535: const char* msg, const char* arg) { jrose@535: DECL_PRINTF_CALLBACK(app_data); jrose@535: if (msg != NULL) { jrose@535: (*printf_callback)(printf_stream, "hsdis: "); jrose@535: (*printf_callback)(printf_stream, msg, arg); jrose@535: (*printf_callback)(printf_stream, "\n"); jrose@535: } jrose@535: (*printf_callback)(printf_stream, "hsdis output options:\n"); jrose@535: if (printf_callback == (printf_callback_t) &fprintf) jrose@535: disassembler_usage((FILE*) printf_stream); jrose@535: else jrose@535: disassembler_usage(stderr); /* better than nothing */ jrose@535: (*printf_callback)(printf_stream, " mach= select disassembly mode\n"); jrose@535: #if defined(LIBARCH_i386) || defined(LIBARCH_amd64) jrose@535: (*printf_callback)(printf_stream, " mach=i386 select 32-bit mode\n"); jrose@535: (*printf_callback)(printf_stream, " mach=x86-64 select 64-bit mode\n"); jrose@535: (*printf_callback)(printf_stream, " suffix always print instruction suffix\n"); jrose@535: #endif jrose@535: (*printf_callback)(printf_stream, " help print this message\n"); jrose@535: } jrose@535: jrose@535: jrose@535: /* low-level bfd and arch stuff that binutils doesn't do for us */ jrose@535: jrose@535: static const bfd_arch_info_type* find_arch_info(const char* arch_name) { jrose@535: const bfd_arch_info_type* arch_info = bfd_scan_arch(arch_name); jrose@535: if (arch_info == NULL) { jrose@535: extern const bfd_arch_info_type bfd_default_arch_struct; jrose@535: arch_info = &bfd_default_arch_struct; jrose@535: } jrose@535: return arch_info; jrose@535: } jrose@535: jrose@535: static const char* native_arch_name() { never@1155: const char* res = NULL; never@1155: #ifdef LIBARCH_i386 minqi@4093: res = "i386"; never@1155: #endif jrose@535: #ifdef LIBARCH_amd64 minqi@4093: res = "i386:x86-64"; jrose@535: #endif jrose@535: #ifdef LIBARCH_sparc minqi@4093: res = "sparc:v8plusb"; jrose@535: #endif jrose@535: #ifdef LIBARCH_sparcv9 minqi@4093: res = "sparc:v9b"; jrose@535: #endif simonis@6456: #ifdef LIBARCH_ppc64 simonis@6456: res = "powerpc:common64"; simonis@6456: #endif jrose@535: if (res == NULL) never@1155: res = "architecture not set in Makefile!"; jrose@535: return res; jrose@535: } jrose@535: jrose@535: static enum bfd_endian native_endian() { jrose@535: int32_t endian_test = 'x'; jrose@535: if (*(const char*) &endian_test == 'x') jrose@535: return BFD_ENDIAN_LITTLE; jrose@535: else jrose@535: return BFD_ENDIAN_BIG; jrose@535: } jrose@535: jrose@535: static bfd* get_native_bfd(const bfd_arch_info_type* arch_info, jrose@535: bfd* empty_bfd, bfd_target* empty_xvec) { jrose@535: memset(empty_bfd, 0, sizeof(*empty_bfd)); jrose@535: memset(empty_xvec, 0, sizeof(*empty_xvec)); jrose@535: empty_xvec->flavour = bfd_target_unknown_flavour; jrose@535: empty_xvec->byteorder = native_endian(); jrose@535: empty_bfd->xvec = empty_xvec; jrose@535: empty_bfd->arch_info = arch_info; jrose@535: return empty_bfd; jrose@535: } jrose@535: jrose@535: static int read_zero_data_only(bfd_vma ignore_p, jrose@535: bfd_byte* myaddr, unsigned int length, jrose@535: struct disassemble_info *ignore_info) { jrose@535: memset(myaddr, 0, length); jrose@535: return 0; jrose@535: } jrose@535: static int print_to_dev_null(void* ignore_stream, const char* ignore_format, ...) { jrose@535: return 0; jrose@535: } jrose@535: jrose@535: /* Prime the pump by running the selected disassembler on a null input. jrose@535: This forces the machine-specific disassembler to divulge invariant jrose@535: information like bytes_per_line. jrose@535: */ jrose@535: static void parse_fake_insn(disassembler_ftype dfn, jrose@535: struct disassemble_info* dinfo) { jrose@535: typedef int (*read_memory_ftype) jrose@535: (bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, jrose@535: struct disassemble_info *info); jrose@535: read_memory_ftype read_memory_func = dinfo->read_memory_func; jrose@535: fprintf_ftype fprintf_func = dinfo->fprintf_func; jrose@535: jrose@535: dinfo->read_memory_func = &read_zero_data_only; jrose@535: dinfo->fprintf_func = &print_to_dev_null; jrose@535: (*dfn)(0, dinfo); jrose@535: minqi@4093: /* put it back */ jrose@535: dinfo->read_memory_func = read_memory_func; jrose@535: dinfo->fprintf_func = fprintf_func; jrose@535: } jrose@535: jrose@535: static void init_disassemble_info_from_bfd(struct disassemble_info* dinfo, jrose@535: void *stream, jrose@535: fprintf_ftype fprintf_func, jrose@535: bfd* abfd, jrose@535: char* disassembler_options) { jrose@535: init_disassemble_info(dinfo, stream, fprintf_func); jrose@535: jrose@535: dinfo->flavour = bfd_get_flavour(abfd); jrose@535: dinfo->arch = bfd_get_arch(abfd); jrose@535: dinfo->mach = bfd_get_mach(abfd); jrose@535: dinfo->disassembler_options = disassembler_options; jrose@535: dinfo->octets_per_byte = bfd_octets_per_byte (abfd); jrose@535: dinfo->skip_zeroes = sizeof(void*) * 2; jrose@535: dinfo->skip_zeroes_at_end = sizeof(void*)-1; jrose@535: dinfo->disassembler_needs_relocs = FALSE; jrose@535: jrose@535: if (bfd_big_endian(abfd)) jrose@535: dinfo->display_endian = dinfo->endian = BFD_ENDIAN_BIG; jrose@535: else if (bfd_little_endian(abfd)) jrose@535: dinfo->display_endian = dinfo->endian = BFD_ENDIAN_LITTLE; jrose@535: else jrose@535: dinfo->endian = native_endian(); jrose@535: jrose@535: disassemble_init_for_target(dinfo); jrose@535: }