22 /* Change to the binary directory. */
23 if (chdir (OBJDIR
) != 0)
25 printf ("cannot change to `%s': %m", OBJDIR
);
29 wd
= getcwd (NULL
, 0);
31 buf
= alloca (strlen (wd
) + strlen (base
) + 5 + sizeof "testobj1.so");
33 printf ("loading `%s'\n", "./testobj1.so");
34 a
= dlopen ("./testobj1.so", RTLD_NOW
);
37 printf ("cannot load `./testobj1.so': %s\n", dlerror ());
41 stpcpy (stpcpy (stpcpy (buf
, "../"), base
), "/testobj1.so");
42 printf ("loading `%s'\n", buf
);
43 b
= dlopen (buf
, RTLD_NOW
);
46 printf ("cannot load `%s': %s\n", buf
, dlerror ());
50 stpcpy (stpcpy (buf
, wd
), "/testobj1.so");
51 printf ("loading `%s'\n", buf
);
52 c
= dlopen (buf
, RTLD_NOW
);
55 printf ("cannot load `%s': %s\n", buf
, dlerror ());
59 stpcpy (stpcpy (stpcpy (stpcpy (buf
, wd
), "/../"), base
), "/testobj1.so");
60 printf ("loading `%s'\n", buf
);
61 d
= dlopen (buf
, RTLD_NOW
);
64 printf ("cannot load `%s': %s\n", buf
, dlerror ());
68 if (a
!= b
|| b
!= c
|| c
!= d
)
70 puts ("shared object loaded more than once");
76 puts ("closing `a' failed");
81 puts ("closing `a' failed");
86 puts ("closing `a' failed");
91 puts ("closing `a' failed");
100 extern int foo (int a
);