Why does ARM assign addresses to registers like this?

1.1k views Asked by At

As you can see in the following snippet of ARM64, this just happens to be from the kernel for iOS 10.

fffffff0073de41c         adrp       x22, #0xfffffff0075ef000
fffffff0073de420         ldr        x0, [x22, #0x330] 

Why does it load a specific address like the one above? 0xfffffff0075ef000 + 0x350, since it's precompiled would it not make sense to just load the entire address 0xfffffff0075ef330.

Sorry for my ignorance.

1

There are 1 answers

1
lucvoo On BEST ANSWER

To load the entire address you would need more instructions (in general, you need 4 instructions to load a 64 bit immediate value).

The purpose of the ADRP instructions, possibly in cooperation with ADR, is to be able to use the address of symbols with less instructions than loading an immediate value would need.