bug-dlsym1.c 664 B

12345678910111213141516171819202122232425262728
  1. /* Test case for bug in dlsym accessing dependency objects' symbols. */
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <unistd.h>
  5. #include <dlfcn.h>
  6. int main(void)
  7. {
  8. void *handle;
  9. char *c;
  10. /* open lib1.so, which has the unresolved test symbol and a DT_NEEDED
  11. on lib2.so, which provides the symbol */
  12. if ((handle = dlopen("bug-dlsym1-lib1.so", RTLD_NOW)) == NULL) {
  13. printf("dlopen(\"bug-dlsym1-lib1.so\"): %s\n", dlerror());
  14. abort();
  15. }
  16. if ((c = dlsym(handle, "dlopen_test_variable")) == NULL) {
  17. printf("dlsym(handle, \"dlopen_test_variable\"): %s\n", dlerror());
  18. abort();
  19. }
  20. (void) dlclose(handle);
  21. return 0;
  22. }