From f95bb9c1ca9aff0dec54065ea84d348a3582f91d Mon Sep 17 00:00:00 2001 From: Mikkel Krautz Date: Sat, 12 Nov 2016 22:15:51 +0100 Subject: [PATCH] shared/shared.cpp: improve Linux VDSO detection. This commit improves the the VDSO lookup mechanism by supporting the shared object names of the VDSO object for other architectures. --- shared/shared.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/shared/shared.cpp b/shared/shared.cpp index 4747c18..6578f5f 100644 --- a/shared/shared.cpp +++ b/shared/shared.cpp @@ -91,6 +91,27 @@ inline QDebug operator<<(QDebug debug, const AppDirInfo &info) return debug; } +// Determine whether the given 'ldd' output contains a Linux VDSO +// shared object. The name of the VDSO object differs depending +// on architecture. See "vDSO names" in the notes section of vdso(7) +// for more information. +static bool lddOutputContainsLinuxVDSO(const QString &lddOutput) { + // aarch64, arm, mips, x86_64, x86/x32 + if (lddOutput.contains(QStringLiteral("linux-vdso.so.1"))) { + return true; + // ppc32, s390 + } else if (lddOutput.contains(QStringLiteral("linux-vdso32.so.1"))) { + return true; + // ppc64, s390x + } else if (lddOutput.contains(QStringLiteral("linux-vdso64.so.1"))) { + return true; + // ia64, sh, i386 + } else if (lddOutput.contains(QStringLiteral("linux-gate.so.1"))) { + return true; + } + return false; +} + bool copyFilePrintStatus(const QString &from, const QString &to) { if (QFile(to).exists()) { @@ -162,7 +183,7 @@ LddInfo findDependencyInfo(const QString &binaryPath) } } - if ((binaryPath.contains(".so.") || binaryPath.endsWith(".so")) and (!output.contains("linux-vdso.so.1"))) { + if ((binaryPath.contains(".so.") || binaryPath.endsWith(".so")) && (!lddOutputContainsLinuxVDSO(output))) { const QRegularExpressionMatch match = regexp.match(outputLines.first()); if (match.hasMatch()) { info.installName = match.captured(1);