Let's say there are multiple shared libraries linked to an executable. Say libaaa.so makes a reference to a global variable aaa
and libbbb.so makes a reference to a global variable bbb
.
My understanding is that the code accesses these variables indirectly via the GOT using offsets. I am having trouble understanding how the offset for aaa
in libaaa.so and offset for bbb
in libbbb.so manage to avoid conflicting with each other.
How is the code for the shared libraries generated such that all references in all the libraries end up at different offsets in the GOT?
I am sure I am missing something silly.