Monday, September 4, 2024 Martin Storsjö <mar...@martin.st> wrote: >> Let's consider the following example, when symbol is located at 3072. >> >> 1. Example without the fix >> compilation time >> adrp x0, (3072 + 256) & ~0xFFF // x0 = 0 >> add x0, x0, (3072 + 256) & 0xFFF // x0 = 3328 >> >> linking time when symbol is relocated with offset 896 >> adrp x0, (0 + 896) & ~0xFFF // x0 = 0 > > Why did the 3072 suddenly become 0 here?
The test case which will be compiled. adrp x0, symbol + 256 add x0, x0, symbol + 256 The numbers which are presented in the example help to clarify relocation steps. symbol is located at 3072. compilation time adrp x0, symbol + 256 90000000 adrp x0, 0 add x0, x0, symbol + 256 91340000 add x0, x0, 3328 linking time when symbol is relocated with offset 896 compiled 90000000 adrp x0, 0 relocated 90000000 adrp x0, 0 // without change ((0 << 12) + 896) >> 12 = 0 // relocation calculation >> add x0, x0, (3328 + 896) & 0xFFF; // x0 = 128 > > Where did 3328 come from in your example? Wasn't "symbol" supposed to be > at address 3072, and we're adding an offset of 896 to it? compiled 91340000 add x0, x0, 3328 relocated 91020000 add x0, x0, 128 (3328 + 896) & 0xFFF = 128 // relocation calculation Regards, Evgeny