From ec81fd165883cf0d033e7822c39c6b6c33f57d77 Mon Sep 17 00:00:00 2001 From: Lukáš Zaoral Date: Sat, 22 Jan 2022 15:30:03 +0100 Subject: Core/Executor: Fix unaligned write of fp80 arguments ... in Executor::callExternalFunction. Fixes the following error reported in Feature/VarArg{Alignment,LongDouble}.c tests: lib/Expr/Expr.cpp:366:5: runtime error: store to misaligned address 0x7ffc011d3528 for type 'long double', which requires 16 byte alignment --- lib/Core/Executor.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/Core/Executor.cpp') diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index c50e4520..85413a42 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -3881,6 +3881,10 @@ void Executor::callExternalFunction(ExecutionState &state, } else { ref arg = toUnique(state, *ai); if (ConstantExpr *ce = dyn_cast(arg)) { + // fp80 must be aligned to 16 according to the System V AMD 64 ABI + if (ce->getWidth() == Expr::Fl80 && wordIndex & 0x01) + wordIndex++; + // XXX kick toMemory functions from here ce->toMemory(&args[wordIndex]); wordIndex += (ce->getWidth()+63)/64; -- cgit 1.4.1