diff --git a/libevmasm/AssemblyItem.cpp b/libevmasm/AssemblyItem.cpp index 8ff96328cc..bf5e61c876 100644 --- a/libevmasm/AssemblyItem.cpp +++ b/libevmasm/AssemblyItem.cpp @@ -83,7 +83,7 @@ size_t AssemblyItem::bytesRequired(size_t _addressLength) const return 1 + _addressLength; case PushLibraryAddress: case PushDeployTimeAddress: - return 1 + 20; + return 1 + 22; case PushImmutable: return 1 + 32; case AssignImmutable: diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index 036240add1..3ffbb287dd 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -226,7 +226,7 @@ void CompilerUtils::storeInMemoryDynamic(Type const& _type, bool _padToWordBound { combineExternalFunctionType(true); m_context << Instruction::DUP2 << Instruction::MSTORE; - m_context << u256(_padToWordBoundaries ? 32 : 24) << Instruction::ADD; + m_context << u256(_type.calldataEncodedSize(_padToWordBoundaries)) << Instruction::ADD; } else if (_type.isValueType()) { @@ -714,10 +714,10 @@ void CompilerUtils::splitExternalFunctionType(bool _leftAligned) if (_leftAligned) { m_context << Instruction::DUP1; - rightShiftNumberOnStack(64 + 32); + rightShiftNumberOnStack(48 + 32); //
m_context << Instruction::SWAP1; - rightShiftNumberOnStack(64); + rightShiftNumberOnStack(48); } else { @@ -737,7 +737,7 @@ void CompilerUtils::combineExternalFunctionType(bool _leftAligned) leftShiftNumberOnStack(32); m_context << Instruction::OR; if (_leftAligned) - leftShiftNumberOnStack(64); + leftShiftNumberOnStack(48); } void CompilerUtils::pushCombinedFunctionEntryLabel(Declaration const& _function, bool _runtimeOnly) diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 23ec6bf661..c6d08b517f 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -231,9 +231,9 @@ size_t ContractCompiler::deployLibrary(ContractDefinition const& _contract) m_context.appendInlineAssembly( Whiskers(R"( { - // If code starts at 11, an mstore(0) writes to the full PUSH20 plus data + // If code starts at 9, an mstore(0) writes to the full PUSH22 plus data // without the need for a shift. - let codepos := 11 + let codepos := 9 codecopy(codepos, subOffset, subSize) // Check that the first opcode is a PUSH22 if iszero(eq(0x75, byte(0, mload(codepos)))) { @@ -306,7 +306,7 @@ void ContractCompiler::appendConstructor(FunctionDefinition const& _constructor) void ContractCompiler::appendDelegatecallCheck() { // Special constant that will be replaced by the address at deploy time. - // At compilation time, this is just "PUSH20 00...000". + // At compilation time, this is just "PUSH22 00...000". m_context.appendDeployTimeAddress(); m_context << Instruction::ADDRESS << Instruction::EQ; // The result on the stack is diff --git a/libsolidity/formal/SMTEncoder.cpp b/libsolidity/formal/SMTEncoder.cpp index a25a5d373f..35b327ff74 100644 --- a/libsolidity/formal/SMTEncoder.cpp +++ b/libsolidity/formal/SMTEncoder.cpp @@ -779,13 +779,11 @@ void SMTEncoder::visitCryptoFunction(FunctionCall const& _funCall) { auto e = state().cryptoFunction("ecrecover"); auto arg0 = expr(*_funCall.arguments().at(0)); - auto arg1 = expr(*_funCall.arguments().at(1)); - auto arg2 = expr(*_funCall.arguments().at(2)); - auto arg3 = expr(*_funCall.arguments().at(3)); + auto arg1 = expr(*_funCall.arguments().at(1), TypeProvider::bytesStorage()); auto inputSort = dynamic_cast