rianquinn wrote:
My understanding of ELF is that for PIC, the start location for the library can change, but the relative offsets between the different sections remain the same, which is why the compiler should be able to figure out where each global symbol is (excluding external symbols of course). That is, the offset between sections like .text and .data is the same, even though the overall position of the library is different.
If you were to move the different sections within the library then that would make sense to me, but how the code find's it's GOT would not as I'm not sure how you would go about doing that without modifying the code itself.
Ok, then what happens when the creator of the shared object adds functions and/or bug patchs - changing the offset of all functions after the change?
You could go through the shared object Sym Table and link all calls to (SO_OFFSET + SYM_OFFSET) or continue using GOT, which is (partly) setup at Compile-Time of the SO
Without GOT you have relocation - which is slower on load; but, quicker on run.
Now, do not get me wrong - I understand your point. But the only way to avoid GOT is to avoid ELF - or hackish ways.
I do dislike GOT myself, which is why I do not support it (yet) - but again this is a hackish way and the output of linking files is something along the lines of:
Code:
LINKING BIN/TEST.ELF...
SRC/test.o: In function `init':
test.c:(.text+0x8): undefined reference to `initHeap'
test.c:(.text+0x74): undefined reference to `Bochs_puts'
SRC/test.o: In function `_JustATest':
test.c:(.text+0x88): undefined reference to `calloc'
test.c:(.text+0xa6): undefined reference to `Bochs_printf'
test.c:(.text+0xd3): undefined reference to `PCI_findByClass'
test.c:(.text+0xee): undefined reference to `PCI_getConfig'
test.c:(.text+0x10a): undefined reference to `Bochs_printf'
test.c:(.text+0x134): undefined reference to `Bochs_printf'
test.c:(.text+0x149): undefined reference to `Bochs_putch'
SRC/test.o: In function `_AnotherThread':
test.c:(.text+0x1a7): undefined reference to `calloc'
SRC/test.o: In function `_PIT_Test':
test.c:(.text+0x27e): undefined reference to `calloc'
Which looks like an error (well, it is, but I told the linker to ignore it)