
In message f608b67d0807232345r482792b6lbc9bd6804f48e597@mail.gmail.com you wrote:
So, the value of 'pf' is equal to the address of do_ptrt() *before* relocation. The fact that there is a GOT and a sophisticated linker script did not prevent this from happening.
Yes, statically initialized function pointers are known to be not relocated at the moment; they need manual fixing after relocation. Note that this is exactly what Grant's patch fixed.
Why would we do that? The compiler already generates such a table for free - the GOT.
well, didn't the example above show that the compiler will not do that to an arbitrary pointer to a text object?
It just shows that we don't know (yet) how to handle this correctly on a range of given toolchains.
Quite frankly, GOT is also clumsy and even ugly IMHO - it requires a lot of special treatment, explicit data definitions and linker scripts, and does not work for arbitrary data as we saw above.
It is standard, documented by the ABI, and works fine if done correctly. We just don't do it correctly yet.
Best regards,
Wolfgang Denk