gpt4 book ai didi

c - 程序集/C/GDB : code to hexadecimal

转载 作者:太空宇宙 更新时间:2023-11-04 07:33:27 26 4
gpt4 key购买 nike

如何查看某些汇编命令的十六进制表示?

这是来自 gdb:

0x8048395 <simple+1>            mov    %esp,%ebp
0x8048397 <simple+3> mov $0x1,%eax
0x804839c <simple+8> pop %ebp
0x804839d <simple+9> ret

“simple”是这个程序的c函数。我试过了

dump ihex value dump.hex simple

结果

:020000040804EE
:0183940000E8
:00000001FF

dump ihex memory dump.hex 0x8048394 0x804839d

结果不同

:020000040804EE
:098394005589E5B8010000005D07
:00000001FF

为什么不一样?其中一个是正确的吗?

最佳答案

要查看实际字节,您可以简单地使用:

disas /r simple

如果你想转储到文件到原始二进制文件

dump binary memory file.bin 0x8048394 0x804839d

ihex格式是 Intel Hex format ,它并不像看起来那么简单。

此外,当您使用 dump value 时您正在转储函数地址的值,而不是函数本身的代码。这就是 dump memory 所做的。 .

更新:实际上,当您执行 dump <format> value dump.hex simple 时, 它会转储 simple 的内容, 但不知道如何转储函数值,它转储它就好像它是一个 char值,也就是说,它转储函数的第一个字节。如果要转储函数的地址,只需执行:dump <format> value dump.hex &simple .

关于c - 程序集/C/GDB : code to hexadecimal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11178591/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com