linux – 使用gdb在指定的可执行文件外部执行单步汇编代码会导致错误“无法找到当前函数的边界”
问题:
我在gdb的目标可执行文件之外,我甚至没有与该目标对应的堆栈。 无论如何我想单步执行,以便我可以验证汇编代码中发生了什么,因为我不是x86汇编的专家。 不幸的是,gdb拒绝进行这种简单的汇编级调试。 它允许我在适当的断点上设置和停止,但是一旦我尝试单步执行,gdb就会报告错误“找不到当前函数的边界”并且EIP不会改变。
额外细节:
机器代码是由gcc asm语句生成的,我将它从objdump -d的输出复制到它正在执行的内核内存位置。 我不介意使用加载器将我的目标代码加载到重定位地址的简单方法,但请记住,加载必须在内核模块中完成。
我想另一个替代方法是生成一个伪内核模块或调试信息文件给gdb,使它相信这个区域在程序代码中。 gdb在内核可执行文件本身上运行良好。
(对于那些真正想知道的人,我在运行时将代码插入到VMware VM内的Linux内核数据空间中,并通过VMware Workstation的内置gdb存根从gdb远程调试内核进行调试。注意我不是在编写内核利用;我是一名安全研究生,正在编写原型。)
(我可以在我的程序集中的每个指令上设置一个断点。这可以工作,但一段时间后会变得相当费力,因为x86汇编指令的大小会有所不同,每次重新启动时程序集的位置都会改变。)
I’m outside gdb’s target executable and I don’t even have a stack that corresponds to that target.I want to single-step anyway, so that I can verify what’s going on in my assembly code, because I’m not an expert at x86 assembly.Unfortunately, gdb refuses to do this simple assembly-level debugging.It allows me to set and stop on appropriate breakpoint, but as soon as I try to single-step onwards, gdb reports the error “Cannot find bounds of current function” and the EIP doesn’t change.Additional details:The machine code was generated by gcc asm statements and I copied it to the kernel memory location where it’s executing, from the output of objdump -d.I wouldn’t mind a simple way to use a loader to load my object code to a relocated address, but bear in mind the loading has to be done in a kernel module.I suppose another alternative would be to produce a fake kernel module or debug info file to give to gdb, to cause it to believe this area is within the program code.gdb works fine on the kernel executable itself.(For those who really want to know, I’m inserting code at runtime into Linux kernel data space inside a VMware VM and debugging it from gdb remote debugging the kernel via VMware Workstation’s built-in gdb stub. Note I’m not writing kernel exploits; I’m a security graduate student writing a prototype.)(I can set a breakpoint on each instruction inside my assembly. This works but would get quite laborious after a while, since the size of x86 assembly instructions varies and the location of the assembly will change every time I reboot.)