From: Nguyen A. Q. <aq...@gm...> - 2014-09-16 23:47:20
|
On Tue, Sep 16, 2014 at 11:20 PM, Peter Lucia <pe...@ro...> wrote: > Yes, I want disassemble LLVM bitcode to LLVM assembly. Basically I want > to do exactly what llvm-dis does, but I'd like to have > the programmatic bindings that capstone provides; ie: get list of all the > instructions with each instruction object having it's opcode, > source registers, and destination registers broken out in nice > Python/Ruby/C#/Java/etc. objects. Ideally, I'd like to use some of the > same tools already built (or that I build in the future) using capstone but > with LLVM bitcode files as source instead of *insert architecture here* > machine code files. Sorry for not being clear at first. > > I'll take a look at the llvm-dis source, the question really is how hard > will it be to integrate that source into capstone so we have API parity > with the other supported input machine languages. Thanks for any further > thoughts you have now or in the future regarding this! > the difference is that you would have to feed Capstone the whole LLVM bitcode binary file, not just a chunk of binary bytes like with machine code. i havent looked that the code of llm-dis, but i dont think this is too hard, as it does not involve any backend here. if you make it, please share the code. i am curious .... thanks. > Peter > > On Tue, Sep 16, 2014 at 10:10 AM, Nguyen Anh Quynh <aq...@gm...> > wrote: > >> >> >> On Tue, Sep 16, 2014 at 10:06 PM, Nguyen Anh Quynh <aq...@gm...> >> wrote: >> >>> >>> >>> On Tue, Sep 16, 2014 at 9:51 PM, Peter Lucia <pe...@ro...> >>> wrote: >>> >>>> Any thoughts on how hard it would be to implement? Note that I'm only >>>> trying to go to LLVM assembly code, not some other architecture's assembly >>>> code. Thanks >>>> >>> >>> do you mean generating machine code from LLVM bitcode? this involves the >>> backends of all related archs, and is quite different from what Capstone is >>> doing. so extending Capstone to do this is not the choice, but you need to >>> do that from scratch. >>> >>> to have a better idea, look at the source of llvm-dis. that is certainly >>> a lot of works. >>> >> >> i think i misunderstood your question: you actually want to disassemble >> LLVM bitcode to LLVM assembly, right? >> >> then it is much easier than generating machine code from LLVM bitcode, >> but again you should look at the source of llvm-dis. >> >> >> cheers, >> Q >> >> >>> >>> >>>> Peter >>>> >>>> On Tue, Sep 16, 2014 at 8:24 AM, Nguyen Anh Quynh <aq...@gm...> >>>> wrote: >>>> >>>>> >>>>> >>>>> On Tue, Sep 16, 2014 at 6:20 AM, Peter Lucia <pe...@ro...> >>>>> wrote: >>>>> >>>>>> Hello, >>>>>> >>>>>> Is LLVM Bitcode itself a supported input architecture? I have some >>>>>> files that have not yet been fully compiled to PowerPC or MIPS, but instead >>>>>> are still in LLVM Bitcode format (in other words, clang with the - >>>>>> emit-llvm option) and I'd love to use capstone to disassemble them >>>>>> pragmatically. >>>>>> >>>>>> If this is not already implemented, how hard would it be to do? Is >>>>>> there some other better way to do this? I'm using llvm-dis now, but it's >>>>>> not ideal for all the reasons capstone would seem to excel. >>>>>> >>>>>> >>>>> unfortunately no. the main idea of Capstone is to disassemble machine >>>>> binary code back to assembly code. so Capstone does not, and will never >>>>> convert LLVM bitcode back to assembly for you. >>>>> >>>>> >>>>> thanks. >>>>> Q >>>>> >>>> >>>> >>> > |