loader.c 334 B

1234567891011121314151617181920212223
  1. #include <dlfcn.h>
  2. #include <stdio.h>
  3. int main (int argc, char *argv[])
  4. {
  5. void * h;
  6. int res;
  7. if (argc == 2) {
  8. h = dlopen(argv[1], RTLD_LAZY | RTLD_GLOBAL);
  9. if (h != NULL) {
  10. res = 0;
  11. } else {
  12. perror(dlerror());
  13. res = 2;
  14. }
  15. } else {
  16. fprintf(stderr, "usage: %s file.so\n", argv[0]);
  17. res = 1;
  18. }
  19. return res;
  20. }