From some time I struggle with the dynamically loaded object into process memory. How it exactly works? I found a lot of materials telling that shared objects shares the same code and has only on copy in the memory. What makes me confused is that processes loads the same library under different addresses what is visible with ldd.
ldd /bin/ls
...
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ffff7d71000)
...
ldd /bin/cat
...
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ffff7db5000)
...
On above, it is visible that the same library is loaded under different process addresses.
For that moment I do not understand if functions from external shared libraries are loaded to the particular process memory or just make a call to the shared memory? What I recall is that GOT tables contains addresses to the shared memory which are fulfilled during dynamic linking process, but what is the purpose of loading shared library under specified memory region visible in relocation tables?
I guess that I lack something important but do not know what