|
|
f2fdff |
#!/bin/sh
|
|
|
f2fdff |
|
|
|
f2fdff |
tempdir=`mktemp -d /tmp/dlopenXXXXXX`
|
|
|
f2fdff |
test -n "$tempdir" || exit 1
|
|
|
f2fdff |
cat >> $tempdir/dlopen.c << _EOF
|
|
|
f2fdff |
#include <dlfcn.h>
|
|
|
f2fdff |
#include <stdio.h>
|
|
|
f2fdff |
#include <limits.h>
|
|
|
f2fdff |
#include <sys/stat.h>
|
|
|
f2fdff |
/* Simple program to see if dlopen() would succeed. */
|
|
|
f2fdff |
int main(int argc, char **argv)
|
|
|
f2fdff |
{
|
|
|
f2fdff |
int i;
|
|
|
f2fdff |
struct stat st;
|
|
|
f2fdff |
char buf[PATH_MAX];
|
|
|
f2fdff |
for (i = 1; i < argc; i++) {
|
|
|
f2fdff |
if (dlopen(argv[i], RTLD_NOW)) {
|
|
|
f2fdff |
fprintf(stdout, "dlopen() of \"%s\" succeeded.\n",
|
|
|
f2fdff |
argv[i]);
|
|
|
f2fdff |
} else {
|
|
|
f2fdff |
snprintf(buf, sizeof(buf), "./%s", argv[i]);
|
|
|
f2fdff |
if ((stat(buf, &st) == 0) && dlopen(buf, RTLD_NOW)) {
|
|
|
f2fdff |
fprintf(stdout, "dlopen() of \"./%s\" "
|
|
|
f2fdff |
"succeeded.\n", argv[i]);
|
|
|
f2fdff |
} else {
|
|
|
f2fdff |
fprintf(stdout, "dlopen() of \"%s\" failed: "
|
|
|
f2fdff |
"%s\n", argv[i], dlerror());
|
|
|
f2fdff |
return 1;
|
|
|
f2fdff |
}
|
|
|
f2fdff |
}
|
|
|
f2fdff |
}
|
|
|
f2fdff |
return 0;
|
|
|
f2fdff |
}
|
|
|
f2fdff |
_EOF
|
|
|
f2fdff |
|
|
|
f2fdff |
for arg in $@ ; do
|
|
|
f2fdff |
case "$arg" in
|
|
|
f2fdff |
"")
|
|
|
f2fdff |
;;
|
|
|
f2fdff |
-I*|-D*|-f*|-m*|-g*|-O*|-W*)
|
|
|
f2fdff |
cflags="$cflags $arg"
|
|
|
f2fdff |
;;
|
|
|
f2fdff |
-l*|-L*)
|
|
|
f2fdff |
ldflags="$ldflags $arg"
|
|
|
f2fdff |
;;
|
|
|
f2fdff |
/*)
|
|
|
f2fdff |
modules="$modules $arg"
|
|
|
f2fdff |
;;
|
|
|
f2fdff |
*)
|
|
|
f2fdff |
modules="$modules $arg"
|
|
|
f2fdff |
;;
|
|
|
f2fdff |
esac
|
|
|
f2fdff |
done
|
|
|
f2fdff |
|
|
|
f2fdff |
${CC:-gcc} $RPM_OPT_FLAGS $CFLAGS -o $tempdir/dlopen $cflags $tempdir/dlopen.c $ldflags -ldl
|
|
|
f2fdff |
|
|
|
f2fdff |
retval=0
|
|
|
f2fdff |
for module in $modules ; do
|
|
|
f2fdff |
case "$module" in
|
|
|
f2fdff |
"")
|
|
|
f2fdff |
;;
|
|
|
f2fdff |
/*)
|
|
|
f2fdff |
$tempdir/dlopen "$module"
|
|
|
f2fdff |
retval=$?
|
|
|
f2fdff |
;;
|
|
|
f2fdff |
*)
|
|
|
f2fdff |
$tempdir/dlopen ./"$module"
|
|
|
f2fdff |
retval=$?
|
|
|
f2fdff |
;;
|
|
|
f2fdff |
esac
|
|
|
f2fdff |
done
|
|
|
f2fdff |
|
|
|
f2fdff |
rm -f $tempdir/dlopen $tempdir/dlopen.c
|
|
|
f2fdff |
rmdir $tempdir
|
|
|
f2fdff |
exit $retval
|