summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xDocumentation/maintainers/dynlink-scanner.sh30
-rw-r--r--Documentation/maintainers/try_dlopen.c23
2 files changed, 38 insertions, 15 deletions
diff --git a/Documentation/maintainers/dynlink-scanner.sh b/Documentation/maintainers/dynlink-scanner.sh
index 73b1f18152d..362ec40f63e 100755
--- a/Documentation/maintainers/dynlink-scanner.sh
+++ b/Documentation/maintainers/dynlink-scanner.sh
@@ -3,19 +3,20 @@
run_scanelf()
{
KEY=
- for dep in `scanelf -yBF '%f %n' "${1}"`; do
- if [[ -z ${KEY} ]]; then
- KEY="${dep}"
+ for dep in `scanelf -yBF '%f %n' "$1"`; do
+ if [[ -z $KEY ]]; then
+ KEY="$dep"
continue
fi
- echo ${dep}
+ echo $dep
done
}
-if [[ "${1}" = --internal ]]; then
- if [[ -f "${2}" && -x "${2}" && ! -L "${2}" ]]; then
- LINK=`run_scanelf "${2}"`
- [[ -n ${LINK} ]] && echo -e ${LINK//,/\\n}
+if [[ "$1" = --internal ]]; then
+ if [[ -f "$2" && -x "$2" && ! -L "$2" ]]; then
+ LINK=`run_scanelf "$2"`
+ [[ "$2" == *.so ]] && /tmp/try_dlopen "$2"
+ [[ -n $LINK ]] && echo -e ${LINK//,/\\n}
exit 0
fi
exit 1
@@ -23,16 +24,15 @@ fi
[[ -z $* ]] && echo "usage: `basename $0` <package>" && exit 0
-if ! portageq has_version ${ROOT}/ ${1}; then
- echo "${1} is not installed"
+if ! portageq has_version $ROOT/ $1; then
+ echo "$1 is not installed"
exit 1
fi
-TMPFILE=`mktemp`
LDLIBS=`/sbin/ldconfig -p`
+gcc "`dirname $0`/try_dlopen.c" -o /tmp/try_dlopen -ldl
-for cpv in `portageq match ${ROOT}/ ${1}`; do
- echo "Processing ${cpv}"
- qfile -eR ${ROOT} `portageq contents ${ROOT}/ ${cpv} | xargs -r -L 1 "${0}" --internal | sort -u` | cut -f1 -d' ' | sort -u
+for cpv in `portageq match $ROOT/ $1`; do
+ echo "Processing $cpv"
+ qfile -eR $ROOT `portageq contents $ROOT/ $cpv | xargs -r -L 1 "$0" --internal | sort -u` | cut -f1 -d' ' | sort -u
done
-rm -f ${TMPFILE}
diff --git a/Documentation/maintainers/try_dlopen.c b/Documentation/maintainers/try_dlopen.c
new file mode 100644
index 00000000000..7ff695810b9
--- /dev/null
+++ b/Documentation/maintainers/try_dlopen.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <dlfcn.h>
+
+/**
+ * Attempts to load shared libraries
+ * @param argc
+ * @param argv files to check (pass only shared libs)
+ * @return 0 - all shared libs loaded, 1 - error occured (invalid or broken files passed)
+ */
+int main(int argc, char* argv[])
+{
+ int i;
+ for (i = 1; i < argc; ++i) {
+ void* handle = dlopen(argv[i], RTLD_NOW);
+ if (!handle) {
+ fprintf(stderr, "%s\n", dlerror());
+ return 1;
+ } else {
+ dlclose(handle);
+ }
+ }
+ return 0;
+}