Skip to contentSkip to conversation

Funny Bash Script ...

Qemu-devel Herbert Poetzl 4 participants 5 messages Feb 13, 2005

lore
Share & tools
lore
#0 lore raw

Hi Folks!

there is a funny bash script available at

http://vserver.13thfloor.at/Stuff/QEMU/rev_01.sh

using this on object files (like the kqemu-mod-i386.o) produces interesting output, which will compile nicely with gcc to something very similar of the original ..

it's a quick and dirty hack, so naturally far away from being perfect (for example it doesn't rebuild non .text sections yet) and of course I would not suggest to use it on before mentioned object file ...

best,
Herbert

#1 lore raw
Quoted 10 lines · Herbert Poetzl

Hi Folks!

there is a funny bash script available at

http://vserver.13thfloor.at/Stuff/QEMU/rev_01.sh

using this on object files (like the kqemu-mod-i386.o) produces interesting output, which will compile nicely with gcc to something very similar of the original ..

Anyone can disassemble a binary and re-compile it. Understanding exactly how it works is another story entirely. I believe you would be in violation of the license if you distributed the de-compiled source, so what do you gain by doing this?

In addition, we are talking kernel code here. The sort of stuff where random compiler optimisations can cause catastrophic failures. Can you guarantee by doing this you are generating exactly the same code as you started with? I would certainly be loathe to trust the compiled binary.

Brad

Signature · 3 lines
"Human beings, who are almost unique in having the ability
to learn from the experience of others, are also remarkable
for their apparent disinclination to do so." -- Douglas Adams
#3 lore raw
In reply to Herbert Poetzl
Quoted 4 lines · Herbert Poetzl

there is a funny bash script available at

http://vserver.13thfloor.at/Stuff/QEMU/rev_01.sh

Quoted 8 lines

using this on object files (like the kqemu-mod-i386.o) produces interesting output, which will compile nicely with gcc to something very similar of the original ..

it's a quick and dirty hack, so naturally far away from being perfect (for example it doesn't rebuild non .text sections yet) and of course I would not suggest to use it on before mentioned object file ...

Hi,

Ok, so you just (re)invented dissassembler that produces compilable output. There are of course better ones (that for example are trying to make C code out of its output).

Using it may be illegal in some countries. Maybe in some not. But this is clearly against the author who gave it to you for free but with no source.

I can bet that any programmer who knows assembler a little can disassemble that file (come on its only 36 kilo!) by hand using anything and put the result into C code. I know about better challenges. For example try to disassemble (and understand) normal PC BIOS. It is really something challenging. And some people did this in the past (you think how companies other than IBM got the BIOS production technology?). BIOS is a mix of awfull hacks (some with historical explanation). Desassembling it is a real pain. How can I compare it to that clean 36666 bytes output of gcc - even not linked part of Linux module.

The only thing that I do not understand is why such tool can be useful at all??? Forgive me, but I really do not. What you can get is more-or-less (rather less) correct version of oryginal. It can produce strange bugs or not work at all. But this way you do not change its licence or make it any more open source. Open source does not mean "you can compile it" but "you can get the _real_ source of it and the _author_ does want to give it to you"!

Can you clarify your intentions?

Grzegorz Kulewski

#2 lore raw
In reply to Brad Campbell
Quoted 5 lines · Brad Campbell
Quoted 4 lines · Herbert Poetzl

Hi Folks!

there is a funny bash script available at

Quoted 7 lines
Quoted 5 lines

http://vserver.13thfloor.at/Stuff/QEMU/rev_01.sh

using this on object files (like the kqemu-mod-i386.o) produces interesting output, which will compile nicely with gcc to something very similar of the original ..

Anyone can disassemble a binary and re-compile it.

sure, that's why this script is there ... ;)

Quoted 1 line

Understanding exactly how it works is another story entirely.

agreed, but understanding binary code is harder ;)

Quoted 3 lines

I believe you would be in violation of the license if you distributed the de-compiled source, so what do you gain by doing this?

well, I'm pretty sure that most of the current qemu hackers are able to _understand_ readable assembler code, so it might not be that complicated ...

Quoted 1 line

In addition, we are talking kernel code here.

yes, I'm aware of that, but let me assure you, this kernel code is much simpler than most of the userspace part qemu folks are working with/on ...

Quoted 2 lines

The sort of stuff where random compiler optimisations can cause catastrophic failures.

of course, and some hackers have been eaten by a grue!

Quoted 2 lines

Can you guarantee by doing this you are generating exactly the same code as you started with?

nobody wants to do that, otherwise you could take the object file and be done, nevertheless, comparing the disassembled code of two object files usually sheds some light on the differences (i.e. with diff)

Quoted 1 line

I would certainly be loathe to trust the compiled binary.

but an unknown, proprietary object file nobody takes liability for you trust ... i.c.

best,
Herbert

Quoted 11 lines

Brad

Signature · 9 lines
"Human beings, who are almost unique in having the ability
to learn from the experience of others, are also remarkable
for their apparent disinclination to do so." -- Douglas Adams


_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
#4 lore raw
In reply to Herbert Poetzl
Quoted 3 lines · Herbert Poetzl

and of course I would not suggest to use
it on before mentioned object file ...

I agree. Doing so would be very unethical, considering that Fabrice released it to us for free. Only reason to do so would be to find and fix bugs, and even that is a long shot. You certainly can't use this to make kqemu open - the redistribution restriction would apply to the disassembled code as well (assuming that such disassembly is legal).

Quoted 4 lines

best,
Herbert

Signature · 2 lines
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.