dlundef.c 590 B

1234567891011121314151617181920212223242526272829
  1. #include <fcntl.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <dlfcn.h>
  5. #include <stdint.h>
  6. #define LIBNAME "libundef.so"
  7. int main(int argc, char **argv)
  8. {
  9. void *handle;
  10. int (*myundefined)(void);
  11. handle = dlopen(LIBNAME, RTLD_LAZY);
  12. if (!handle) {
  13. fprintf(stderr, "Could not open ./%s: %s\n", LIBNAME, dlerror());
  14. return EXIT_FAILURE;
  15. }
  16. myundefined = dlsym(handle, "__booga_booga_you_cant_touch_this__");
  17. if (myundefined != NULL) {
  18. fprintf(stderr, "dlsym() found a symbol that does not exist!\n");
  19. return EXIT_FAILURE;
  20. }
  21. dlclose(handle);
  22. return EXIT_SUCCESS;
  23. }