Why different memory addresses for a function between direct linking and dlopen
问题 When same library is linked and used with dlopen, same function (sqrt in this example) has different memory addresses. Can you please explain why it is so? Is there some indirection? # cat dl-test.c #include <stdio.h> #include <stdlib.h> #include <dlfcn.h> #include <math.h> #include <inttypes.h> int main() { void *dl, *dl_sqrt; dl = dlopen("/lib/x86_64-linux-gnu/libm.so.6", RTLD_LAZY); if (!dl) { fprintf(stderr, "%s\n", dlerror()); exit(1); } dl_sqrt = dlsym(dl,"sqrt"); if (!dl_sqrt) {