PIC code generation in gcc/binutils
Quoted 4 lines
I can see some advantages in this even with a non-segmented runtime architecture - theoretically, having the GP be managed by the caller rather than the callee should make intramodule calls in position-independent code more efficient. (I think so at least)
Yes, it does have that advantage, and we take advantage of it when we can determine at compile time that the callee is in the same load module.
Quoted 3 lines
One thing I have not figured out is how the GP is "bootstrapped" in the startup code for the dynamic linker itself - how does ELF64 on HP/UX deal with this problem?
The kernel loader passes a "load info" record to the dynamic loader as the fourth parameter (after argc, argv, and envp). This record contains, among other things, the load addresses of the dynamic loader's text and data segments. The dynamic loader's startup code materializes its own gp based on the base address of its data segment.
-cary