Jump to content
  • 0

ARM LDR


THETWINSOFFICIAL
 Share

Question

Recommended Posts

  • 0
19 minutes ago, Alessa- said:

Eaxmple ldr addres : B179DE28 

and i want load addres: AFFDACA4 

ldr cant doit i dont know why

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
Link to comment
Share on other sites

  • 0
5 minutes ago, 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

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?

4 minutes ago, XEKEX said:

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

Okay

Edited by Alessa-
Link to comment
Share on other sites

  • 0
9 minutes ago, 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

Example 

Address 

12345678 | LDR R0, [PC, OFFSET]

98765443 | 

ldr cnt doit

Link to comment
Share on other sites

  • 0
8 minutes ago, 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

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
Link to comment
Share on other sites

  • 0
1 minute ago, 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]

https://pasteboard.co/wHQVyXkj7EHV.jpg

Link to comment
Share on other sites

  • 0
1 minute ago, 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

 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?

7 minutes ago, 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]

I dont know why gg cant doit mov r0, offset

Only mov r0, value

Edited by Alessa-
Link to comment
Share on other sites

  • 0
2 minutes ago, 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.

 

Ouw not far from the instruction 

If very far away cant ?

 

thank you for answering my question

Link to comment
Share on other sites

  • 0
2 hours ago, Alessa- said:

Ouw not far from the instruction 

If very far away cant ?

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).

Link to comment
Share on other sites

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
 Share

×
×
  • 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.