aboutsummaryrefslogtreecommitdiffstats
path: root/src/3rdparty/masm/assembler/LinkBuffer.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-01-11 11:33:26 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-01-12 10:09:53 +0100
commit131e2c81d40e3d324c62e113749a08e7993d008f (patch)
treeb8bb24c8a189cba4ef4a46d5eb5c810b7905f51c /src/3rdparty/masm/assembler/LinkBuffer.h
parent8dbe5b2be4e65e96013651f1ffee1cc26dd1ead1 (diff)
masm: Add error handling for failed mprotect()
If we cannot mprotect() we have to abort the JIT compilation. Delete RepatchBuffer.h as it is unfixable in that regard. Luckily we don't use it. Task-number: QTBUG-89659 Pick-to: 5.15 Change-Id: Ic5ddbdf51b471db4ddeaa75aab48b24c1f7ced56 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'src/3rdparty/masm/assembler/LinkBuffer.h')
-rw-r--r--src/3rdparty/masm/assembler/LinkBuffer.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/3rdparty/masm/assembler/LinkBuffer.h b/src/3rdparty/masm/assembler/LinkBuffer.h
index 3fe5d56c47..a556ef379b 100644
--- a/src/3rdparty/masm/assembler/LinkBuffer.h
+++ b/src/3rdparty/masm/assembler/LinkBuffer.h
@@ -228,7 +228,7 @@ public:
return m_size;
}
- inline void makeExecutable();
+ inline bool makeExecutable();
private:
template <typename T> T applyOffset(T src)
@@ -353,10 +353,10 @@ void LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::performFinaliza
}
template <typename MacroAssembler, template <typename T> class ExecutableOffsetCalculator>
-inline void LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::makeExecutable()
+inline bool LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::makeExecutable()
{
- ExecutableAllocator::makeExecutable(m_executableMemory->memoryStart(),
- m_executableMemory->memorySize());
+ return ExecutableAllocator::makeExecutable(m_executableMemory->memoryStart(),
+ m_executableMemory->memorySize());
}
template <typename MacroAssembler>
@@ -392,7 +392,7 @@ public:
}
virtual void performFinalization() override final;
- inline void makeExecutable();
+ inline bool makeExecutable();
inline void linkCode(void* ownerUID, JITCompilationEffort);
@@ -428,9 +428,9 @@ void BranchCompactingLinkBuffer<MacroAssembler>::performFinalization()
}
template <typename MacroAssembler>
-inline void BranchCompactingLinkBuffer<MacroAssembler>::makeExecutable()
+inline bool BranchCompactingLinkBuffer<MacroAssembler>::makeExecutable()
{
- ExecutableAllocator::makeExecutable(code(), m_initialSize);
+ return ExecutableAllocator::makeExecutable(code(), m_initialSize);
}
template <typename MacroAssembler>
@@ -443,9 +443,12 @@ inline void BranchCompactingLinkBuffer<MacroAssembler>::linkCode(void* ownerUID,
m_executableMemory = m_globalData->executableAllocator.allocate(*m_globalData, m_initialSize, ownerUID, effort);
if (!m_executableMemory)
return;
+ if (Q_UNLIKELY(!ExecutableAllocator::makeWritable(m_executableMemory->memoryStart(), m_executableMemory->memorySize()))) {
+ m_executableMemory = {};
+ return;
+ }
m_code = (uint8_t*)m_executableMemory->codeStart();
ASSERT(m_code);
- ExecutableAllocator::makeWritable(m_executableMemory->memoryStart(), m_executableMemory->memorySize());
uint8_t* inData = (uint8_t*)m_assembler->unlinkedCode();
uint8_t* outData = reinterpret_cast<uint8_t*>(m_code);
int readPtr = 0;