2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-02-01 18:36:00 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-02-01 18:36:00 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-02-01 18:36:00 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-02-01 18:36:00 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-02-01 18:36:00 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-02-01 18:36:00 +01:00
|
|
|
|
|
|
|
|
#include "abi.h"
|
|
|
|
|
|
2013-03-25 17:13:18 +01:00
|
|
|
#include <utils/fileutils.h>
|
2018-01-10 16:51:58 +01:00
|
|
|
#include <utils/qtcfallthrough.h>
|
2013-03-25 17:13:18 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QtEndian>
|
|
|
|
|
#include <QFile>
|
2017-03-09 23:02:32 +01:00
|
|
|
#include <QRegExp>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QString>
|
|
|
|
|
#include <QStringList>
|
|
|
|
|
#include <QSysInfo>
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::Abi
|
|
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The Abi class represents the Application Binary Interface (ABI) of
|
|
|
|
|
a target platform.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
|
|
|
|
\sa ProjectExplorer::ToolChain
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
2011-03-02 14:09:18 +01:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// Helpers
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2018-01-23 12:00:45 +01:00
|
|
|
static Abi::Architecture architectureFromQt()
|
|
|
|
|
{
|
|
|
|
|
const QString arch = QSysInfo::buildCpuArchitecture();
|
|
|
|
|
if (arch.startsWith("arm"))
|
|
|
|
|
return Abi::ArmArchitecture;
|
|
|
|
|
if (arch.startsWith("x86") || arch == "i386")
|
|
|
|
|
return Abi::X86Architecture;
|
|
|
|
|
if (arch == "ia64")
|
|
|
|
|
return Abi::ItaniumArchitecture;
|
|
|
|
|
if (arch.startsWith("mips"))
|
|
|
|
|
return Abi::MipsArchitecture;
|
|
|
|
|
if (arch.startsWith("power"))
|
|
|
|
|
return Abi::PowerPCArchitecture;
|
|
|
|
|
if (arch.startsWith("sh")) // Not in Qt documentation!
|
|
|
|
|
return Abi::ShArchitecture;
|
|
|
|
|
if (arch.startsWith("avr")) // Not in Qt documentation!
|
|
|
|
|
return Abi::AvrArchitecture;
|
|
|
|
|
|
|
|
|
|
return Abi::UnknownArchitecture;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-31 15:09:18 +00:00
|
|
|
static quint8 getUint8(const QByteArray &data, int pos)
|
|
|
|
|
{
|
|
|
|
|
return static_cast<quint8>(data.at(pos));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static quint32 getLEUint32(const QByteArray &ba, int pos)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(ba.size() >= pos + 3);
|
|
|
|
|
return (static_cast<quint32>(static_cast<quint8>(ba.at(pos + 3))) << 24)
|
|
|
|
|
+ (static_cast<quint32>(static_cast<quint8>(ba.at(pos + 2)) << 16))
|
|
|
|
|
+ (static_cast<quint32>(static_cast<quint8>(ba.at(pos + 1))) << 8)
|
|
|
|
|
+ static_cast<quint8>(ba.at(pos));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static quint32 getBEUint32(const QByteArray &ba, int pos)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(ba.size() >= pos + 3);
|
|
|
|
|
return (static_cast<quint32>(static_cast<quint8>(ba.at(pos))) << 24)
|
|
|
|
|
+ (static_cast<quint32>(static_cast<quint8>(ba.at(pos + 1))) << 16)
|
|
|
|
|
+ (static_cast<quint32>(static_cast<quint8>(ba.at(pos + 2))) << 8)
|
|
|
|
|
+ static_cast<quint8>(ba.at(pos + 3));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static quint32 getLEUint16(const QByteArray &ba, int pos)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(ba.size() >= pos + 1);
|
|
|
|
|
return (static_cast<quint16>(static_cast<quint8>(ba.at(pos + 1))) << 8) + static_cast<quint8>(ba.at(pos));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static quint32 getBEUint16(const QByteArray &ba, int pos)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(ba.size() >= pos + 1);
|
|
|
|
|
return (static_cast<quint16>(static_cast<quint8>(ba.at(pos))) << 8) + static_cast<quint8>(ba.at(pos + 1));
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-02 14:09:18 +01:00
|
|
|
static Abi macAbiForCpu(quint32 type) {
|
|
|
|
|
switch (type) {
|
|
|
|
|
case 7: // CPU_TYPE_X86, CPU_TYPE_I386
|
2016-07-25 18:39:16 -07:00
|
|
|
return Abi(Abi::X86Architecture, Abi::DarwinOS, Abi::GenericDarwinFlavor, Abi::MachOFormat, 32);
|
2011-03-02 14:09:18 +01:00
|
|
|
case 0x01000000 + 7: // CPU_TYPE_X86_64
|
2016-07-25 18:39:16 -07:00
|
|
|
return Abi(Abi::X86Architecture, Abi::DarwinOS, Abi::GenericDarwinFlavor, Abi::MachOFormat, 64);
|
2011-03-02 14:09:18 +01:00
|
|
|
case 18: // CPU_TYPE_POWERPC
|
2016-07-25 18:39:16 -07:00
|
|
|
return Abi(Abi::PowerPCArchitecture, Abi::DarwinOS, Abi::GenericDarwinFlavor, Abi::MachOFormat, 32);
|
2011-03-02 14:09:18 +01:00
|
|
|
case 0x01000000 + 18: // CPU_TYPE_POWERPC64
|
2016-07-25 18:39:16 -07:00
|
|
|
return Abi(Abi::PowerPCArchitecture, Abi::DarwinOS, Abi::GenericDarwinFlavor, Abi::MachOFormat, 32);
|
2011-03-02 14:09:18 +01:00
|
|
|
case 12: // CPU_TYPE_ARM
|
2016-07-25 18:39:16 -07:00
|
|
|
return Abi(Abi::ArmArchitecture, Abi::DarwinOS, Abi::GenericDarwinFlavor, Abi::MachOFormat, 32);
|
2014-09-28 14:48:40 -04:00
|
|
|
case 0x01000000 + 12: // CPU_TYPE_ARM64
|
2016-07-25 18:39:16 -07:00
|
|
|
return Abi(Abi::ArmArchitecture, Abi::DarwinOS, Abi::GenericDarwinFlavor, Abi::MachOFormat, 64);
|
2011-03-02 14:09:18 +01:00
|
|
|
default:
|
|
|
|
|
return Abi();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-03 11:29:07 +01:00
|
|
|
static QList<Abi> parseCoffHeader(const QByteArray &data)
|
|
|
|
|
{
|
|
|
|
|
QList<Abi> result;
|
|
|
|
|
if (data.size() < 20)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
Abi::Architecture arch = Abi::UnknownArchitecture;
|
|
|
|
|
Abi::OSFlavor flavor = Abi::UnknownFlavor;
|
|
|
|
|
int width = 0;
|
|
|
|
|
|
|
|
|
|
// Get machine field from COFF file header
|
2011-08-31 15:09:18 +00:00
|
|
|
quint16 machine = getLEUint16(data, 0);
|
2011-03-03 11:29:07 +01:00
|
|
|
switch (machine) {
|
2013-02-07 14:22:08 +01:00
|
|
|
case 0x01c0: // ARM LE
|
|
|
|
|
case 0x01c2: // ARM or thumb
|
|
|
|
|
case 0x01c4: // ARMv7 thumb
|
|
|
|
|
arch = Abi::ArmArchitecture;
|
|
|
|
|
width = 32;
|
|
|
|
|
break;
|
2011-03-03 11:29:07 +01:00
|
|
|
case 0x8664: // x86_64
|
|
|
|
|
arch = Abi::X86Architecture;
|
|
|
|
|
width = 64;
|
|
|
|
|
break;
|
|
|
|
|
case 0x014c: // i386
|
|
|
|
|
arch = Abi::X86Architecture;
|
|
|
|
|
width = 32;
|
|
|
|
|
break;
|
2011-07-11 14:22:28 +00:00
|
|
|
case 0x0166: // MIPS, little endian
|
2011-08-31 09:55:34 +00:00
|
|
|
arch = Abi::MipsArchitecture;
|
2011-07-11 14:22:28 +00:00
|
|
|
width = 32;
|
|
|
|
|
break;
|
2011-03-03 11:29:07 +01:00
|
|
|
case 0x0200: // ia64
|
|
|
|
|
arch = Abi::ItaniumArchitecture;
|
|
|
|
|
width = 64;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-20 13:25:35 +02:00
|
|
|
if (data.size() >= 24) {
|
2011-03-03 11:29:07 +01:00
|
|
|
// Get Major and Minor Image Version from optional header fields
|
2012-09-20 13:25:35 +02:00
|
|
|
quint8 minorLinker = data.at(23);
|
|
|
|
|
switch (data.at(22)) {
|
|
|
|
|
case 2:
|
|
|
|
|
case 3: // not yet reached:-)
|
2011-03-03 11:29:07 +01:00
|
|
|
flavor = Abi::WindowsMSysFlavor;
|
2012-09-20 13:25:35 +02:00
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
flavor = Abi::WindowsMsvc2005Flavor;
|
|
|
|
|
break;
|
|
|
|
|
case 9:
|
|
|
|
|
flavor = Abi::WindowsMsvc2008Flavor;
|
|
|
|
|
break;
|
|
|
|
|
case 10:
|
|
|
|
|
flavor = Abi::WindowsMsvc2010Flavor;
|
|
|
|
|
break;
|
|
|
|
|
case 11:
|
|
|
|
|
flavor = Abi::WindowsMsvc2012Flavor;
|
|
|
|
|
break;
|
2013-10-20 23:44:52 +08:00
|
|
|
case 12:
|
|
|
|
|
flavor = Abi::WindowsMsvc2013Flavor;
|
|
|
|
|
break;
|
2015-06-12 11:30:43 +02:00
|
|
|
case 14:
|
2016-12-13 15:17:37 +01:00
|
|
|
flavor = minorLinker >= quint8(10)
|
|
|
|
|
? Abi::WindowsMsvc2017Flavor // MSVC2017 RC
|
|
|
|
|
: Abi::WindowsMsvc2015Flavor;
|
2016-11-25 11:12:16 +01:00
|
|
|
break;
|
2016-11-23 09:06:44 +01:00
|
|
|
case 15:
|
|
|
|
|
flavor = Abi::WindowsMsvc2017Flavor;
|
2015-06-12 11:30:43 +02:00
|
|
|
break;
|
2012-09-20 13:25:35 +02:00
|
|
|
default: // Keep unknown flavor
|
|
|
|
|
if (minorLinker != 0)
|
|
|
|
|
flavor = Abi::WindowsMSysFlavor; // MSVC seems to avoid using minor numbers
|
|
|
|
|
else
|
2012-07-27 20:34:46 +02:00
|
|
|
qWarning("%s: Unknown MSVC flavour encountered.", Q_FUNC_INFO);
|
2012-09-20 13:25:35 +02:00
|
|
|
break;
|
2011-03-18 09:54:35 +01:00
|
|
|
}
|
2011-03-03 11:29:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (arch != Abi::UnknownArchitecture && width != 0)
|
|
|
|
|
result.append(Abi(arch, Abi::WindowsOS, flavor, Abi::PEFormat, width));
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-02 14:09:18 +01:00
|
|
|
static QList<Abi> abiOf(const QByteArray &data)
|
|
|
|
|
{
|
|
|
|
|
QList<Abi> result;
|
2011-08-31 15:09:18 +00:00
|
|
|
if (data.size() <= 8)
|
|
|
|
|
return result;
|
2011-03-02 14:09:18 +01:00
|
|
|
|
|
|
|
|
if (data.size() >= 20
|
2011-08-31 15:09:18 +00:00
|
|
|
&& getUint8(data, 0) == 0x7f && getUint8(data, 1) == 'E' && getUint8(data, 2) == 'L'
|
|
|
|
|
&& getUint8(data, 3) == 'F') {
|
2011-03-02 14:09:18 +01:00
|
|
|
// ELF format:
|
2011-08-31 15:09:18 +00:00
|
|
|
bool isLE = (getUint8(data, 5) == 1);
|
|
|
|
|
quint16 machine = isLE ? getLEUint16(data, 18) : getBEUint16(data, 18);
|
|
|
|
|
quint8 osAbi = getUint8(data, 7);
|
2011-05-31 10:06:32 +00:00
|
|
|
|
|
|
|
|
Abi::OS os = Abi::UnixOS;
|
|
|
|
|
Abi::OSFlavor flavor = Abi::GenericUnixFlavor;
|
|
|
|
|
// http://www.sco.com/developers/gabi/latest/ch4.eheader.html#elfid
|
|
|
|
|
switch (osAbi) {
|
2016-06-13 22:31:17 +02:00
|
|
|
#if defined(Q_OS_NETBSD)
|
|
|
|
|
case 0: // NetBSD: ELFOSABI_NETBSD 2, however, NetBSD uses 0
|
2011-05-31 10:06:32 +00:00
|
|
|
os = Abi::BsdOS;
|
|
|
|
|
flavor = Abi::NetBsdFlavor;
|
|
|
|
|
break;
|
2016-06-13 22:31:17 +02:00
|
|
|
#elif defined(Q_OS_OPENBSD)
|
|
|
|
|
case 0: // OpenBSD: ELFOSABI_OPENBSD 12, however, OpenBSD uses 0
|
|
|
|
|
os = Abi::BsdOS;
|
|
|
|
|
flavor = Abi::OpenBsdFlavor;
|
|
|
|
|
break;
|
|
|
|
|
#else
|
2011-05-31 10:06:32 +00:00
|
|
|
case 0: // no extra info available: Default to Linux:
|
2016-06-13 22:31:17 +02:00
|
|
|
#endif
|
|
|
|
|
case 3: // Linux:
|
2012-01-25 10:54:21 +01:00
|
|
|
case 97: // ARM, also linux most of the time.
|
2011-05-31 10:06:32 +00:00
|
|
|
os = Abi::LinuxOS;
|
|
|
|
|
flavor = Abi::GenericLinuxFlavor;
|
|
|
|
|
break;
|
|
|
|
|
case 6: // Solaris:
|
|
|
|
|
os = Abi::UnixOS;
|
|
|
|
|
flavor = Abi::SolarisUnixFlavor;
|
|
|
|
|
break;
|
|
|
|
|
case 9: // FreeBSD:
|
|
|
|
|
os = Abi::BsdOS;
|
|
|
|
|
flavor = Abi::FreeBsdFlavor;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-05-31 08:55:57 +00:00
|
|
|
|
2011-03-02 14:09:18 +01:00
|
|
|
switch (machine) {
|
|
|
|
|
case 3: // EM_386
|
2011-05-31 08:55:57 +00:00
|
|
|
result.append(Abi(Abi::X86Architecture, os, flavor, Abi::ElfFormat, 32));
|
2011-03-02 14:09:18 +01:00
|
|
|
break;
|
|
|
|
|
case 8: // EM_MIPS
|
2011-08-31 09:55:34 +00:00
|
|
|
result.append(Abi(Abi::MipsArchitecture, os, flavor, Abi::ElfFormat, 32));
|
2011-03-02 14:09:18 +01:00
|
|
|
break;
|
|
|
|
|
case 20: // EM_PPC
|
2011-05-31 08:55:57 +00:00
|
|
|
result.append(Abi(Abi::PowerPCArchitecture, os, flavor, Abi::ElfFormat, 32));
|
2011-03-02 14:09:18 +01:00
|
|
|
break;
|
|
|
|
|
case 21: // EM_PPC64
|
2011-05-31 08:55:57 +00:00
|
|
|
result.append(Abi(Abi::PowerPCArchitecture, os, flavor, Abi::ElfFormat, 64));
|
2011-03-02 14:09:18 +01:00
|
|
|
break;
|
2011-03-21 18:04:24 +01:00
|
|
|
case 40: // EM_ARM
|
2011-05-31 08:55:57 +00:00
|
|
|
result.append(Abi(Abi::ArmArchitecture, os, flavor, Abi::ElfFormat, 32));
|
2011-03-21 18:04:24 +01:00
|
|
|
break;
|
2014-11-18 18:37:05 +01:00
|
|
|
case 183: // EM_AARCH64
|
|
|
|
|
result.append(Abi(Abi::ArmArchitecture, os, flavor, Abi::ElfFormat, 64));
|
|
|
|
|
break;
|
2011-03-02 14:09:18 +01:00
|
|
|
case 62: // EM_X86_64
|
2011-05-31 08:55:57 +00:00
|
|
|
result.append(Abi(Abi::X86Architecture, os, flavor, Abi::ElfFormat, 64));
|
2011-03-02 14:09:18 +01:00
|
|
|
break;
|
2011-09-22 14:26:10 +00:00
|
|
|
case 42: // EM_SH
|
|
|
|
|
result.append(Abi(Abi::ShArchitecture, os, flavor, Abi::ElfFormat, 32));
|
|
|
|
|
break;
|
2011-03-02 14:09:18 +01:00
|
|
|
case 50: // EM_IA_64
|
2011-05-31 08:55:57 +00:00
|
|
|
result.append(Abi(Abi::ItaniumArchitecture, os, flavor, Abi::ElfFormat, 64));
|
2011-03-02 14:09:18 +01:00
|
|
|
break;
|
|
|
|
|
default:
|
2013-09-03 18:48:02 +02:00
|
|
|
;
|
2011-03-02 14:09:18 +01:00
|
|
|
}
|
2011-08-31 15:09:18 +00:00
|
|
|
} else if (((getUint8(data, 0) == 0xce || getUint8(data, 0) == 0xcf)
|
|
|
|
|
&& getUint8(data, 1) == 0xfa && getUint8(data, 2) == 0xed && getUint8(data, 3) == 0xfe
|
|
|
|
|
)
|
|
|
|
|
||
|
|
|
|
|
(getUint8(data, 0) == 0xfe && getUint8(data, 1) == 0xed && getUint8(data, 2) == 0xfa
|
|
|
|
|
&& (getUint8(data, 3) == 0xce || getUint8(data, 3) == 0xcf)
|
|
|
|
|
)
|
|
|
|
|
) {
|
|
|
|
|
// Mach-O format (Mac non-fat binary, 32 and 64bit magic):
|
|
|
|
|
quint32 type = (getUint8(data, 1) == 0xfa) ? getLEUint32(data, 4) : getBEUint32(data, 4);
|
|
|
|
|
result.append(macAbiForCpu(type));
|
|
|
|
|
} else if ((getUint8(data, 0) == 0xbe && getUint8(data, 1) == 0xba
|
|
|
|
|
&& getUint8(data, 2) == 0xfe && getUint8(data, 3) == 0xca)
|
|
|
|
|
||
|
|
|
|
|
(getUint8(data, 0) == 0xca && getUint8(data, 1) == 0xfe
|
|
|
|
|
&& getUint8(data, 2) == 0xba && getUint8(data, 3) == 0xbe)
|
|
|
|
|
) {
|
|
|
|
|
// Mach-0 format Fat binary header:
|
|
|
|
|
bool isLE = (getUint8(data, 0) == 0xbe);
|
|
|
|
|
quint32 count = isLE ? getLEUint32(data, 4) : getBEUint32(data, 4);
|
2011-03-02 14:09:18 +01:00
|
|
|
int pos = 8;
|
|
|
|
|
for (quint32 i = 0; i < count; ++i) {
|
|
|
|
|
if (data.size() <= pos + 4)
|
|
|
|
|
break;
|
|
|
|
|
|
2011-08-31 15:09:18 +00:00
|
|
|
quint32 type = isLE ? getLEUint32(data, pos) : getBEUint32(data, pos);
|
2011-03-02 14:09:18 +01:00
|
|
|
result.append(macAbiForCpu(type));
|
|
|
|
|
pos += 20;
|
|
|
|
|
}
|
2011-08-31 11:38:39 +00:00
|
|
|
} else if (data.size() >= 64){
|
2011-08-31 15:09:18 +00:00
|
|
|
// Windows PE: values are LE (except for a few exceptions which we will not use here).
|
2011-08-31 11:38:39 +00:00
|
|
|
|
2011-08-31 15:09:18 +00:00
|
|
|
// MZ header first (ZM is also allowed, but rarely used)
|
2011-09-12 15:48:43 +02:00
|
|
|
const quint8 firstChar = getUint8(data, 0);
|
|
|
|
|
const quint8 secondChar = getUint8(data, 1);
|
|
|
|
|
if ((firstChar != 'M' || secondChar != 'Z') && (firstChar != 'Z' || secondChar != 'M'))
|
|
|
|
|
return result;
|
2011-08-31 11:38:39 +00:00
|
|
|
|
|
|
|
|
// Get PE/COFF header position from MZ header:
|
2011-08-31 15:09:18 +00:00
|
|
|
qint32 pePos = getLEUint32(data, 60);
|
2011-08-31 11:38:39 +00:00
|
|
|
if (pePos <= 0 || data.size() < pePos + 4 + 20) // PE magic bytes plus COFF header
|
|
|
|
|
return result;
|
2011-08-31 15:09:18 +00:00
|
|
|
if (getUint8(data, pePos) == 'P' && getUint8(data, pePos + 1) == 'E'
|
|
|
|
|
&& getUint8(data, pePos + 2) == 0 && getUint8(data, pePos + 3) == 0)
|
2011-03-03 11:29:07 +01:00
|
|
|
result = parseCoffHeader(data.mid(pePos + 4));
|
2011-03-02 14:09:18 +01:00
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// Abi
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
Abi::Abi(const Architecture &a, const OS &o,
|
2011-02-23 16:47:08 +01:00
|
|
|
const OSFlavor &of, const BinaryFormat &f, unsigned char w) :
|
2011-02-01 18:36:00 +01:00
|
|
|
m_architecture(a), m_os(o), m_osFlavor(of), m_binaryFormat(f), m_wordWidth(w)
|
|
|
|
|
{
|
|
|
|
|
switch (m_os) {
|
2017-07-25 23:14:48 +03:00
|
|
|
case UnknownOS:
|
2011-02-23 16:47:08 +01:00
|
|
|
m_osFlavor = UnknownFlavor;
|
2011-02-01 18:36:00 +01:00
|
|
|
break;
|
2017-07-25 23:14:48 +03:00
|
|
|
case LinuxOS:
|
2013-10-24 13:34:41 +02:00
|
|
|
if (m_osFlavor < GenericLinuxFlavor || m_osFlavor > AndroidLinuxFlavor)
|
2011-02-23 16:47:08 +01:00
|
|
|
m_osFlavor = UnknownFlavor;
|
2011-02-01 18:36:00 +01:00
|
|
|
break;
|
2017-07-25 23:14:48 +03:00
|
|
|
case BsdOS:
|
2013-10-24 13:33:52 +02:00
|
|
|
if (m_osFlavor < FreeBsdFlavor || m_osFlavor > OpenBsdFlavor)
|
|
|
|
|
m_osFlavor = UnknownFlavor;
|
2011-05-31 08:55:57 +00:00
|
|
|
break;
|
2017-07-25 23:14:48 +03:00
|
|
|
case DarwinOS:
|
2016-07-25 18:39:16 -07:00
|
|
|
if (m_osFlavor < GenericDarwinFlavor || m_osFlavor > GenericDarwinFlavor)
|
2011-02-23 16:47:08 +01:00
|
|
|
m_osFlavor = UnknownFlavor;
|
2011-02-01 18:36:00 +01:00
|
|
|
break;
|
2017-07-25 23:14:48 +03:00
|
|
|
case UnixOS:
|
2013-10-24 13:33:52 +02:00
|
|
|
if (m_osFlavor < GenericUnixFlavor || m_osFlavor > SolarisUnixFlavor)
|
2011-02-23 16:47:08 +01:00
|
|
|
m_osFlavor = UnknownFlavor;
|
2011-02-01 18:36:00 +01:00
|
|
|
break;
|
2017-07-25 23:14:48 +03:00
|
|
|
case WindowsOS:
|
2011-03-18 09:54:35 +01:00
|
|
|
if (m_osFlavor < WindowsMsvc2005Flavor || m_osFlavor > WindowsCEFlavor)
|
2011-02-23 16:47:08 +01:00
|
|
|
m_osFlavor = UnknownFlavor;
|
2011-02-01 18:36:00 +01:00
|
|
|
break;
|
2017-07-25 23:14:48 +03:00
|
|
|
case VxWorks:
|
2014-12-16 16:34:08 +01:00
|
|
|
if (m_osFlavor != VxWorksFlavor)
|
|
|
|
|
m_osFlavor = VxWorksFlavor;
|
2017-03-27 09:42:15 +02:00
|
|
|
break;
|
2017-07-25 23:14:48 +03:00
|
|
|
case QnxOS:
|
2016-12-16 14:02:26 -05:00
|
|
|
if (m_osFlavor != GenericQnxFlavor)
|
|
|
|
|
m_osFlavor = UnknownFlavor;
|
2017-03-27 09:42:15 +02:00
|
|
|
break;
|
2017-07-25 23:52:09 +03:00
|
|
|
case BareMetalOS:
|
|
|
|
|
if (m_osFlavor != GenericBareMetalFlavor)
|
|
|
|
|
m_osFlavor = GenericBareMetalFlavor;
|
|
|
|
|
break;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Abi::Abi(const QString &abiString) :
|
2011-02-23 16:47:08 +01:00
|
|
|
m_architecture(UnknownArchitecture), m_os(UnknownOS),
|
|
|
|
|
m_osFlavor(UnknownFlavor), m_binaryFormat(UnknownFormat), m_wordWidth(0)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2017-07-25 23:14:48 +03:00
|
|
|
const QVector<QStringRef> abiParts = abiString.splitRef('-');
|
2011-02-01 18:36:00 +01:00
|
|
|
if (abiParts.count() >= 1) {
|
2017-07-25 23:14:48 +03:00
|
|
|
if (abiParts.at(0) == "unknown")
|
2011-02-23 16:47:08 +01:00
|
|
|
m_architecture = UnknownArchitecture;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(0) == "arm")
|
2011-02-23 16:47:08 +01:00
|
|
|
m_architecture = ArmArchitecture;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(0) == "aarch64")
|
2016-03-15 15:28:29 +01:00
|
|
|
m_architecture = ArmArchitecture;
|
2017-07-25 23:52:09 +03:00
|
|
|
else if (abiParts.at(0) == "avr")
|
|
|
|
|
m_architecture = AvrArchitecture;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(0) == "x86")
|
2011-02-23 16:47:08 +01:00
|
|
|
m_architecture = X86Architecture;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(0) == "mips")
|
2011-08-31 09:55:34 +00:00
|
|
|
m_architecture = MipsArchitecture;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(0) == "ppc")
|
2011-02-23 16:47:08 +01:00
|
|
|
m_architecture = PowerPCArchitecture;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(0) == "itanium")
|
2011-02-23 16:47:08 +01:00
|
|
|
m_architecture = ItaniumArchitecture;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(0) == "sh")
|
2011-09-22 14:26:10 +00:00
|
|
|
m_architecture = ShArchitecture;
|
2011-02-01 18:36:00 +01:00
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (abiParts.count() >= 2) {
|
2017-07-25 23:14:48 +03:00
|
|
|
if (abiParts.at(1) == "unknown")
|
2011-02-23 16:47:08 +01:00
|
|
|
m_os = UnknownOS;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(1) == "linux")
|
2011-02-23 16:47:08 +01:00
|
|
|
m_os = LinuxOS;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(1) == "bsd")
|
2011-05-31 10:06:32 +00:00
|
|
|
m_os = BsdOS;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(1) == "darwin"
|
|
|
|
|
|| abiParts.at(1) == "macos")
|
2016-07-25 18:39:16 -07:00
|
|
|
m_os = DarwinOS;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(1) == "unix")
|
2011-02-23 16:47:08 +01:00
|
|
|
m_os = UnixOS;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(1) == "windows")
|
2011-02-23 16:47:08 +01:00
|
|
|
m_os = WindowsOS;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(1) == "vxworks")
|
2014-12-16 16:34:08 +01:00
|
|
|
m_os = VxWorks;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(1) == "qnx")
|
2016-12-16 14:02:26 -05:00
|
|
|
m_os = QnxOS;
|
2011-02-01 18:36:00 +01:00
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (abiParts.count() >= 3) {
|
2017-07-25 23:14:48 +03:00
|
|
|
if (abiParts.at(2) == "unknown")
|
2011-02-23 16:47:08 +01:00
|
|
|
m_osFlavor = UnknownFlavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "generic" && m_os == LinuxOS)
|
2011-02-23 16:47:08 +01:00
|
|
|
m_osFlavor = GenericLinuxFlavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "android" && m_os == LinuxOS)
|
2012-04-18 20:30:57 +03:00
|
|
|
m_osFlavor = AndroidLinuxFlavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "generic" && m_os == QnxOS)
|
2016-12-16 14:02:26 -05:00
|
|
|
m_osFlavor = GenericQnxFlavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "freebsd" && m_os == BsdOS)
|
2011-05-31 10:06:32 +00:00
|
|
|
m_osFlavor = FreeBsdFlavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "netbsd" && m_os == BsdOS)
|
2011-05-31 10:06:32 +00:00
|
|
|
m_osFlavor = NetBsdFlavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "openbsd" && m_os == BsdOS)
|
2011-05-31 10:06:32 +00:00
|
|
|
m_osFlavor = OpenBsdFlavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "generic" && m_os == DarwinOS)
|
2016-07-25 18:39:16 -07:00
|
|
|
m_osFlavor = GenericDarwinFlavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "generic" && m_os == UnixOS)
|
2011-02-23 16:47:08 +01:00
|
|
|
m_osFlavor = GenericUnixFlavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "solaris" && m_os == UnixOS)
|
2011-05-31 10:06:32 +00:00
|
|
|
m_osFlavor = SolarisUnixFlavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "msvc2005" && m_os == WindowsOS)
|
2011-03-18 09:54:35 +01:00
|
|
|
m_osFlavor = WindowsMsvc2005Flavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "msvc2008" && m_os == WindowsOS)
|
2011-03-18 09:54:35 +01:00
|
|
|
m_osFlavor = WindowsMsvc2008Flavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "msvc2010" && m_os == WindowsOS)
|
2011-03-18 09:54:35 +01:00
|
|
|
m_osFlavor = WindowsMsvc2010Flavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "msvc2012" && m_os == WindowsOS)
|
2012-07-27 20:34:46 +02:00
|
|
|
m_osFlavor = WindowsMsvc2012Flavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "msvc2013" && m_os == WindowsOS)
|
2013-10-20 23:44:52 +08:00
|
|
|
m_osFlavor = WindowsMsvc2013Flavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "msvc2015" && m_os == WindowsOS)
|
2015-06-12 11:30:43 +02:00
|
|
|
m_osFlavor = WindowsMsvc2015Flavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "msvc2017" && m_os == WindowsOS)
|
2016-11-23 09:06:44 +01:00
|
|
|
m_osFlavor = WindowsMsvc2017Flavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "msys" && m_os == WindowsOS)
|
2011-02-23 16:47:08 +01:00
|
|
|
m_osFlavor = WindowsMSysFlavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "ce" && m_os == WindowsOS)
|
2011-02-23 16:47:08 +01:00
|
|
|
m_osFlavor = WindowsCEFlavor;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(2) == "vxworks" && m_os == VxWorks)
|
2014-12-16 16:34:08 +01:00
|
|
|
m_osFlavor = VxWorksFlavor;
|
2011-02-01 18:36:00 +01:00
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (abiParts.count() >= 4) {
|
2017-07-25 23:14:48 +03:00
|
|
|
if (abiParts.at(3) == "unknown")
|
2011-02-23 16:47:08 +01:00
|
|
|
m_binaryFormat = UnknownFormat;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(3) == "elf")
|
2011-02-23 16:47:08 +01:00
|
|
|
m_binaryFormat = ElfFormat;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(3) == "pe")
|
2011-02-23 16:47:08 +01:00
|
|
|
m_binaryFormat = PEFormat;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(3) == "mach_o")
|
2011-02-23 16:47:08 +01:00
|
|
|
m_binaryFormat = MachOFormat;
|
2017-07-25 23:14:48 +03:00
|
|
|
else if (abiParts.at(3) == "qml_rt")
|
2011-02-23 16:47:08 +01:00
|
|
|
m_binaryFormat = RuntimeQmlFormat;
|
2011-02-01 18:36:00 +01:00
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (abiParts.count() >= 5) {
|
2016-11-23 10:10:55 +01:00
|
|
|
const QStringRef &bits = abiParts.at(4);
|
2017-07-25 23:14:48 +03:00
|
|
|
if (!bits.endsWith("bit"))
|
2011-02-01 18:36:00 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bool ok = false;
|
2016-11-23 10:10:55 +01:00
|
|
|
const QStringRef number =
|
|
|
|
|
bits.string()->midRef(bits.position(), bits.count() - 3);
|
|
|
|
|
const int bitCount = number.toInt(&ok);
|
2011-02-01 18:36:00 +01:00
|
|
|
if (!ok)
|
|
|
|
|
return;
|
|
|
|
|
if (bitCount != 8 && bitCount != 16 && bitCount != 32 && bitCount != 64)
|
|
|
|
|
return;
|
|
|
|
|
m_wordWidth = bitCount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-23 11:45:39 +02:00
|
|
|
Abi Abi::abiFromTargetTriplet(const QString &triple)
|
|
|
|
|
{
|
2017-09-29 14:45:21 +02:00
|
|
|
const QString machine = triple.toLower();
|
2013-08-23 11:45:39 +02:00
|
|
|
if (machine.isEmpty())
|
|
|
|
|
return Abi();
|
|
|
|
|
|
2017-07-25 23:14:48 +03:00
|
|
|
const QVector<QStringRef> parts = machine.splitRef(QRegExp("[ /-]"));
|
2013-08-23 11:45:39 +02:00
|
|
|
|
2017-07-25 23:14:48 +03:00
|
|
|
Architecture arch = UnknownArchitecture;
|
|
|
|
|
OS os = UnknownOS;
|
|
|
|
|
OSFlavor flavor = UnknownFlavor;
|
|
|
|
|
BinaryFormat format = UnknownFormat;
|
2015-11-16 12:53:08 +01:00
|
|
|
unsigned char width = 0;
|
2013-08-23 11:45:39 +02:00
|
|
|
int unknownCount = 0;
|
|
|
|
|
|
2016-11-23 10:10:55 +01:00
|
|
|
for (const QStringRef &p : parts) {
|
2017-07-25 23:14:48 +03:00
|
|
|
if (p == "unknown" || p == "pc" || p == "none"
|
|
|
|
|
|| p == "gnu" || p == "uclibc"
|
|
|
|
|
|| p == "86_64" || p == "redhat"
|
|
|
|
|
|| p == "gnueabi" || p == "w64") {
|
2013-08-23 11:45:39 +02:00
|
|
|
continue;
|
2017-07-25 23:14:48 +03:00
|
|
|
} else if (p == "i386" || p == "i486" || p == "i586"
|
|
|
|
|
|| p == "i686" || p == "x86") {
|
|
|
|
|
arch = X86Architecture;
|
2014-07-24 13:58:32 +02:00
|
|
|
width = 32;
|
2017-07-25 23:14:48 +03:00
|
|
|
} else if (p.startsWith("arm")) {
|
|
|
|
|
arch = ArmArchitecture;
|
|
|
|
|
width = p.contains("64") ? 64 : 32;
|
|
|
|
|
} else if (p.startsWith("aarch64")) {
|
|
|
|
|
arch = ArmArchitecture;
|
2016-03-15 15:28:29 +01:00
|
|
|
width = 64;
|
2017-07-25 23:52:09 +03:00
|
|
|
} else if (p == "avr") {
|
|
|
|
|
arch = AvrArchitecture;
|
|
|
|
|
os = BareMetalOS;
|
|
|
|
|
flavor = GenericBareMetalFlavor;
|
|
|
|
|
format = ElfFormat;
|
|
|
|
|
width = 16;
|
2017-07-25 23:14:48 +03:00
|
|
|
} else if (p.startsWith("mips")) {
|
|
|
|
|
arch = MipsArchitecture;
|
|
|
|
|
width = p.contains("64") ? 64 : 32;
|
|
|
|
|
} else if (p == "x86_64" || p == "amd64") {
|
|
|
|
|
arch = X86Architecture;
|
2013-08-23 11:45:39 +02:00
|
|
|
width = 64;
|
2017-07-25 23:14:48 +03:00
|
|
|
} else if (p == "powerpc64") {
|
|
|
|
|
arch = PowerPCArchitecture;
|
2013-08-23 11:45:39 +02:00
|
|
|
width = 64;
|
2017-07-25 23:14:48 +03:00
|
|
|
} else if (p == "powerpc") {
|
|
|
|
|
arch = PowerPCArchitecture;
|
2013-08-23 11:45:39 +02:00
|
|
|
width = 32;
|
2017-07-25 23:14:48 +03:00
|
|
|
} else if (p == "linux" || p == "linux6e") {
|
|
|
|
|
os = LinuxOS;
|
|
|
|
|
if (flavor == UnknownFlavor)
|
|
|
|
|
flavor = GenericLinuxFlavor;
|
|
|
|
|
format = ElfFormat;
|
|
|
|
|
} else if (p == "android") {
|
|
|
|
|
flavor = AndroidLinuxFlavor;
|
|
|
|
|
} else if (p == "androideabi") {
|
|
|
|
|
flavor = AndroidLinuxFlavor;
|
|
|
|
|
} else if (p.startsWith("freebsd")) {
|
|
|
|
|
os = BsdOS;
|
|
|
|
|
if (flavor == UnknownFlavor)
|
|
|
|
|
flavor = FreeBsdFlavor;
|
|
|
|
|
format = ElfFormat;
|
|
|
|
|
} else if (p.startsWith("openbsd")) {
|
|
|
|
|
os = BsdOS;
|
|
|
|
|
if (flavor == UnknownFlavor)
|
|
|
|
|
flavor = OpenBsdFlavor;
|
|
|
|
|
format = ElfFormat;
|
|
|
|
|
} else if (p == "mingw32" || p == "win32"
|
|
|
|
|
|| p == "mingw32msvc" || p == "msys"
|
|
|
|
|
|| p == "cygwin" || p == "windows") {
|
|
|
|
|
arch = X86Architecture;
|
|
|
|
|
os = WindowsOS;
|
|
|
|
|
flavor = WindowsMSysFlavor;
|
|
|
|
|
format = PEFormat;
|
|
|
|
|
} else if (p == "apple") {
|
|
|
|
|
os = DarwinOS;
|
|
|
|
|
flavor = GenericDarwinFlavor;
|
|
|
|
|
format = MachOFormat;
|
|
|
|
|
} else if (p == "darwin10") {
|
2013-08-23 11:45:39 +02:00
|
|
|
width = 64;
|
2017-07-25 23:14:48 +03:00
|
|
|
} else if (p == "darwin9") {
|
2013-08-23 11:45:39 +02:00
|
|
|
width = 32;
|
2017-07-25 23:14:48 +03:00
|
|
|
} else if (p == "gnueabi") {
|
|
|
|
|
format = ElfFormat;
|
|
|
|
|
} else if (p == "wrs") {
|
2014-12-16 16:34:08 +01:00
|
|
|
continue;
|
2017-07-25 23:14:48 +03:00
|
|
|
} else if (p == "vxworks") {
|
|
|
|
|
os = VxWorks;
|
|
|
|
|
flavor = VxWorksFlavor;
|
|
|
|
|
format = ElfFormat;
|
|
|
|
|
} else if (p.startsWith("qnx")) {
|
|
|
|
|
os = QnxOS;
|
|
|
|
|
flavor = GenericQnxFlavor;
|
|
|
|
|
format = ElfFormat;
|
2013-08-23 11:45:39 +02:00
|
|
|
} else {
|
|
|
|
|
++unknownCount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Abi(arch, os, flavor, format, width);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QString Abi::toString() const
|
|
|
|
|
{
|
2017-07-26 22:40:53 +03:00
|
|
|
const QStringList dn = {toString(m_architecture), toString(m_os), toString(m_osFlavor),
|
|
|
|
|
toString(m_binaryFormat), toString(m_wordWidth)};
|
2017-07-25 23:14:48 +03:00
|
|
|
return dn.join('-');
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2011-03-10 14:43:44 +01:00
|
|
|
bool Abi::operator != (const Abi &other) const
|
|
|
|
|
{
|
|
|
|
|
return !operator ==(other);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
bool Abi::operator == (const Abi &other) const
|
|
|
|
|
{
|
|
|
|
|
return m_architecture == other.m_architecture
|
|
|
|
|
&& m_os == other.m_os
|
|
|
|
|
&& m_osFlavor == other.m_osFlavor
|
|
|
|
|
&& m_binaryFormat == other.m_binaryFormat
|
|
|
|
|
&& m_wordWidth == other.m_wordWidth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Abi::isCompatibleWith(const Abi &other) const
|
|
|
|
|
{
|
2017-04-26 11:18:01 +02:00
|
|
|
// Generic match: If stuff is identical or the other side is unknown, then this is a match.
|
|
|
|
|
bool isCompat = (architecture() == other.architecture() || other.architecture() == UnknownArchitecture)
|
|
|
|
|
&& (os() == other.os() || other.os() == UnknownOS)
|
|
|
|
|
&& (osFlavor() == other.osFlavor() || other.osFlavor() == UnknownFlavor)
|
|
|
|
|
&& (binaryFormat() == other.binaryFormat() || other.binaryFormat() == UnknownFormat)
|
2011-03-28 15:25:50 +02:00
|
|
|
&& ((wordWidth() == other.wordWidth() && wordWidth() != 0) || other.wordWidth() == 0);
|
2017-04-26 11:18:01 +02:00
|
|
|
|
2011-09-09 09:51:58 +00:00
|
|
|
// *-linux-generic-* is compatible with *-linux-* (both ways): This is for the benefit of
|
|
|
|
|
// people building Qt themselves using e.g. a meego toolchain.
|
|
|
|
|
//
|
2017-04-26 11:18:01 +02:00
|
|
|
// We leave it to the specific targets to filter out the tool chains that do not
|
2011-09-09 09:51:58 +00:00
|
|
|
// work for them.
|
2017-04-26 11:18:01 +02:00
|
|
|
if (!isCompat && (architecture() == other.architecture() || other.architecture() == UnknownArchitecture)
|
2011-09-16 11:35:38 +00:00
|
|
|
&& ((os() == other.os()) && (os() == LinuxOS))
|
2011-09-09 09:51:58 +00:00
|
|
|
&& (osFlavor() == GenericLinuxFlavor || other.osFlavor() == GenericLinuxFlavor)
|
2017-04-26 11:18:01 +02:00
|
|
|
&& (binaryFormat() == other.binaryFormat() || other.binaryFormat() == UnknownFormat)
|
|
|
|
|
&& ((wordWidth() == other.wordWidth() && wordWidth() != 0) || other.wordWidth() == 0)) {
|
|
|
|
|
isCompat = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make Android matching more strict than the generic Linux matches so far:
|
|
|
|
|
if (isCompat && (osFlavor() == AndroidLinuxFlavor || other.osFlavor() == AndroidLinuxFlavor))
|
|
|
|
|
isCompat = (architecture() == other.architecture()) && (osFlavor() == other.osFlavor());
|
|
|
|
|
|
|
|
|
|
// MSVC2017 is compatible with MSVC2015
|
|
|
|
|
if (!isCompat
|
|
|
|
|
&& ((osFlavor() == WindowsMsvc2015Flavor && other.osFlavor() == WindowsMsvc2017Flavor)
|
|
|
|
|
|| (osFlavor() == WindowsMsvc2017Flavor && other.osFlavor() == WindowsMsvc2015Flavor))) {
|
2011-03-28 15:25:50 +02:00
|
|
|
isCompat = true;
|
2017-04-26 11:18:01 +02:00
|
|
|
}
|
2011-03-28 15:25:50 +02:00
|
|
|
return isCompat;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Abi::isValid() const
|
|
|
|
|
{
|
2011-02-23 16:47:08 +01:00
|
|
|
return m_architecture != UnknownArchitecture
|
|
|
|
|
&& m_os != UnknownOS
|
|
|
|
|
&& m_osFlavor != UnknownFlavor
|
|
|
|
|
&& m_binaryFormat != UnknownFormat
|
2011-02-01 18:36:00 +01:00
|
|
|
&& m_wordWidth != 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-06 14:24:13 +00:00
|
|
|
bool Abi::isNull() const
|
|
|
|
|
{
|
|
|
|
|
return m_architecture == UnknownArchitecture
|
|
|
|
|
&& m_os == UnknownOS
|
|
|
|
|
&& m_osFlavor == UnknownFlavor
|
|
|
|
|
&& m_binaryFormat == UnknownFormat
|
|
|
|
|
&& m_wordWidth == 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QString Abi::toString(const Architecture &a)
|
|
|
|
|
{
|
|
|
|
|
switch (a) {
|
2011-02-23 16:47:08 +01:00
|
|
|
case ArmArchitecture:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("arm");
|
2017-07-25 23:52:09 +03:00
|
|
|
case AvrArchitecture:
|
|
|
|
|
return QLatin1String("avr");
|
2011-02-23 16:47:08 +01:00
|
|
|
case X86Architecture:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("x86");
|
2011-08-31 09:55:34 +00:00
|
|
|
case MipsArchitecture:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("mips");
|
2011-02-23 16:47:08 +01:00
|
|
|
case PowerPCArchitecture:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("ppc");
|
2011-02-23 16:47:08 +01:00
|
|
|
case ItaniumArchitecture:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("itanium");
|
2011-09-22 14:26:10 +00:00
|
|
|
case ShArchitecture:
|
2011-09-23 11:57:11 +00:00
|
|
|
return QLatin1String("sh");
|
2018-01-10 16:51:58 +01:00
|
|
|
case UnknownArchitecture:
|
|
|
|
|
Q_FALLTHROUGH();
|
2011-02-01 18:36:00 +01:00
|
|
|
default:
|
|
|
|
|
return QLatin1String("unknown");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Abi::toString(const OS &o)
|
|
|
|
|
{
|
|
|
|
|
switch (o) {
|
2011-02-23 16:47:08 +01:00
|
|
|
case LinuxOS:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("linux");
|
2011-05-31 10:06:32 +00:00
|
|
|
case BsdOS:
|
|
|
|
|
return QLatin1String("bsd");
|
2016-07-25 18:39:16 -07:00
|
|
|
case DarwinOS:
|
|
|
|
|
return QLatin1String("darwin");
|
2011-02-23 16:47:08 +01:00
|
|
|
case UnixOS:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("unix");
|
2011-02-23 16:47:08 +01:00
|
|
|
case WindowsOS:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("windows");
|
2014-12-16 16:34:08 +01:00
|
|
|
case VxWorks:
|
|
|
|
|
return QLatin1String("vxworks");
|
2016-12-16 14:02:26 -05:00
|
|
|
case QnxOS:
|
|
|
|
|
return QLatin1String("qnx");
|
2017-07-25 23:52:09 +03:00
|
|
|
case BareMetalOS:
|
|
|
|
|
return QLatin1String("baremetal");
|
2018-01-10 16:51:58 +01:00
|
|
|
case UnknownOS:
|
|
|
|
|
Q_FALLTHROUGH();
|
2011-02-01 18:36:00 +01:00
|
|
|
default:
|
|
|
|
|
return QLatin1String("unknown");
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-23 16:47:08 +01:00
|
|
|
QString Abi::toString(const OSFlavor &of)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
|
|
|
|
switch (of) {
|
2017-07-25 23:14:48 +03:00
|
|
|
case GenericLinuxFlavor:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("generic");
|
2017-07-25 23:14:48 +03:00
|
|
|
case AndroidLinuxFlavor:
|
2012-04-18 20:30:57 +03:00
|
|
|
return QLatin1String("android");
|
2017-07-25 23:14:48 +03:00
|
|
|
case FreeBsdFlavor:
|
2011-05-31 10:06:32 +00:00
|
|
|
return QLatin1String("freebsd");
|
2017-07-25 23:14:48 +03:00
|
|
|
case NetBsdFlavor:
|
2011-05-31 10:06:32 +00:00
|
|
|
return QLatin1String("netbsd");
|
2017-07-25 23:14:48 +03:00
|
|
|
case OpenBsdFlavor:
|
2011-05-31 10:06:32 +00:00
|
|
|
return QLatin1String("openbsd");
|
2017-07-25 23:14:48 +03:00
|
|
|
case GenericDarwinFlavor:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("generic");
|
2017-07-25 23:14:48 +03:00
|
|
|
case GenericUnixFlavor:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("generic");
|
2017-07-25 23:14:48 +03:00
|
|
|
case SolarisUnixFlavor:
|
2011-05-31 10:06:32 +00:00
|
|
|
return QLatin1String("solaris");
|
2017-07-25 23:14:48 +03:00
|
|
|
case WindowsMsvc2005Flavor:
|
2011-03-18 09:54:35 +01:00
|
|
|
return QLatin1String("msvc2005");
|
2017-07-25 23:14:48 +03:00
|
|
|
case WindowsMsvc2008Flavor:
|
2011-03-18 09:54:35 +01:00
|
|
|
return QLatin1String("msvc2008");
|
2017-07-25 23:14:48 +03:00
|
|
|
case WindowsMsvc2010Flavor:
|
2011-03-18 09:54:35 +01:00
|
|
|
return QLatin1String("msvc2010");
|
2017-07-25 23:14:48 +03:00
|
|
|
case WindowsMsvc2012Flavor:
|
2012-07-27 20:34:46 +02:00
|
|
|
return QLatin1String("msvc2012");
|
2017-07-25 23:14:48 +03:00
|
|
|
case WindowsMsvc2013Flavor:
|
2013-10-20 23:44:52 +08:00
|
|
|
return QLatin1String("msvc2013");
|
2017-07-25 23:14:48 +03:00
|
|
|
case WindowsMsvc2015Flavor:
|
2015-06-12 11:30:43 +02:00
|
|
|
return QLatin1String("msvc2015");
|
2017-07-25 23:14:48 +03:00
|
|
|
case WindowsMsvc2017Flavor:
|
2016-11-18 16:27:25 +01:00
|
|
|
return QLatin1String("msvc2017");
|
2017-07-25 23:14:48 +03:00
|
|
|
case WindowsMSysFlavor:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("msys");
|
2017-07-25 23:14:48 +03:00
|
|
|
case WindowsCEFlavor:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("ce");
|
2017-07-25 23:14:48 +03:00
|
|
|
case VxWorksFlavor:
|
2014-12-16 16:34:08 +01:00
|
|
|
return QLatin1String("vxworks");
|
2017-07-25 23:14:48 +03:00
|
|
|
case GenericQnxFlavor:
|
2017-07-25 23:52:09 +03:00
|
|
|
case GenericBareMetalFlavor:
|
2016-12-16 14:02:26 -05:00
|
|
|
return QLatin1String("generic");
|
2018-01-10 16:51:58 +01:00
|
|
|
case UnknownFlavor:
|
|
|
|
|
Q_FALLTHROUGH();
|
2011-02-01 18:36:00 +01:00
|
|
|
default:
|
|
|
|
|
return QLatin1String("unknown");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Abi::toString(const BinaryFormat &bf)
|
|
|
|
|
{
|
|
|
|
|
switch (bf) {
|
2011-02-23 16:47:08 +01:00
|
|
|
case ElfFormat:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("elf");
|
2011-02-23 16:47:08 +01:00
|
|
|
case PEFormat:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("pe");
|
2011-02-23 16:47:08 +01:00
|
|
|
case MachOFormat:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("mach_o");
|
2011-02-23 16:47:08 +01:00
|
|
|
case RuntimeQmlFormat:
|
2011-02-01 18:36:00 +01:00
|
|
|
return QLatin1String("qml_rt");
|
2018-01-10 16:51:58 +01:00
|
|
|
case UnknownFormat:
|
|
|
|
|
Q_FALLTHROUGH();
|
2011-02-01 18:36:00 +01:00
|
|
|
default:
|
|
|
|
|
return QLatin1String("unknown");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Abi::toString(int w)
|
|
|
|
|
{
|
|
|
|
|
if (w == 0)
|
|
|
|
|
return QLatin1String("unknown");
|
|
|
|
|
return QString::fromLatin1("%1bit").arg(w);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-24 14:06:51 +00:00
|
|
|
QList<Abi::OSFlavor> Abi::flavorsForOs(const Abi::OS &o)
|
|
|
|
|
{
|
|
|
|
|
switch (o) {
|
|
|
|
|
case BsdOS:
|
2017-07-26 22:40:53 +03:00
|
|
|
return {FreeBsdFlavor, OpenBsdFlavor, NetBsdFlavor, UnknownFlavor};
|
2011-05-24 14:06:51 +00:00
|
|
|
case LinuxOS:
|
2017-07-26 22:40:53 +03:00
|
|
|
return {GenericLinuxFlavor, AndroidLinuxFlavor, UnknownFlavor};
|
2016-07-25 18:39:16 -07:00
|
|
|
case DarwinOS:
|
2017-07-26 22:40:53 +03:00
|
|
|
return {GenericDarwinFlavor, UnknownFlavor};
|
2011-05-24 14:06:51 +00:00
|
|
|
case UnixOS:
|
2017-07-26 22:40:53 +03:00
|
|
|
return {GenericUnixFlavor, SolarisUnixFlavor, UnknownFlavor};
|
2011-05-24 14:06:51 +00:00
|
|
|
case WindowsOS:
|
2017-07-26 22:40:53 +03:00
|
|
|
return {WindowsMsvc2005Flavor, WindowsMsvc2008Flavor, WindowsMsvc2010Flavor,
|
|
|
|
|
WindowsMsvc2012Flavor, WindowsMsvc2013Flavor, WindowsMsvc2015Flavor,
|
|
|
|
|
WindowsMsvc2017Flavor , WindowsMSysFlavor, WindowsCEFlavor, UnknownFlavor};
|
2014-12-16 16:34:08 +01:00
|
|
|
case VxWorks:
|
2017-07-26 22:40:53 +03:00
|
|
|
return {VxWorksFlavor, UnknownFlavor};
|
2016-12-16 14:02:26 -05:00
|
|
|
case QnxOS:
|
2017-07-26 22:40:53 +03:00
|
|
|
return {GenericQnxFlavor, UnknownFlavor};
|
2017-07-25 23:52:09 +03:00
|
|
|
case BareMetalOS:
|
2017-09-29 14:44:58 +02:00
|
|
|
return {GenericBareMetalFlavor, UnknownFlavor};
|
2011-05-24 14:06:51 +00:00
|
|
|
case UnknownOS:
|
2017-07-26 22:40:53 +03:00
|
|
|
return {UnknownFlavor};
|
2011-05-24 14:06:51 +00:00
|
|
|
}
|
2017-09-29 14:45:21 +02:00
|
|
|
return QList<OSFlavor>();
|
2011-05-24 14:06:51 +00:00
|
|
|
}
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2017-04-06 16:25:16 +03:00
|
|
|
Abi::OSFlavor Abi::flavorForMsvcVersion(int version)
|
|
|
|
|
{
|
|
|
|
|
if (version >= 1910)
|
|
|
|
|
return WindowsMsvc2017Flavor;
|
|
|
|
|
switch (version) {
|
|
|
|
|
case 1900:
|
|
|
|
|
return WindowsMsvc2015Flavor;
|
|
|
|
|
case 1800:
|
|
|
|
|
return WindowsMsvc2013Flavor;
|
|
|
|
|
case 1700:
|
|
|
|
|
return WindowsMsvc2012Flavor;
|
|
|
|
|
case 1600:
|
|
|
|
|
return WindowsMsvc2010Flavor;
|
|
|
|
|
case 1500:
|
|
|
|
|
return WindowsMsvc2008Flavor;
|
|
|
|
|
case 1400:
|
|
|
|
|
return WindowsMsvc2005Flavor;
|
|
|
|
|
default:
|
|
|
|
|
return WindowsMSysFlavor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
Abi Abi::hostAbi()
|
|
|
|
|
{
|
2018-01-23 12:00:45 +01:00
|
|
|
Architecture arch = architectureFromQt();
|
2011-02-23 16:47:08 +01:00
|
|
|
OS os = UnknownOS;
|
|
|
|
|
OSFlavor subos = UnknownFlavor;
|
|
|
|
|
BinaryFormat format = UnknownFormat;
|
2011-02-01 18:36:00 +01:00
|
|
|
|
|
|
|
|
#if defined (Q_OS_WIN)
|
2011-02-23 16:47:08 +01:00
|
|
|
os = WindowsOS;
|
2017-04-06 16:25:16 +03:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
subos = flavorForMsvcVersion(_MSC_VER);
|
2012-08-27 10:45:20 +02:00
|
|
|
#elif defined (Q_CC_MINGW)
|
2011-03-18 09:54:35 +01:00
|
|
|
subos = WindowsMSysFlavor;
|
|
|
|
|
#endif
|
2011-02-23 16:47:08 +01:00
|
|
|
format = PEFormat;
|
2011-02-01 18:36:00 +01:00
|
|
|
#elif defined (Q_OS_LINUX)
|
2011-02-23 16:47:08 +01:00
|
|
|
os = LinuxOS;
|
|
|
|
|
subos = GenericLinuxFlavor;
|
|
|
|
|
format = ElfFormat;
|
2016-07-25 18:39:16 -07:00
|
|
|
#elif defined (Q_OS_DARWIN)
|
|
|
|
|
os = DarwinOS;
|
|
|
|
|
subos = GenericDarwinFlavor;
|
2011-02-23 16:47:08 +01:00
|
|
|
format = MachOFormat;
|
2014-12-30 14:23:49 +02:00
|
|
|
#elif defined (Q_OS_BSD4)
|
|
|
|
|
os = BsdOS;
|
|
|
|
|
# if defined (Q_OS_FREEBSD)
|
|
|
|
|
subos = FreeBsdFlavor;
|
|
|
|
|
# elif defined (Q_OS_NETBSD)
|
|
|
|
|
subos = NetBsdFlavor;
|
|
|
|
|
# elif defined (Q_OS_OPENBSD)
|
|
|
|
|
subos = OpenBsdFlavor;
|
|
|
|
|
# endif
|
|
|
|
|
format = ElfFormat;
|
2011-02-01 18:36:00 +01:00
|
|
|
#endif
|
|
|
|
|
|
2012-07-27 20:34:46 +02:00
|
|
|
const Abi result(arch, os, subos, format, QSysInfo::WordSize);
|
|
|
|
|
if (!result.isValid())
|
|
|
|
|
qWarning("Unable to completely determine the host ABI (%s).",
|
|
|
|
|
qPrintable(result.toString()));
|
|
|
|
|
return result;
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-13 15:07:32 +01:00
|
|
|
QList<Abi> Abi::abisOfBinary(const Utils::FileName &path)
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
2011-03-21 18:04:24 +01:00
|
|
|
QList<Abi> tmp;
|
2011-02-01 18:36:00 +01:00
|
|
|
if (path.isEmpty())
|
2011-03-21 18:04:24 +01:00
|
|
|
return tmp;
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2012-01-13 15:07:32 +01:00
|
|
|
QFile f(path.toString());
|
2011-02-01 18:36:00 +01:00
|
|
|
if (!f.exists())
|
2011-03-21 18:04:24 +01:00
|
|
|
return tmp;
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2013-01-14 11:42:09 +01:00
|
|
|
if (!f.open(QFile::ReadOnly))
|
|
|
|
|
return tmp;
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QByteArray data = f.read(1024);
|
2011-03-02 14:09:18 +01:00
|
|
|
if (data.size() >= 67
|
2011-08-31 15:09:18 +00:00
|
|
|
&& getUint8(data, 0) == '!' && getUint8(data, 1) == '<' && getUint8(data, 2) == 'a'
|
|
|
|
|
&& getUint8(data, 3) == 'r' && getUint8(data, 4) == 'c' && getUint8(data, 5) == 'h'
|
|
|
|
|
&& getUint8(data, 6) == '>' && getUint8(data, 7) == 0x0a) {
|
2011-03-21 18:04:24 +01:00
|
|
|
// We got an ar file: possibly a static lib for ELF, PE or Mach-O
|
2011-03-02 14:09:18 +01:00
|
|
|
|
|
|
|
|
data = data.mid(8); // Cut of ar file magic
|
|
|
|
|
quint64 offset = 8;
|
|
|
|
|
|
|
|
|
|
while (!data.isEmpty()) {
|
2011-08-31 15:09:18 +00:00
|
|
|
if ((getUint8(data, 58) != 0x60 || getUint8(data, 59) != 0x0a)) {
|
2012-01-13 15:07:32 +01:00
|
|
|
qWarning() << path.toString() << ": Thought it was an ar-file, but it is not!";
|
2011-02-01 18:36:00 +01:00
|
|
|
break;
|
2011-03-02 14:09:18 +01:00
|
|
|
}
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2011-03-02 14:09:18 +01:00
|
|
|
const QString fileName = QString::fromLocal8Bit(data.mid(0, 16));
|
|
|
|
|
quint64 fileNameOffset = 0;
|
2017-07-25 23:14:48 +03:00
|
|
|
if (fileName.startsWith("#1/"))
|
2016-02-03 13:49:53 +01:00
|
|
|
fileNameOffset = fileName.midRef(3).toInt();
|
2012-09-21 13:54:38 +02:00
|
|
|
const QString fileLength = QString::fromLatin1(data.mid(48, 10));
|
2011-03-01 18:04:16 +01:00
|
|
|
|
2011-03-03 11:29:07 +01:00
|
|
|
int toSkip = 60 + fileNameOffset;
|
2011-03-02 14:09:18 +01:00
|
|
|
offset += fileLength.toInt() + 60 /* header */;
|
2011-05-06 17:56:21 +02:00
|
|
|
|
|
|
|
|
tmp.append(abiOf(data.mid(toSkip)));
|
2017-07-25 23:14:48 +03:00
|
|
|
if (tmp.isEmpty() && fileName == "/0 ")
|
2011-05-06 17:56:21 +02:00
|
|
|
tmp = parseCoffHeader(data.mid(toSkip, 20)); // This might be windws...
|
|
|
|
|
|
2017-07-25 23:14:48 +03:00
|
|
|
if (!tmp.isEmpty() && tmp.at(0).binaryFormat() != MachOFormat)
|
2011-02-01 18:36:00 +01:00
|
|
|
break;
|
2011-03-01 18:04:16 +01:00
|
|
|
|
2011-05-10 15:19:38 +02:00
|
|
|
offset += (offset % 2); // ar is 2 byte aligned
|
2011-04-11 12:47:31 +02:00
|
|
|
f.seek(offset);
|
2011-03-02 14:09:18 +01:00
|
|
|
data = f.read(1024);
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
2011-03-02 14:09:18 +01:00
|
|
|
} else {
|
2011-03-21 18:04:24 +01:00
|
|
|
tmp = abiOf(data);
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
2011-03-02 14:09:18 +01:00
|
|
|
f.close();
|
|
|
|
|
|
2011-03-21 18:04:24 +01:00
|
|
|
// Remove duplicates:
|
|
|
|
|
QList<Abi> result;
|
|
|
|
|
foreach (const Abi &a, tmp) {
|
|
|
|
|
if (!result.contains(a))
|
|
|
|
|
result.append(a);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace ProjectExplorer
|
2011-03-21 18:04:24 +01:00
|
|
|
|
|
|
|
|
// Unit tests:
|
|
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
# include <QTest>
|
2012-02-15 10:42:41 +01:00
|
|
|
# include <QFileInfo>
|
2011-03-21 18:04:24 +01:00
|
|
|
|
|
|
|
|
# include "projectexplorer.h"
|
|
|
|
|
|
|
|
|
|
void ProjectExplorer::ProjectExplorerPlugin::testAbiOfBinary_data()
|
|
|
|
|
{
|
|
|
|
|
QTest::addColumn<QString>("file");
|
|
|
|
|
QTest::addColumn<QStringList>("abis");
|
|
|
|
|
|
|
|
|
|
QTest::newRow("no file")
|
|
|
|
|
<< QString()
|
|
|
|
|
<< (QStringList());
|
|
|
|
|
QTest::newRow("non existing file")
|
|
|
|
|
<< QString::fromLatin1("/does/not/exist")
|
|
|
|
|
<< (QStringList());
|
|
|
|
|
|
|
|
|
|
// Set up prefix for test data now that we can be sure to have some tests to run:
|
2012-01-09 16:30:33 +01:00
|
|
|
QString prefix = QString::fromLocal8Bit(qgetenv("QTC_TEST_EXTRADATALOCATION"));
|
2011-03-21 18:04:24 +01:00
|
|
|
if (prefix.isEmpty())
|
|
|
|
|
return;
|
2017-07-25 23:14:48 +03:00
|
|
|
prefix += "/projectexplorer/abi";
|
2011-06-24 12:08:29 +02:00
|
|
|
|
2011-03-21 18:04:24 +01:00
|
|
|
QFileInfo fi(prefix);
|
|
|
|
|
if (!fi.exists() || !fi.isDir())
|
|
|
|
|
return;
|
|
|
|
|
prefix = fi.absoluteFilePath();
|
|
|
|
|
|
|
|
|
|
QTest::newRow("text file")
|
|
|
|
|
<< QString::fromLatin1("%1/broken/text.txt").arg(prefix)
|
|
|
|
|
<< (QStringList());
|
|
|
|
|
|
|
|
|
|
QTest::newRow("static QtCore: win msvc2008")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/static/win-msvc2008-release.lib").arg(prefix)
|
2011-03-21 18:04:24 +01:00
|
|
|
<< (QStringList() << QString::fromLatin1("x86-windows-unknown-pe-32bit"));
|
2011-04-11 12:47:31 +02:00
|
|
|
QTest::newRow("static QtCore: win msvc2008 II")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/static/win-msvc2008-release2.lib").arg(prefix)
|
2011-04-11 12:47:31 +02:00
|
|
|
<< (QStringList() << QString::fromLatin1("x86-windows-unknown-pe-64bit"));
|
2011-03-21 18:04:24 +01:00
|
|
|
QTest::newRow("static QtCore: win msvc2008 (debug)")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/static/win-msvc2008-debug.lib").arg(prefix)
|
2011-03-21 18:04:24 +01:00
|
|
|
<< (QStringList() << QString::fromLatin1("x86-windows-unknown-pe-32bit"));
|
2011-05-06 17:56:21 +02:00
|
|
|
QTest::newRow("static QtCore: win mingw")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/static/win-mingw.a").arg(prefix)
|
2011-05-06 17:56:21 +02:00
|
|
|
<< (QStringList() << QString::fromLatin1("x86-windows-unknown-pe-32bit"));
|
2011-03-21 18:04:24 +01:00
|
|
|
QTest::newRow("static QtCore: mac (debug)")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/static/mac-32bit-debug.a").arg(prefix)
|
2016-07-25 18:39:16 -07:00
|
|
|
<< (QStringList() << QString::fromLatin1("x86-darwin-generic-mach_o-32bit"));
|
2011-03-21 18:04:24 +01:00
|
|
|
QTest::newRow("static QtCore: linux 32bit")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/static/linux-32bit-release.a").arg(prefix)
|
2011-03-21 18:04:24 +01:00
|
|
|
<< (QStringList() << QString::fromLatin1("x86-linux-generic-elf-32bit"));
|
|
|
|
|
QTest::newRow("static QtCore: linux 64bit")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/static/linux-64bit-release.a").arg(prefix)
|
2011-03-21 18:04:24 +01:00
|
|
|
<< (QStringList() << QString::fromLatin1("x86-linux-generic-elf-64bit"));
|
|
|
|
|
|
|
|
|
|
QTest::newRow("static stdc++: mac fat")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/static/mac-fat.a").arg(prefix)
|
2016-07-25 18:39:16 -07:00
|
|
|
<< (QStringList() << QString::fromLatin1("x86-darwin-generic-mach_o-32bit")
|
|
|
|
|
<< QString::fromLatin1("ppc-darwin-generic-mach_o-32bit")
|
|
|
|
|
<< QString::fromLatin1("x86-darwin-generic-mach_o-64bit"));
|
2011-03-21 18:04:24 +01:00
|
|
|
|
2013-10-21 11:59:26 +02:00
|
|
|
QTest::newRow("executable: win msvc2013 64bit")
|
|
|
|
|
<< QString::fromLatin1("%1/executables/x86-windows-mvsc2013-pe-64bit.exe").arg(prefix)
|
|
|
|
|
<< (QStringList() << QString::fromLatin1("x86-windows-msvc2013-pe-64bit"));
|
|
|
|
|
QTest::newRow("executable: win msvc2013 32bit")
|
|
|
|
|
<< QString::fromLatin1("%1/executables/x86-windows-mvsc2013-pe-32bit.exe").arg(prefix)
|
|
|
|
|
<< (QStringList() << QString::fromLatin1("x86-windows-msvc2013-pe-32bit"));
|
|
|
|
|
QTest::newRow("dynamic: win msvc2013 64bit")
|
|
|
|
|
<< QString::fromLatin1("%1/dynamic/x86-windows-mvsc2013-pe-64bit.dll").arg(prefix)
|
|
|
|
|
<< (QStringList() << QString::fromLatin1("x86-windows-msvc2013-pe-64bit"));
|
|
|
|
|
QTest::newRow("dynamic: win msvc2013 32bit")
|
|
|
|
|
<< QString::fromLatin1("%1/dynamic/x86-windows-mvsc2013-pe-32bit.dll").arg(prefix)
|
|
|
|
|
<< (QStringList() << QString::fromLatin1("x86-windows-msvc2013-pe-32bit"));
|
2011-03-21 18:04:24 +01:00
|
|
|
QTest::newRow("dynamic QtCore: win msvc2010 64bit")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/dynamic/win-msvc2010-64bit.dll").arg(prefix)
|
2011-03-21 18:04:24 +01:00
|
|
|
<< (QStringList() << QString::fromLatin1("x86-windows-msvc2010-pe-64bit"));
|
|
|
|
|
QTest::newRow("dynamic QtCore: win msvc2008 32bit")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/dynamic/win-msvc2008-32bit.dll").arg(prefix)
|
2011-03-21 18:04:24 +01:00
|
|
|
<< (QStringList() << QString::fromLatin1("x86-windows-msvc2008-pe-32bit"));
|
|
|
|
|
QTest::newRow("dynamic QtCore: win msvc2005 32bit")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/dynamic/win-msvc2005-32bit.dll").arg(prefix)
|
2011-03-21 18:04:24 +01:00
|
|
|
<< (QStringList() << QString::fromLatin1("x86-windows-msvc2005-pe-32bit"));
|
|
|
|
|
QTest::newRow("dynamic QtCore: win msys 32bit")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/dynamic/win-mingw-32bit.dll").arg(prefix)
|
2011-03-21 18:04:24 +01:00
|
|
|
<< (QStringList() << QString::fromLatin1("x86-windows-msys-pe-32bit"));
|
2012-09-20 13:25:35 +02:00
|
|
|
QTest::newRow("dynamic QtCore: win mingw 64bit")
|
|
|
|
|
<< QString::fromLatin1("%1/dynamic/win-mingw-64bit.dll").arg(prefix)
|
|
|
|
|
<< (QStringList() << QString::fromLatin1("x86-windows-msys-pe-64bit"));
|
2013-02-07 14:22:08 +01:00
|
|
|
QTest::newRow("dynamic QtCore: wince mips msvc2005 32bit")
|
2011-07-11 14:22:28 +00:00
|
|
|
<< QString::fromLatin1("%1/dynamic/wince-32bit.dll").arg(prefix)
|
|
|
|
|
<< (QStringList() << QString::fromLatin1("mips-windows-msvc2005-pe-32bit"));
|
2013-02-07 14:22:08 +01:00
|
|
|
QTest::newRow("dynamic QtCore: wince arm msvc2008 32bit")
|
|
|
|
|
<< QString::fromLatin1("%1/dynamic/arm-win-ce-pe-32bit").arg(prefix)
|
|
|
|
|
<< (QStringList() << QString::fromLatin1("arm-windows-msvc2008-pe-32bit"));
|
|
|
|
|
|
2011-03-23 15:25:38 +01:00
|
|
|
QTest::newRow("dynamic stdc++: mac fat")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/dynamic/mac-fat.dylib").arg(prefix)
|
2016-07-25 18:39:16 -07:00
|
|
|
<< (QStringList() << QString::fromLatin1("x86-darwin-generic-mach_o-32bit")
|
|
|
|
|
<< QString::fromLatin1("ppc-darwin-generic-mach_o-32bit")
|
|
|
|
|
<< QString::fromLatin1("x86-darwin-generic-mach_o-64bit"));
|
2011-03-23 15:25:38 +01:00
|
|
|
QTest::newRow("dynamic QtCore: arm linux 32bit")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/dynamic/arm-linux.so").arg(prefix)
|
2011-03-23 15:25:38 +01:00
|
|
|
<< (QStringList() << QString::fromLatin1("arm-linux-generic-elf-32bit"));
|
2012-01-25 10:54:21 +01:00
|
|
|
QTest::newRow("dynamic QtCore: arm linux 32bit, using ARM as OSABI")
|
|
|
|
|
<< QString::fromLatin1("%1/dynamic/arm-linux2.so").arg(prefix)
|
|
|
|
|
<< (QStringList() << QString::fromLatin1("arm-linux-generic-elf-32bit"));
|
2011-08-31 15:20:28 +00:00
|
|
|
QTest::newRow("dynamic QtCore: arm linux 32bit (angstrom)")
|
|
|
|
|
<< QString::fromLatin1("%1/dynamic/arm-angstrom-linux.so").arg(prefix)
|
|
|
|
|
<< (QStringList() << QString::fromLatin1("arm-linux-generic-elf-32bit"));
|
2011-09-22 14:26:10 +00:00
|
|
|
QTest::newRow("dynamic QtCore: sh4 linux 32bit")
|
|
|
|
|
<< QString::fromLatin1("%1/dynamic/sh4-linux.so").arg(prefix)
|
|
|
|
|
<< (QStringList() << QString::fromLatin1("sh-linux-generic-elf-32bit"));
|
2011-04-06 10:04:57 +02:00
|
|
|
QTest::newRow("dynamic QtCore: mips linux 32bit")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/dynamic/mips-linux.so").arg(prefix)
|
2011-04-06 10:04:57 +02:00
|
|
|
<< (QStringList() << QString::fromLatin1("mips-linux-generic-elf-32bit"));
|
2011-06-24 12:08:29 +02:00
|
|
|
QTest::newRow("dynamic QtCore: projectexplorer/abi/static/win-msvc2010-32bit.libppc be linux 32bit")
|
|
|
|
|
<< QString::fromLatin1("%1/dynamic/ppcbe-linux-32bit.so").arg(prefix)
|
|
|
|
|
<< (QStringList() << QString::fromLatin1("ppc-linux-generic-elf-32bit"));
|
2011-05-31 10:06:32 +00:00
|
|
|
QTest::newRow("dynamic QtCore: x86 freebsd 64bit")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/dynamic/freebsd-elf-64bit.so").arg(prefix)
|
2011-05-31 10:06:32 +00:00
|
|
|
<< (QStringList() << QString::fromLatin1("x86-bsd-freebsd-elf-64bit"));
|
|
|
|
|
QTest::newRow("dynamic QtCore: x86 freebsd 64bit")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/dynamic/freebsd-elf-64bit.so").arg(prefix)
|
2011-05-31 10:06:32 +00:00
|
|
|
<< (QStringList() << QString::fromLatin1("x86-bsd-freebsd-elf-64bit"));
|
|
|
|
|
QTest::newRow("dynamic QtCore: x86 freebsd 32bit")
|
2011-06-24 12:08:29 +02:00
|
|
|
<< QString::fromLatin1("%1/dynamic/freebsd-elf-32bit.so").arg(prefix)
|
2011-05-31 10:06:32 +00:00
|
|
|
<< (QStringList() << QString::fromLatin1("x86-bsd-freebsd-elf-32bit"));
|
2011-09-22 14:26:10 +00:00
|
|
|
|
|
|
|
|
QTest::newRow("executable: x86 win 32bit cygwin executable")
|
|
|
|
|
<< QString::fromLatin1("%1/executable/cygwin-32bit.exe").arg(prefix)
|
|
|
|
|
<< (QStringList() << QString::fromLatin1("x86-windows-msys-pe-32bit"));
|
2011-09-23 15:53:55 +00:00
|
|
|
QTest::newRow("executable: x86 win 32bit mingw executable")
|
|
|
|
|
<< QString::fromLatin1("%1/executable/mingw-32bit.exe").arg(prefix)
|
|
|
|
|
<< (QStringList() << QString::fromLatin1("x86-windows-msys-pe-32bit"));
|
2011-03-21 18:04:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProjectExplorer::ProjectExplorerPlugin::testAbiOfBinary()
|
|
|
|
|
{
|
|
|
|
|
QFETCH(QString, file);
|
|
|
|
|
QFETCH(QStringList, abis);
|
|
|
|
|
|
2017-07-25 23:14:48 +03:00
|
|
|
QList<Abi> result = Abi::abisOfBinary(Utils::FileName::fromString(file));
|
2011-03-21 18:04:24 +01:00
|
|
|
QCOMPARE(result.count(), abis.count());
|
|
|
|
|
for (int i = 0; i < abis.count(); ++i)
|
|
|
|
|
QCOMPARE(result.at(i).toString(), abis.at(i));
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-24 14:06:51 +00:00
|
|
|
void ProjectExplorer::ProjectExplorerPlugin::testFlavorForOs()
|
|
|
|
|
{
|
2017-07-25 23:14:48 +03:00
|
|
|
QList<QList<Abi::OSFlavor> > flavorLists;
|
2011-05-24 14:06:51 +00:00
|
|
|
for (int i = 0; i != static_cast<int>(Abi::UnknownOS); ++i)
|
|
|
|
|
flavorLists.append(Abi::flavorsForOs(static_cast<Abi::OS>(i)));
|
|
|
|
|
|
|
|
|
|
int foundCounter = 0;
|
|
|
|
|
for (int i = 0; i != Abi::UnknownFlavor; ++i) {
|
|
|
|
|
foundCounter = 0;
|
|
|
|
|
// make sure i is in exactly on of the flavor lists!
|
|
|
|
|
foreach (const QList<Abi::OSFlavor> &l, flavorLists) {
|
2013-02-13 10:22:59 +01:00
|
|
|
QVERIFY(l.contains(Abi::UnknownFlavor));
|
2011-05-24 14:06:51 +00:00
|
|
|
if (l.contains(static_cast<Abi::OSFlavor>(i)))
|
|
|
|
|
++foundCounter;
|
|
|
|
|
}
|
|
|
|
|
QCOMPARE(foundCounter, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-04 15:33:54 +01:00
|
|
|
void ProjectExplorer::ProjectExplorerPlugin::testAbiFromTargetTriplet_data()
|
|
|
|
|
{
|
|
|
|
|
QTest::addColumn<int>("architecture");
|
|
|
|
|
QTest::addColumn<int>("os");
|
|
|
|
|
QTest::addColumn<int>("osFlavor");
|
|
|
|
|
QTest::addColumn<int>("binaryFormat");
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::addColumn<int>("wordWidth");
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::newRow("x86_64-apple-darwin") << int(Abi::X86Architecture)
|
2016-07-25 18:39:16 -07:00
|
|
|
<< int(Abi::DarwinOS) << int(Abi::GenericDarwinFlavor)
|
2014-08-04 16:19:01 +03:00
|
|
|
<< int(Abi::MachOFormat) << 64;
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::newRow("x86_64-apple-darwin12.5.0") << int(Abi::X86Architecture)
|
2016-07-25 18:39:16 -07:00
|
|
|
<< int(Abi::DarwinOS) << int(Abi::GenericDarwinFlavor)
|
2014-08-04 16:19:01 +03:00
|
|
|
<< int(Abi::MachOFormat) << 64;
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::newRow("x86_64-linux-gnu") << int(Abi::X86Architecture)
|
2014-02-04 15:33:54 +01:00
|
|
|
<< int(Abi::LinuxOS) << int(Abi::GenericLinuxFlavor)
|
2014-08-04 16:19:01 +03:00
|
|
|
<< int(Abi::ElfFormat) << 64;
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::newRow("x86_64-pc-mingw32msvc") << int(Abi::X86Architecture)
|
2014-02-04 15:33:54 +01:00
|
|
|
<< int(Abi::WindowsOS) << int(Abi::WindowsMSysFlavor)
|
2014-08-04 16:19:01 +03:00
|
|
|
<< int(Abi::PEFormat) << 64;
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::newRow("i586-pc-mingw32msvc") << int(Abi::X86Architecture)
|
2014-02-04 15:33:54 +01:00
|
|
|
<< int(Abi::WindowsOS) << int(Abi::WindowsMSysFlavor)
|
2014-07-24 13:58:32 +02:00
|
|
|
<< int(Abi::PEFormat) << 32;
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::newRow("i686-linux-gnu") << int(Abi::X86Architecture)
|
2014-02-04 15:33:54 +01:00
|
|
|
<< int(Abi::LinuxOS) << int(Abi::GenericLinuxFlavor)
|
2014-07-24 13:58:32 +02:00
|
|
|
<< int(Abi::ElfFormat) << 32;
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::newRow("i686-linux-android") << int(Abi::X86Architecture)
|
2014-02-04 15:33:54 +01:00
|
|
|
<< int(Abi::LinuxOS) << int(Abi::AndroidLinuxFlavor)
|
2014-07-24 13:58:32 +02:00
|
|
|
<< int(Abi::ElfFormat) << 32;
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::newRow("i686-pc-linux-android") << int(Abi::X86Architecture)
|
2014-02-04 15:33:54 +01:00
|
|
|
<< int(Abi::LinuxOS) << int(Abi::AndroidLinuxFlavor)
|
2014-07-24 13:58:32 +02:00
|
|
|
<< int(Abi::ElfFormat) << 32;
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::newRow("i686-pc-mingw32") << int(Abi::X86Architecture)
|
2014-02-04 15:33:54 +01:00
|
|
|
<< int(Abi::WindowsOS) << int(Abi::WindowsMSysFlavor)
|
2014-07-24 13:58:32 +02:00
|
|
|
<< int(Abi::PEFormat) << 32;
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::newRow("i686-w64-mingw32") << int(Abi::X86Architecture)
|
2014-02-04 15:33:54 +01:00
|
|
|
<< int(Abi::WindowsOS) << int(Abi::WindowsMSysFlavor)
|
2014-07-24 13:58:32 +02:00
|
|
|
<< int(Abi::PEFormat) << 32;
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2015-08-13 16:36:11 +03:00
|
|
|
QTest::newRow("x86_64-pc-msys") << int(Abi::X86Architecture)
|
|
|
|
|
<< int(Abi::WindowsOS) << int(Abi::WindowsMSysFlavor)
|
|
|
|
|
<< int(Abi::PEFormat) << 64;
|
|
|
|
|
|
2015-10-12 16:27:54 +03:00
|
|
|
QTest::newRow("x86_64-pc-cygwin") << int(Abi::X86Architecture)
|
|
|
|
|
<< int(Abi::WindowsOS) << int(Abi::WindowsMSysFlavor)
|
|
|
|
|
<< int(Abi::PEFormat) << 64;
|
|
|
|
|
|
2017-04-06 16:22:24 +03:00
|
|
|
QTest::newRow("x86-pc-windows-msvc") << int(Abi::X86Architecture)
|
|
|
|
|
<< int(Abi::WindowsOS) << int(Abi::WindowsMSysFlavor)
|
|
|
|
|
<< int(Abi::PEFormat) << 32;
|
|
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::newRow("mingw32") << int(Abi::X86Architecture)
|
2014-02-04 15:33:54 +01:00
|
|
|
<< int(Abi::WindowsOS) << int(Abi::WindowsMSysFlavor)
|
2014-08-04 16:19:01 +03:00
|
|
|
<< int(Abi::PEFormat) << 0;
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::newRow("arm-linux-android") << int(Abi::ArmArchitecture)
|
2014-02-04 15:33:54 +01:00
|
|
|
<< int(Abi::LinuxOS) << int(Abi::AndroidLinuxFlavor)
|
2014-08-04 16:19:01 +03:00
|
|
|
<< int(Abi::ElfFormat) << 32;
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::newRow("arm-linux-androideabi") << int(Abi::ArmArchitecture)
|
2014-02-04 15:33:54 +01:00
|
|
|
<< int(Abi::LinuxOS) << int(Abi::AndroidLinuxFlavor)
|
2014-08-04 16:19:01 +03:00
|
|
|
<< int(Abi::ElfFormat) << 32;
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::newRow("arm-none-linux-gnueabi") << int(Abi::ArmArchitecture)
|
2014-02-04 15:33:54 +01:00
|
|
|
<< int(Abi::LinuxOS) << int(Abi::GenericLinuxFlavor)
|
2014-08-04 16:19:01 +03:00
|
|
|
<< int(Abi::ElfFormat) << 32;
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::newRow("mipsel-linux-android") << int(Abi::MipsArchitecture)
|
2014-02-04 15:33:54 +01:00
|
|
|
<< int(Abi::LinuxOS) << int(Abi::AndroidLinuxFlavor)
|
2014-08-04 16:19:01 +03:00
|
|
|
<< int(Abi::ElfFormat) << 32;
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QTest::newRow("mipsel-unknown-linux-android") << int(Abi::MipsArchitecture)
|
2014-02-04 15:33:54 +01:00
|
|
|
<< int(Abi::LinuxOS) << int(Abi::AndroidLinuxFlavor)
|
2014-08-04 16:19:01 +03:00
|
|
|
<< int(Abi::ElfFormat) << 32;
|
2014-08-04 12:45:46 +03:00
|
|
|
|
|
|
|
|
QTest::newRow("mips-linux-gnu") << int(Abi::MipsArchitecture)
|
|
|
|
|
<< int(Abi::LinuxOS) << int(Abi::GenericLinuxFlavor)
|
|
|
|
|
<< int(Abi::ElfFormat) << 32;
|
|
|
|
|
|
2017-05-24 14:14:39 -07:00
|
|
|
QTest::newRow("mips64el-linux-android") << int(Abi::MipsArchitecture)
|
|
|
|
|
<< int(Abi::LinuxOS) << int(Abi::AndroidLinuxFlavor)
|
|
|
|
|
<< int(Abi::ElfFormat) << 64;
|
|
|
|
|
|
|
|
|
|
QTest::newRow("mips64el-unknown-linux-android") << int(Abi::MipsArchitecture)
|
|
|
|
|
<< int(Abi::LinuxOS) << int(Abi::AndroidLinuxFlavor)
|
|
|
|
|
<< int(Abi::ElfFormat) << 64;
|
|
|
|
|
|
2014-08-04 12:45:46 +03:00
|
|
|
QTest::newRow("mips64-linux-octeon-gnu") << int(Abi::MipsArchitecture)
|
|
|
|
|
<< int(Abi::LinuxOS) << int(Abi::GenericLinuxFlavor)
|
|
|
|
|
<< int(Abi::ElfFormat) << 64;
|
2014-08-11 23:41:30 +03:00
|
|
|
|
|
|
|
|
QTest::newRow("mips64el-linux-gnuabi") << int(Abi::MipsArchitecture)
|
|
|
|
|
<< int(Abi::LinuxOS) << int(Abi::GenericLinuxFlavor)
|
|
|
|
|
<< int(Abi::ElfFormat) << 64;
|
2014-12-16 16:34:08 +01:00
|
|
|
|
|
|
|
|
QTest::newRow("arm-wrs-vxworks") << int(Abi::ArmArchitecture)
|
|
|
|
|
<< int(Abi::VxWorks) << int(Abi::VxWorksFlavor)
|
|
|
|
|
<< int(Abi::ElfFormat) << 32;
|
2016-01-16 17:08:44 +01:00
|
|
|
|
|
|
|
|
QTest::newRow("x86_64-unknown-openbsd") << int(Abi::X86Architecture)
|
|
|
|
|
<< int(Abi::BsdOS) << int(Abi::OpenBsdFlavor)
|
|
|
|
|
<< int(Abi::ElfFormat) << 64;
|
2016-03-15 15:28:29 +01:00
|
|
|
|
|
|
|
|
QTest::newRow("aarch64-unknown-linux-gnu") << int(Abi::ArmArchitecture)
|
|
|
|
|
<< int(Abi::LinuxOS) << int(Abi::GenericLinuxFlavor)
|
|
|
|
|
<< int(Abi::ElfFormat) << 64;
|
2017-07-25 23:52:09 +03:00
|
|
|
|
|
|
|
|
// Yes, that's the entire triplet
|
|
|
|
|
QTest::newRow("avr") << int(Abi::AvrArchitecture)
|
|
|
|
|
<< int(Abi::BareMetalOS) << int(Abi::GenericBareMetalFlavor)
|
|
|
|
|
<< int(Abi::ElfFormat) << 16;
|
2014-02-04 15:33:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProjectExplorer::ProjectExplorerPlugin::testAbiFromTargetTriplet()
|
|
|
|
|
{
|
|
|
|
|
QFETCH(int, architecture);
|
|
|
|
|
QFETCH(int, os);
|
|
|
|
|
QFETCH(int, osFlavor);
|
|
|
|
|
QFETCH(int, binaryFormat);
|
2014-08-04 16:19:01 +03:00
|
|
|
QFETCH(int, wordWidth);
|
2014-02-04 15:33:54 +01:00
|
|
|
|
|
|
|
|
const Abi expectedAbi = Abi(Abi::Architecture(architecture),
|
|
|
|
|
Abi::OS(os), Abi::OSFlavor(osFlavor),
|
2017-07-26 22:40:53 +03:00
|
|
|
Abi::BinaryFormat(binaryFormat),
|
|
|
|
|
static_cast<unsigned char>(wordWidth));
|
2014-02-04 15:33:54 +01:00
|
|
|
|
2014-08-04 16:19:01 +03:00
|
|
|
QCOMPARE(Abi::abiFromTargetTriplet(QLatin1String(QTest::currentDataTag())), expectedAbi);
|
2014-02-04 15:33:54 +01:00
|
|
|
}
|
2013-02-14 15:51:59 +01:00
|
|
|
|
2011-03-21 18:04:24 +01:00
|
|
|
#endif
|