
hi Wolfgang, I am will glad to share my understanding.
Dear David,
In message 0579E649-F359-415B-A8ED-E1D4267F8A24@phytium.com.cn you wrote:
And if any text base alignment is less than the image's maximum alignment requirement, the load will fail, and then we likely scratch our heads and set the CONFIG_SYS_TEXT_BASE alignment higher until it works.
Whatever CONFIG_SYS_TEXT_BASE is the alignment will be ok if the relocated address satisfy the align requirement. So CONFIG_SYS_TEXT_BASE could be any value(compiler maybe require the text base aligned with 0x20), just make relocated address has the same offset.
There is a point which has not been answered yet, wnd which I really would like to understand. maybe you could be so kind and try to explain it to me?
I wonder if the use of the "ardp" instruction by the compiler can be influenced or maybe even prevent for specific code parts, for example by specific compiler options? For example, there is a number of PIC/PIE-related compiler options - would these have any influence here?
I did not find any options that can prevent the use of adrp.
I wonder how "adrp" would work in any code that is supposed to be position-independent?
In my understanding, with adrp the program is still relocatable except that the text base should be 4KB aligned or the relocated address has the same offset with text base. Darwin want CONFIG_SYS_TEXT_BASE to be not 4KB aligned, so the relocated address should be offsetted in the same manner.
Position-independent code is usually page aligned, so gcc-aarch64 implicitly apply the restriction of text base.
Actually, u-boot for aarch64 apply another align requirement that is interrupt vector. The interrupt vector should be 2KB aligned. So, even without adrp CONFIG_SYS_TEXT_BASE should be 2KB aligned yet or relocated with the same offset, otherwise bug exist.
Best regards, David