汇编.asm时,可以将其反汇编为相同的语法吗?

发布于 2024-09-14 08:48:19 字数 134 浏览 3 评论 0原文

假设我有一个简单的 nasm 程序来打印 hello!,当然是 intel 语法,当我组装它(使用 -f elf)并使用 ndisasm 进行反汇编时,它是完全不同的!为什么它不能反汇编回与我的 hello world 程序相同的简单格式?难道不可能吗?

Say I have a simple nasm program 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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

安稳善良 2024-09-21 08:48:19

如果您尝试从程序集中恢复原始源代码,请忘记它。特别是对于进行了大量优化的现代编译器。

根据我使用反汇编程序的经验,您可以获得一些半可读的代码,但前提是程序相对简单。

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.

葬花如无物 2024-09-21 08:48:19

所有汇编指令、注释、标签名称、行编号和空白(制表符和空格)都会在汇编过程中丢失。更重要的是,反汇编程序无法确切地知道哪些部分是代码,哪些部分是数据。因此,反汇编必须启发式地将可能的机器代码转换为汇编程序指令,并发明新的标签名称(或者仅使用对内存的数字引用)。

第一个例外是当模块导出标签时,这些标签包含在目标文件输出中并且可供反汇编器使用。

第二个例外是调试信息可能存在于目标文件、链接的可执行文件或引用可执行文件的单独文件中。这可以包括引用原始来源的标签名称和行号。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文