CC u-boot mailing list to make people aware of the discussion.
By the way, I also noticed that, the final linking command is using:
'''-pie -Bstatic --no-dynamic-linker'''
And there are self-relocating code in Start.S.
BUT it is not included when u-boot is not configured using "POSITION_INDEPENDENT"
Which means, PIE feature cannot be used at load time.
I am not sure about the code design and use cases, but '''LDFLAGS_u-boot += -pie''' may need to be guarded with '''CONFIG_POSITION_INDEPENDENT''' as well? Otherwise what is the purpose of pie without processing the dynamic relocations?
I tried to do that, and with some fixes in other places to change the checks for relocations, it could generate a binary without any relocations. Though, I am NOT sure about the CORRECTNESS of the binary.
In the original code, R_AARCH64_ABS32 relocation is used to resolve an address at static linking time. It seems works fine originally (which doesn't mean it is not bugous). I assume it is because, no one is trying to use pie feature really.
If people is using pie feature to load the binary in a different address, proper relocations are required, as well as the self-relocating code.
The linker won't generate a dynamic RELATIVE relocation for _AARCH64_ABS32. SO the address in the table won't be updated by the fixup code. However, bfd linker will generate a dynamic RELATIVE relocation for R_AARCH64_ABS64 relocation, and it could be processed by self-relocating code, taking the load address into account.
Regards,
Renlin