Jump to content

Question

Recommended Posts

  • 0
Posted
  On 3/13/2023 at 6:51 PM, Alessa- said:

Eaxmple ldr addres : B179DE28 

and i want load addres: AFFDACA4 

ldr cant doit i dont know why

Expand  

As other have mentioned above, such case requires more than one instruction. At least 8 bytes are required: 4 for LDR instruction and 4 for your new address that needs to be placed somewhere not far from LDR instruction. For example: 

Address  | Instruction/Value
12345678 | LDR R0, [PC, #-4]
1234567C | 0xAFFDACA4
  • 0
Posted (edited)
  On 3/13/2023 at 7:22 PM, CmP said:

As other have mentioned above, such case requires more than one instruction. At least 8 bytes are required: 4 for LDR instruction and 4 for your new address that needs to be placed somewhere not far from LDR instruction. For example: 

Address  | Instruction/Value
12345678 | LDR R0, [PC, #-4]
1234567C | 0xAFFDACA4
Expand  

Yes is area same

123456

And ldr can doit

But 

if the address is not far I can but if the address is very far away, LDR can't do it what is this limit?

  On 3/13/2023 at 7:23 PM, XEKEX said:

try #56872 -- idk why it give you error it should read it 

Expand  

Okay

Edited by Alessa-
  • 0
Posted
  On 3/13/2023 at 7:22 PM, CmP said:

As other have mentioned above, such case requires more than one instruction. At least 8 bytes are required: 4 for LDR instruction and 4 for your new address that needs to be placed somewhere not far from LDR instruction. For example: 

Address  | Instruction/Value
12345678 | LDR R0, [PC, #-4]
1234567C | 0xAFFDACA4
Expand  

Example 

Address 

12345678 | LDR R0, [PC, OFFSET]

98765443 | 

ldr cnt doit

  • 0
Posted (edited)
  On 3/13/2023 at 7:26 PM, Alessa- said:

Yes is area same

12345 

And ldr can doit

But 

if the address is not far I can but if the address is very far away, LDR can't do it what is this limit?

Okay

Expand  

Note : the offset of the address 0xB179DE28 and 0x1AFFDACA4 should be a const offset if you want to implement it in a script otherwise if the offset between the lib and the address 0x1AFFDACA4 is a const offset use lib_base_address + offset to get the address then split it into 2 half
MOVW r0, 0xACA4 
MOVT r0, 0xAFFD
LDR r0, [r0]

Edited by XEKEX
  • 0
Posted
  On 3/13/2023 at 7:34 PM, XEKEX said:

Note : the offset of the address 0xB179DE28 and 0x1AFFDACA4 should be a const offset if you want to implement it in a script otherwise if the offset between the lib and the address 0x1AFFDACA4 is a const offset use 
MOVW r0, 0xACA4 
MOVT r0, 0xAFFD
LDR r0, [r0]

Expand  

https://pasteboard.co/wHQVyXkj7EHV.jpg

  • 0
Posted (edited)
  On 3/13/2023 at 7:36 PM, CmP said:

There are 12 bits in the instruction that are used for encoding offset from PC in bytes, so the limit is from -4095 to 4095.

Reference: https://developer.arm.com/documentation/ddi0406/cb/Application-Level-Architecture/Instruction-Details/Alphabetical-list-of-instructions/LDR--literal-?lang=en

Expand  

 it's true that ldr has a limit, so to overcome it with what?

do you have a solution? How about bl? Can you handle it?

  On 3/13/2023 at 7:34 PM, XEKEX said:

Note : the offset of the address 0xB179DE28 and 0x1AFFDACA4 should be a const offset if you want to implement it in a script otherwise if the offset between the lib and the address 0x1AFFDACA4 is a const offset use lib_base_address + offset to get the address then split it into 2 half
MOVW r0, 0xACA4 
MOVT r0, 0xAFFD
LDR r0, [r0]

Expand  

I dont know why gg cant doit mov r0, offset

Only mov r0, value

Edited by Alessa-
  • 0
Posted
  On 3/13/2023 at 7:44 PM, CmP said:

Either with 3 instructions as @XEKEX has described in his post or with 1 instruction and 4 bytes for address that need to be not far from the instruction as I have mentioned in this post.

 

Expand  

Ouw not far from the instruction 

If very far away cant ?

 

thank you for answering my question

  • 0
Posted
  On 3/13/2023 at 7:47 PM, Alessa- said:

Ouw not far from the instruction 

If very far away cant ?

Expand  

This is limitation of particular variant of LDR instruction, it doesn't mean that it's not possible anyhow. But to be able to provide you reasonable answer, one needs to know what you want to achieve, why do you need to use LDR in the first place. So provide the following information (preferably in new topic):
  - what you are working with (function(s) name, description and instructions that it contains);
  - which modification you want to implement (for example, make the function return fixed value).

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.