简体   繁体   中英

ARM assembly Jump to address

I have a need in pure C , after make the page read, I want to replace the function address with jump instruction and another function address, so I can use another function instead of current function at runtime, which implements MOCK.

It works fine on X86, but on ARM, I came into some issues, and do not know how to solve it. could you help me?

What is jump instruction of ARM, and how to replace it with current function address using memcpy?

I think maybe the key element is 16hex ARM jump instruction

From blog post titled Caches and Self-Modifying Code on arm's community page:

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.

I believe rest of the article would help you dig deeper however I wonder why you are not using function pointers? They would be much easier to build on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM