This is the mail archive of the
mailing list for the binutils project.
Re: open source disassembler library recommended
- From: Nick Clifton <nickc at redhat dot com>
- To: 慕冬亮 <mudongliangabcd at gmail dot com>, binutils at sourceware dot org
- Date: Fri, 4 Aug 2017 08:52:06 +0100
- Subject: Re: open source disassembler library recommended
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=nickc at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2A57DC0587D1
- References: <CAD-N9QVm8dCY3guDqJyo7tTdc47v5zFCNKMGj3bDK2e020ba0A@mail.gmail.com>
> could you guys recommend an open source disassembler library.
Well, since you have posted to the binutils list, I am definitely
going to recommend the libopcodes library. To be honest though,
I do not know about other disassembler libraries, so there is
nothing else that I could recommend.
> Originally I want to try libopcodes in the binutils, but it seems not
> easy to learn and modify.
True, but I suspect that this will happen with any disassembler library
that you encounter.
If you want to see some simple examples of how to use libopcodes to
disassemble an instruction, have a look at the simulator sources. For
example have a look at <binutils/gdb sources>/sim/rx/trace.c. The
function sim_disasm_one() prints out the disassembly of a single RX
instruction (along with various other info, like the source line number
and so on). It uses the libopcodes function print_insn_rx() to do this.
You can use this code as a template for whatever it is that you want to do.
Note - although this example applies to the RX architecture, similar
code can be used for any architecture supported by the libopces library.