如何调用组件GDB? [英] How to call assembly in gdb?

查看:105
本文介绍了如何调用组件GDB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在gdb的我可以使用呼叫运行的功能,但如果我要运行一些额外的组件是什么?

In gdb I can use call to run functions,but what if I want to run some additional assembly?

推荐答案

此前GCC 5 (1),我不知道的方式来运行任意机器code,除非你实际上进入机器code到内存中,然后运行它。

Prior to GCC 5 (1), I don't know of a way to run arbitrary machine code unless you actually enter the machine code into memory and then run it.

如果你想运行code那的的内存,你可以设置指令指针到开始,在最后一个断点,然后去。然后,断点之后,指令指针改回其原始值。

If you want to run code that's already in memory, you can just set the instruction pointer to the start, a breakpoint at the end, then go. Then, after the breakpoint, change the instruction pointer back to its original value.

但我不能真正看到这种情况的用例。这并不意味着存在的不是的之一,只是什么,你可以通过运行code做,你也可以通过直接修改寄存器,标志,内存等实现的。

But I can't actually see the use case for this. That doesn't mean there isn't one, just that anything you can do by running code, you can also achieve by directly modifying the registers, flags, memory and so forth.

例如,命令:

info registers

将转储寄存器的当前值,而

will dump the current values of the registers while:

set $eax = 42

将修改 EAX 注册 42

您也可以以这种方式改变内存:

You can also change memory in this way:

set *((char*)0xb7ffeca0) = 4

此写入了一个字节来存储位置 0xb7ffeca0 ,你也可以使用同样的方法来存储更广泛的数据类型。

This writes a single byte to memory location 0xb7ffeca0 and you can also use that same method to store wider data types.

(1) GCC 5,您可以编译和使用编译code 命令执行任意code,如记录这里

(1) GCC 5 allows you to compile and execute arbitrary code with the compile code command, as documented here.

这篇关于如何调用组件GDB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆