diff options
Diffstat (limited to 'src/3rdparty/masm/stubs/ExecutableAllocator.h')
-rw-r--r-- | src/3rdparty/masm/stubs/ExecutableAllocator.h | 66 |
1 files changed, 19 insertions, 47 deletions
diff --git a/src/3rdparty/masm/stubs/ExecutableAllocator.h b/src/3rdparty/masm/stubs/ExecutableAllocator.h index 156b24b4e8..876a12fce5 100644 --- a/src/3rdparty/masm/stubs/ExecutableAllocator.h +++ b/src/3rdparty/masm/stubs/ExecutableAllocator.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 -** 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. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** 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-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef MASM_EXECUTABLEALLOCATOR_H #define MASM_EXECUTABLEALLOCATOR_H @@ -50,7 +14,7 @@ #endif #if OS(WINDOWS) -#include <windows.h> +#include <qt_windows.h> #else #include <sys/mman.h> #include <unistd.h> @@ -82,8 +46,14 @@ struct ExecutableMemoryHandle : public RefCounted<ExecutableMemoryHandle> { inline bool isManaged() const { return true; } - void *start() { return m_allocation->start(); } - size_t sizeInBytes() { return m_size; } + void *memoryStart() { return m_allocation->memoryStart(); } + size_t memorySize() { return m_allocation->memorySize(); } + + void *exceptionHandlerStart() { return m_allocation->exceptionHandlerStart(); } + size_t exceptionHandlerSize() { return m_allocation->exceptionHandlerSize(); } + + void *codeStart() { return m_allocation->codeStart(); } + size_t codeSize() { return m_size; } QV4::ExecutableAllocator::ChunkOfPages *chunk() const { return m_allocator->chunkForAllocation(m_allocation); } @@ -103,7 +73,7 @@ struct ExecutableAllocator { return adoptRef(new ExecutableMemoryHandle(realAllocator, size)); } - static void makeWritable(void* addr, size_t size) + static bool makeWritable(void* addr, size_t size) { quintptr pageSize = WTF::pageSize(); quintptr iaddr = reinterpret_cast<quintptr>(addr); @@ -119,7 +89,7 @@ struct ExecutableAllocator { # else bool hr = VirtualProtectFromApp(addr, size, PAGE_READWRITE, &oldProtect); if (!hr) { - Q_UNREACHABLE(); + return false; } # endif # elif OS(INTEGRITY) @@ -128,7 +98,7 @@ struct ExecutableAllocator { int mode = PROT_READ | PROT_WRITE; if (mprotect(addr, size, mode) != 0) { perror("mprotect failed in ExecutableAllocator::makeWritable"); - Q_UNREACHABLE(); + return false; } # endif #else @@ -136,9 +106,10 @@ struct ExecutableAllocator { (void)addr; // suppress unused parameter warning (void)size; // suppress unused parameter warning #endif + return true; } - static void makeExecutable(void* addr, size_t size) + static bool makeExecutable(void* addr, size_t size) { quintptr pageSize = WTF::pageSize(); quintptr iaddr = reinterpret_cast<quintptr>(addr); @@ -155,7 +126,7 @@ struct ExecutableAllocator { # else bool hr = VirtualProtectFromApp(addr, size, PAGE_EXECUTE_READ, &oldProtect); if (!hr) { - Q_UNREACHABLE(); + return false; } # endif # elif OS(INTEGRITY) @@ -164,7 +135,7 @@ struct ExecutableAllocator { int mode = PROT_READ | PROT_EXEC; if (mprotect(addr, size, mode) != 0) { perror("mprotect failed in ExecutableAllocator::makeExecutable"); - Q_UNREACHABLE(); + return false; } # endif #else @@ -174,6 +145,7 @@ struct ExecutableAllocator { (void)addr; // suppress unused parameter warning (void)size; // suppress unused parameter warning #endif + return true; } QV4::ExecutableAllocator *realAllocator; |