A good diassembler?

Programming, for all ages and all languages.
Post Reply
junkoi
Member
Member
Posts: 63
Joined: Wed Jan 23, 2008 8:55 pm

A good diassembler?

Post by junkoi »

Hi,

I am wring some code that mix 16bit and 32bit code in asm and C. To fight some bugs I am having, I need to diassemble the code. Unfortunately I found that objdump is horrible: it very often produces bad disassembly that is very different from the source, so I cannot understand where the problem is.

I use objdump with option "-S -d". So could anybody tell if if there is a way to have objdump worked better?

Or: Is there a more reliable disassembler than objdump for what I want to do?

Thanks,
J
jzgriffin
Member
Member
Posts: 190
Joined: Tue Sep 26, 2006 1:40 pm
Libera.chat IRC: Nokurn
Location: Ontario, CA, USA
Contact:

Post by jzgriffin »

I use ndisasm, the nasm disassembler. Just strip the location and hex dump columns from the disassembly and you'll have a reassemblable output ready to go through nasm. It replaces data with opcodes, though - but in the end it looks the same in the output file.
junkoi
Member
Member
Posts: 63
Joined: Wed Jan 23, 2008 8:55 pm

Post by junkoi »

Jeremiah Griffin wrote:I use ndisasm, the nasm disassembler. Just strip the location and hex dump columns from the disassembly and you'll have a reassemblable output ready to go through nasm. It replaces data with opcodes, though - but in the end it looks the same in the output file.
I tried ndisasm before, but the output looks quite confused, because it doesnt come with C source code like objdump (the -S option of objdump is good!). And ndisasm only produces pure assembly, without any symbols that can help to quickly understand the code??

Any idea?

Thanks,
J
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

I suggest you get used to reading assembly. objdump is an extremely good disassembler - what you're actually asking for is a decompiler, of which there are few, and fewer good ones. I use "objdump -d" and interpret the assembly, as I know many others do.
junkoi
Member
Member
Posts: 63
Joined: Wed Jan 23, 2008 8:55 pm

Post by junkoi »

JamesM wrote:I suggest you get used to reading assembly. objdump is an extremely good disassembler - what you're actually asking for is a decompiler, of which there are few, and fewer good ones. I use "objdump -d" and interpret the assembly, as I know many others do.
In my experience, objdump produces very bad assembly output, which is completely wrong almost all the time on my code. So I cannot say that objdump is a good one, at least for 16bit code.

Meanwhile, ndisasm produces very nice and correct assembly code, The only problem is that it cannot corporate source code like objdump does.

Currently I use objdump to have a look first, then if something is wrong (mostly), I get the related opcode, and search for them on the output of ndisasm to see what it actually does. But this is very inconvenient, so I want to know if there is a "2-in-1" tool to do everything correctly and nicely.

Thanks,
J
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

In what respect is the output wrong? Could you post a snippet of where it goes wrong?

Cheers,

James
User avatar
binutils
Member
Member
Posts: 214
Joined: Thu Apr 05, 2007 6:07 am

Post by binutils »

Last edited by binutils on Tue Apr 01, 2008 5:43 am, edited 1 time in total.
exkor
Member
Member
Posts: 111
Joined: Wed May 23, 2007 9:38 pm

Post by exkor »

IDA
If it doesn't know file format(PE,ELF) then you need to tell yourself where code/data start. Same goes for mixed (16/32/64bit) code.
IDA 4.9 is free for non commercial use, lacks some features - don't know which.
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Post by 01000101 »

I use IDA as well.
I use it for both the disassembly mode and decompiling feature.
junkoi
Member
Member
Posts: 63
Joined: Wed Jan 23, 2008 8:55 pm

Post by junkoi »

JamesM wrote:In what respect is the output wrong? Could you post a snippet of where it goes wrong?
Sorry that I have no code here, but you can try to compile some 16bit code with ".code16gcc" directive. Somehow objdump fails to understand when the code use override prefixes for address and data.

Thanks,
J
User avatar
devel
Member
Member
Posts: 62
Joined: Wed Nov 28, 2007 4:15 am
Contact:

Post by devel »

junkoi wrote: Sorry that I have no code here, but you can try to compile some 16bit code with ".code16gcc" directive. Somehow objdump fails to understand when the code use override prefixes for address and data.
I think in case you are trying to disasembly 8086 code with objdump this `-m i8086' switch should be used.
iammisc
Member
Member
Posts: 269
Joined: Thu Nov 09, 2006 6:23 pm

Post by iammisc »

In my experience, objdump produces very bad assembly output, which is completely wrong almost all the time on my code. So I cannot say that objdump is a good one, at least for 16bit code.
IIRC, that's because you're using it wrong. You're supposed to pass a command line option to switch it to 16-bit mode.
junkoi
Member
Member
Posts: 63
Joined: Wed Jan 23, 2008 8:55 pm

Post by junkoi »

devel wrote:
junkoi wrote: Sorry that I have no code here, but you can try to compile some 16bit code with ".code16gcc" directive. Somehow objdump fails to understand when the code use override prefixes for address and data.
I think in case you are trying to disasembly 8086 code with objdump this `-m i8086' switch should be used.
devel, thanks so much for your suggestion! -m i8086 works perfectly for me!!!!!!

Best,
J
Post Reply