开发者

When assembling .asm, can it be disassembled to the same syntax?

Say I have a simple nasm pr开发者_如何学运维ogram to print hello!, of course in intel syntax, when I assemble it (with -f elf) and diassemble with with ndisasm it's completely different! why can it not disassemble back into the same simple format of my hello world program? is it not possible ?


If you are trying to recover the original source code from assemblies, forget about it. Especially with modern compilers that do a lot of optimizations.

From my experience with disassemblers, you can get some semi-readable code, but only when the program is relatively simple.


All assembler directives, comments, label names, line numbering, and whitespace (tabs and blanks) is lost in the process of assembling. Even moreso, the disassembler cannot know exactly which parts are code and which are data. So a disassembly has to heuristically translate possible machine code into assembler instructions, and invent new label names (or just use numeric references to memory).

The first exception is when a module exports labels, these labels are included in the object file output and can be used by the disassembler.

The second exception is that debugging information may be present in the object file, or the linked executable, or in separate files referring to the executable. This can include label names and line numbers referring to the original source.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜