Search code examples
iosmemoryarminstructions

The memory copy from text segment is not the same with the original


In iOS, I copy memory use the code below:

memcpy(code, oriAddress  , 100);

where oriAddress point to text segment(a funtion's address). My problem is ,the memory in oriAddress is not the same with in code. How this happen?

enter image description here

enter image description here

Before the arm instruction ldrh execute, the value pointed by 0x2a305ad4 is 0xb5f0. But after ldrh execute,the value of r0 is not 0xb5f0.


Solution

  • It’s my fault. I set a BreakPoint to the address,And lldb change the value pointed by the address. So the value is the BreakPoint code.