c - ARM汇编跳转到地址

标签 c assembly arm

我有一个纯C的需求,在读取页面后,我想用跳转指令和另一个函数地址替换函数地址,所以我可以使用另一个函数代替当前函数运行时,它实现了 MOCK。

它在 X86 上运行良好,但在 ARM 上,我遇到了一些问题,不知道如何解决。你可以帮帮我吗?

什么是ARM的跳转指令,如何用memcpy替换当前函数地址?

我认为关键元素可能是 16 进制 ARM 跳转指令

最佳答案

来自标题为 Caches and Self-Modifying Code 的博文在 arm 的社区页面上:

Cached ARM architectures have a separate cache for data and instruction accesses; these are called the D-cache and the I-cache, respectively. ... with two interfaces to the CPU, the core can load an instruction and some data at the same time.

... because the D-cache and I-cache are not coherent, the newly-written instructions might be masked by the existing contents of the I-cache, causing the processor to execute old (or possibly invalid) instructions.

我相信本文的其余部分会帮助您深入挖掘,但我想知道您为什么不使用函数指针?它们会更容易构建。

关于c - ARM汇编跳转到地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24131724/

相关文章:

assembly - (有意义的)跳转指令的成本?

assembly - 在x86程序集中取消引用标签

c - 交叉编译时如何使用外部库?

c - arm 链接器在函数调用中使用的 'veneer' 是什么?

c - 从文本文件中删除数据(C 编程)

c - gcc给linux ELF增加了哪些功能?

c - 如何从字符串中打印空格?

arm - PCIe 总线上的写入是原子的吗?

c - 通过线程函数发送字符串以使用 fopen() 打开

c - 修改函数中的指针