组装显示很多重复代码?
因此,我正在研究一些二进制以组装到C ++代码。这是为了一个项目。
当我拆卸二进制文件时,我会得到很多重复的装配代码,但我不确定它在做什么。几乎就像它只是指着它正在下降。
0x0000000000000000 <+0>: push %rbp
0x0000000000000001 <+1>: mov %rsp,%rbp
0x0000000000000004 <+4>: lea 0x0(%rip),%rsi # 0xb <main+11>
0x000000000000000b <+11>: lea 0x0(%rip),%rdi # 0x12 <main+18>
0x0000000000000012 <+18>: callq 0x17 <main+23>
0x0000000000000017 <+23>: callq 0x1c <main+28>
0x000000000000001c <+28>: mov %eax,0x0(%rip) # 0x22 <main+34>
0x0000000000000022 <+34>: mov 0x0(%rip),%eax # 0x28 <main+40>
0x0000000000000028 <+40>: cmp $0x1,%eax
0x000000000000002b <+43>: je 0x40 <main+64>
0x000000000000002d <+45>: lea 0x0(%rip),%rsi # 0x34 <main+52>
0x0000000000000034 <+52>: lea 0x0(%rip),%rdi # 0x3b <main+59>
0x000000000000003b <+59>: callq 0x40 <main+64>
0x0000000000000040 <+64>: mov 0x0(%rip),%eax # 0x46 <main+70>
0x0000000000000046 <+70>: cmp $0x1,%eax
因此,重复代码是“ lea”和“ callq”。根据我阅读的方式,它只是指向下一行。例如,第一个LEA以#0xB&lt; main+11&gt;结束。这是其下方的线,一个指向其下方的线,依此类推。谁能帮助我看的东西?
该项目中至少有一百个行,所以我不是在寻找免费的A,我只需要帮助理解。
编辑:我正在使用一个.o文件,而无需访问原始.CPP文件,任务是使用GDB并祝福我读取汇编输出并将其重新集结到一个与原始代码相同的.cpp文件中。
So I'm working on some binary to assembly to c++ code. It's for a project.
When I disassemble the binary I'm getting a lot of repeating assembly code and I'm not sure what it's doing. It's almost like it's just pointing it's way down.
0x0000000000000000 <+0>: push %rbp
0x0000000000000001 <+1>: mov %rsp,%rbp
0x0000000000000004 <+4>: lea 0x0(%rip),%rsi # 0xb <main+11>
0x000000000000000b <+11>: lea 0x0(%rip),%rdi # 0x12 <main+18>
0x0000000000000012 <+18>: callq 0x17 <main+23>
0x0000000000000017 <+23>: callq 0x1c <main+28>
0x000000000000001c <+28>: mov %eax,0x0(%rip) # 0x22 <main+34>
0x0000000000000022 <+34>: mov 0x0(%rip),%eax # 0x28 <main+40>
0x0000000000000028 <+40>: cmp $0x1,%eax
0x000000000000002b <+43>: je 0x40 <main+64>
0x000000000000002d <+45>: lea 0x0(%rip),%rsi # 0x34 <main+52>
0x0000000000000034 <+52>: lea 0x0(%rip),%rdi # 0x3b <main+59>
0x000000000000003b <+59>: callq 0x40 <main+64>
0x0000000000000040 <+64>: mov 0x0(%rip),%eax # 0x46 <main+70>
0x0000000000000046 <+70>: cmp $0x1,%eax
So the repeating code is the "lea" and "callq". Based on the way I'm reading it, it's just pointing to the next line down. For example, the first lea ends with #0xb <main+11> which is the line right below it, and that one points to the line below it, and so on. Can anyone help with what I'm looking at?
There's at least a hundred extra lines in the project, so I'm not looking for a free A, I just need help understanding.
Edit: I am working with a .o file without access to the original .cpp file and the task is to use GDB and Bless to help me read the Assembly output and reassemble it into a .cpp file that works the same as the original code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
地址表明您是在拆卸
.o
文件,而不是可执行文件(您应该始终在询问其输出时显示您使用的命令)。尝试
objdump -dr foo.o
而不是 - 图片应该变得更加清晰。无论如何,PS GDB并不是真正查看
.o
文件的正确工具。更新:
看起来更接近:它是不是相同的输出。
objdump
将显示重新信号,其中显示他call
实际上将转到位置。您还应该能够将
project1.o
链接到可执行文件中(例如gcc project1.o -o project1
),然后运行gdb project1
然后disas main
。您会看到 拆卸更有意义,并且与objdump
的输出匹配。The addresses suggest that you are disassembling
.o
file, not an executable (you should always show the command you used when asking about its output).Try
objdump -dr foo.o
instead -- the picture should become much clearer.P.S. GDB isn't really the right tool for looking at
.o
files anyway.Update:
Look closer: it's not the same output.
objdump
will display relocations, which show where heCALL
will actually go to.You should also be able to link
Project1.o
into an executable (something likegcc Project1.o -o Project1
), and rungdb Project1
and thendisas main
. You will see that that disassembly makes more sense, and also matches the output ofobjdump
.