1*57718be8SEnji Cooper #include <dlfcn.h> 2*57718be8SEnji Cooper #include <err.h> 3*57718be8SEnji Cooper #include <unistd.h> 4*57718be8SEnji Cooper 5*57718be8SEnji Cooper int main(void)6*57718be8SEnji Coopermain(void) 7*57718be8SEnji Cooper { 8*57718be8SEnji Cooper static const char msg1[] = "main started\n"; 9*57718be8SEnji Cooper static const char msg2[] = "main after dlopen\n"; 10*57718be8SEnji Cooper static const char msg3[] = "main terminated\n"; 11*57718be8SEnji Cooper 12*57718be8SEnji Cooper void *handle; 13*57718be8SEnji Cooper 14*57718be8SEnji Cooper write(STDOUT_FILENO, msg1, sizeof(msg1) - 1); 15*57718be8SEnji Cooper handle = dlopen("h_initfini3_dso.so", RTLD_NOW | RTLD_LOCAL); 16*57718be8SEnji Cooper if (handle == NULL) 17*57718be8SEnji Cooper err(1, "dlopen"); 18*57718be8SEnji Cooper write(STDOUT_FILENO, msg2, sizeof(msg2) - 1); 19*57718be8SEnji Cooper dlclose(handle); 20*57718be8SEnji Cooper write(STDOUT_FILENO, msg3, sizeof(msg3) - 1); 21*57718be8SEnji Cooper return 0; 22*57718be8SEnji Cooper } 23