|
Packit |
6c4009 |
#include <dlfcn.h>
|
|
Packit |
6c4009 |
#include <stdio.h>
|
|
Packit |
6c4009 |
#include <gnu/lib-names.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define TEST_SO "$ORIGIN/tst-dlmopen1mod.so"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
static int
|
|
Packit |
6c4009 |
do_test (void)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
void *h = dlopen (LIBC_SO, RTLD_LAZY|RTLD_NOLOAD);
|
|
Packit |
6c4009 |
if (h == NULL)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("cannot get handle for %s: %s\n", LIBC_SO, dlerror ());
|
|
Packit |
6c4009 |
return 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Lmid_t ns = -10;
|
|
Packit |
6c4009 |
if (dlinfo (h, RTLD_DI_LMID, &ns) != 0)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("dlinfo for %s in %s failed: %s\n",
|
|
Packit |
6c4009 |
LIBC_SO, __func__, dlerror ());
|
|
Packit |
6c4009 |
return 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (ns != LM_ID_BASE)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("namespace for %s not LM_ID_BASE\n", LIBC_SO);
|
|
Packit |
6c4009 |
return 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (dlclose (h) != 0)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("dlclose for %s in %s failed: %s\n",
|
|
Packit |
6c4009 |
LIBC_SO, __func__, dlerror ());
|
|
Packit |
6c4009 |
return 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
h = dlmopen (LM_ID_NEWLM, TEST_SO, RTLD_LAZY);
|
|
Packit |
6c4009 |
if (h == NULL)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("cannot get handle for %s: %s\n",
|
|
Packit |
6c4009 |
"tst-dlmopen1mod.so", dlerror ());
|
|
Packit |
6c4009 |
return 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ns = -10;
|
|
Packit |
6c4009 |
if (dlinfo (h, RTLD_DI_LMID, &ns) != 0)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("dlinfo for %s in %s failed: %s\n",
|
|
Packit |
6c4009 |
"tst-dlmopen1mod.so", __func__, dlerror ());
|
|
Packit |
6c4009 |
return 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (ns == LM_ID_BASE)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("namespace for %s is LM_ID_BASE\n", TEST_SO);
|
|
Packit |
6c4009 |
return 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
int (*fct) (Lmid_t) = dlsym (h, "foo");
|
|
Packit |
6c4009 |
if (fct == NULL)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("could not find %s: %s\n", "foo", dlerror ());
|
|
Packit |
6c4009 |
return 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (fct (ns) != 0)
|
|
Packit |
6c4009 |
return 1;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (dlclose (h) != 0)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("dlclose for %s in %s failed: %s\n",
|
|
Packit |
6c4009 |
TEST_SO, __func__, dlerror ());
|
|
Packit |
6c4009 |
return 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return 0;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <support/test-driver.c>
|