我有一个纯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/