/* cc -o h_tls_extern h_tls_extern.c -Wl,-R/usr/tests/libexec/ld.elf_so */ #include #include #include #include int main(void) { void *use_dynamic, *use_static; int *(*fdynamic)(void), *(*fstatic)(void); int *pdynamic, *pstatic; if ((use_dynamic = dlopen("libh_onlyuse_dynamic.so", 0)) == NULL) return 2; if ((use_static = dlopen("libh_onlyuse_static.so", 0)) == NULL) return 3; if ((fdynamic = dlsym(use_dynamic, "fdynamic")) == NULL) return 4; if ((fstatic = dlsym(use_static, "fstatic")) == NULL) return 5; pdynamic = (*fdynamic)(); pstatic = (*fstatic)(); return pdynamic != pstatic; }