mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-21 03:10:24 +08:00
add trusted abi
This commit is contained in:
parent
ff865c1fe7
commit
fbf8d071c7
@ -6,6 +6,7 @@ namespace Qv2ray::core::kernel::abi
|
||||
{
|
||||
QvKernelABICompatibility checkCompatibility(QvKernelABIType hostType, QvKernelABIType targetType)
|
||||
{
|
||||
#ifndef QV2RAY_TRUSTED_ABI
|
||||
switch (hostType)
|
||||
{
|
||||
case ABI_WIN32:
|
||||
@ -15,12 +16,19 @@ namespace Qv2ray::core::kernel::abi
|
||||
case ABI_ELF_X86: return targetType == hostType ? ABI_PERFECT : ABI_NOPE;
|
||||
case ABI_ELF_X86_64: return targetType == hostType ? ABI_PERFECT : targetType == ABI_ELF_X86 ? ABI_MAYBE : ABI_NOPE;
|
||||
case ABI_ELF_OTHER: return targetType == hostType ? ABI_PERFECT : ABI_MAYBE;
|
||||
case ABI_TRUSTED: return ABI_PERFECT;
|
||||
default: return ABI_MAYBE;
|
||||
}
|
||||
#else
|
||||
return ABI_PERFECT;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::pair<std::optional<QvKernelABIType>, std::optional<QString>> deduceKernelABI(const QString &pathCoreExecutable)
|
||||
{
|
||||
#ifdef QV2RAY_TRUSTED_ABI
|
||||
return QvKernelABIType::ABI_TRUSTED;
|
||||
#else
|
||||
QFile file(pathCoreExecutable);
|
||||
if (!file.exists())
|
||||
return { std::nullopt, QObject::tr("core executable file %1 does not exist").arg(pathCoreExecutable) };
|
||||
@ -55,6 +63,7 @@ namespace Qv2ray::core::kernel::abi
|
||||
return { QvKernelABIType::ABI_MACH_O, std::nullopt };
|
||||
else
|
||||
return { std::nullopt, QObject::tr("cannot deduce the type of core executable file %1").arg(pathCoreExecutable) };
|
||||
#endif
|
||||
}
|
||||
|
||||
QString abiToString(QvKernelABIType abi)
|
||||
@ -68,6 +77,7 @@ namespace Qv2ray::core::kernel::abi
|
||||
case ABI_ELF_AARCH64: return QObject::tr("ELF arm64 executable");
|
||||
case ABI_ELF_ARM: return QObject::tr("ELF arm executable");
|
||||
case ABI_ELF_OTHER: return QObject::tr("other ELF executable");
|
||||
case ABI_TRUSTED: return QObject::tr("trusted abi");
|
||||
default: return QObject::tr("unknown abi");
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ namespace Qv2ray::core::kernel
|
||||
ABI_ELF_AARCH64,
|
||||
ABI_ELF_ARM,
|
||||
ABI_ELF_OTHER,
|
||||
ABI_TRUSTED,
|
||||
};
|
||||
|
||||
enum QvKernelABICompatibility
|
||||
@ -42,7 +43,8 @@ namespace Qv2ray::core::kernel
|
||||
#elif defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM_V7)
|
||||
QvKernelABIType::ABI_ELF_ARM;
|
||||
#else
|
||||
#error "unknown architecture"
|
||||
QvKernelABIType::ABI_TRUSTED;
|
||||
#define QV2RAY_TRUSTED_ABI
|
||||
#endif
|
||||
|
||||
std::pair<std::optional<QvKernelABIType>, std::optional<QString>> deduceKernelABI(const QString &pathCoreExecutable);
|
||||
|
Loading…
Reference in New Issue
Block a user