Teach QMacVersion to deal with 32-bit Mach-O headers

Change-Id: I7946aa35722bc76326e2d6cf0820353c4ba13fad
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit b6de6a96990577f8041ba1520bd0f2766be6027c)
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Tor Arne Vestbø 2020-08-05 10:31:35 +02:00
parent 35ecd0b69d
commit 512c2cf2fb
2 changed files with 3 additions and 5 deletions

View File

@ -178,10 +178,6 @@ T qt_mac_resolveOption(const T &fallback, QWindow *window, const QByteArray &pro
// -------------------------------------------------------------------------
#if QT_POINTER_SIZE == 4
#error "32-bit builds are not supported"
#endif
class QMacVersion
{
public:

View File

@ -406,7 +406,9 @@ QMacVersion::VersionTuple QMacVersion::versionsForImage(const mach_header *machH
);
};
auto commandCursor = uintptr_t(machHeader) + sizeof(mach_header_64);
const bool is64Bit = machHeader->magic == MH_MAGIC_64 || machHeader->magic == MH_CIGAM_64;
auto commandCursor = uintptr_t(machHeader) + (is64Bit ? sizeof(mach_header_64) : sizeof(mach_header));
for (uint32_t i = 0; i < machHeader->ncmds; ++i) {
load_command *loadCommand = reinterpret_cast<load_command *>(commandCursor);
if (loadCommand->cmd == LC_VERSION_MIN_MACOSX) {