mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10229 from ethereum/linking-in-assembly-mode
Linking in assembly mode
This commit is contained in:
commit
b981a2a74a
@ -8,6 +8,7 @@ Compiler Features:
|
|||||||
* SMTChecker: Support ``selector`` for expressions with value known at compile-time.
|
* SMTChecker: Support ``selector`` for expressions with value known at compile-time.
|
||||||
* Command Line Interface: New option ``--model-checker-timeout`` sets a timeout in milliseconds for each individual query performed by the SMTChecker.
|
* Command Line Interface: New option ``--model-checker-timeout`` sets a timeout in milliseconds for each individual query performed by the SMTChecker.
|
||||||
* Standard JSON: New option ``modelCheckerSettings.timeout`` sets a timeout in milliseconds for each individual query performed by the SMTChecker.
|
* Standard JSON: New option ``modelCheckerSettings.timeout`` sets a timeout in milliseconds for each individual query performed by the SMTChecker.
|
||||||
|
* Assembler: Perform linking in assembly mode when library addresses are provided.
|
||||||
|
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
@ -1180,8 +1180,6 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings)
|
|||||||
return formatFatalError("JSONError", "Yul mode does not support smtlib2responses.");
|
return formatFatalError("JSONError", "Yul mode does not support smtlib2responses.");
|
||||||
if (!_inputsAndSettings.remappings.empty())
|
if (!_inputsAndSettings.remappings.empty())
|
||||||
return formatFatalError("JSONError", "Field \"settings.remappings\" cannot be used for Yul.");
|
return formatFatalError("JSONError", "Field \"settings.remappings\" cannot be used for Yul.");
|
||||||
if (!_inputsAndSettings.libraries.empty())
|
|
||||||
return formatFatalError("JSONError", "Field \"settings.libraries\" cannot be used for Yul.");
|
|
||||||
if (_inputsAndSettings.revertStrings != RevertStrings::Default)
|
if (_inputsAndSettings.revertStrings != RevertStrings::Default)
|
||||||
return formatFatalError("JSONError", "Field \"settings.debug.revertStrings\" cannot be used for Yul.");
|
return formatFatalError("JSONError", "Field \"settings.debug.revertStrings\" cannot be used for Yul.");
|
||||||
|
|
||||||
@ -1234,6 +1232,11 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings)
|
|||||||
MachineAssemblyObject runtimeObject;
|
MachineAssemblyObject runtimeObject;
|
||||||
tie(object, runtimeObject) = stack.assembleAndGuessRuntime();
|
tie(object, runtimeObject) = stack.assembleAndGuessRuntime();
|
||||||
|
|
||||||
|
if (object.bytecode)
|
||||||
|
object.bytecode->link(_inputsAndSettings.libraries);
|
||||||
|
if (runtimeObject.bytecode)
|
||||||
|
runtimeObject.bytecode->link(_inputsAndSettings.libraries);
|
||||||
|
|
||||||
for (string const& objectKind: vector<string>{"bytecode", "deployedBytecode"})
|
for (string const& objectKind: vector<string>{"bytecode", "deployedBytecode"})
|
||||||
if (isArtifactRequested(
|
if (isArtifactRequested(
|
||||||
_inputsAndSettings.outputSelection,
|
_inputsAndSettings.outputSelection,
|
||||||
|
@ -1916,6 +1916,7 @@ bool CommandLineInterface::assemble(
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
object = stack.assemble(_targetMachine);
|
object = stack.assemble(_targetMachine);
|
||||||
|
object.bytecode->link(m_libraries);
|
||||||
}
|
}
|
||||||
catch (Exception const& _exception)
|
catch (Exception const& _exception)
|
||||||
{
|
{
|
||||||
|
@ -1 +1 @@
|
|||||||
{"errors":[{"component":"general","formattedMessage":"Field \"settings.libraries\" cannot be used for Yul.","message":"Field \"settings.libraries\" cannot be used for Yul.","severity":"error","type":"JSONError"}]}
|
{"contracts":{"A":{"a":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"errors":[{"component":"general","formattedMessage":"Yul is still experimental. Please use the output with care.","message":"Yul is still experimental. Please use the output with care.","severity":"warning","type":"Warning"}]}
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"language": "Yul",
|
||||||
|
"sources": {
|
||||||
|
"A": {
|
||||||
|
"content": "object \"a\" { code { let addr := linkersymbol(\"contract/test\\\".sol:L\") } }"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"libraries": {
|
||||||
|
"contract/test\".sol": {
|
||||||
|
"L": "0x1234567890123456789012345678901234567890"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputSelection": {
|
||||||
|
"*": {
|
||||||
|
"*": ["evm.bytecode.object", "evm.bytecode.linkReferences"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
{"contracts":{"A":{"a":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"errors":[{"component":"general","formattedMessage":"Yul is still experimental. Please use the output with care.","message":"Yul is still experimental. Please use the output with care.","severity":"warning","type":"Warning"}]}
|
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"language": "Yul",
|
||||||
|
"sources": {
|
||||||
|
"A": {
|
||||||
|
"content": "object \"a\" { code { let addr1 := linkersymbol(\"contract/test.sol:L1\") let addr2 := linkersymbol(\"contract/test.sol:L2\") } }"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"libraries": {
|
||||||
|
"contract/test.sol": {
|
||||||
|
"L1": "0x1234567890123456789012345678901234567890"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputSelection": {
|
||||||
|
"*": {
|
||||||
|
"*": ["evm.bytecode.object", "evm.bytecode.linkReferences"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
{"contracts":{"A":{"a":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{"contract/test.sol":{"L2":[{"length":20,"start":22}]}},"object":"<BYTECODE REMOVED>__$fb58009a6b1ecea3b9d99bedd645df4ec3$__<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"errors":[{"component":"general","formattedMessage":"Yul is still experimental. Please use the output with care.","message":"Yul is still experimental. Please use the output with care.","severity":"warning","type":"Warning"}]}
|
@ -10,7 +10,7 @@ object "a" {
|
|||||||
|
|
||||||
|
|
||||||
Binary representation:
|
Binary representation:
|
||||||
73__$f919ba91ac99f96129544b80b9516b27a8$__50
|
73123456789012345678901234567890123456789050
|
||||||
|
|
||||||
Text representation:
|
Text representation:
|
||||||
linkerSymbol("f919ba91ac99f96129544b80b9516b27a80e376b9dc693819d0b18b7e0395612")
|
linkerSymbol("f919ba91ac99f96129544b80b9516b27a80e376b9dc693819d0b18b7e0395612")
|
||||||
|
@ -11,7 +11,7 @@ object "a" {
|
|||||||
|
|
||||||
|
|
||||||
Binary representation:
|
Binary representation:
|
||||||
<BYTECODE REMOVED>__$05b0326038374a21e0895480a58bda0768$__<BYTECODE REMOVED>__$fb58009a6b1ecea3b9d99bedd645df4ec3$__5050
|
73123456789012345678901234567890123456789073__$fb58009a6b1ecea3b9d99bedd645df4ec3$__5050
|
||||||
|
|
||||||
Text representation:
|
Text representation:
|
||||||
linkerSymbol("05b0326038374a21e0895480a58bda0768cdcc04c8d18f154362d1ca5223d245")
|
linkerSymbol("05b0326038374a21e0895480a58bda0768cdcc04c8d18f154362d1ca5223d245")
|
||||||
|
@ -97,6 +97,7 @@ bytes SolidityExecutionFramework::multiSourceCompileContract(
|
|||||||
{
|
{
|
||||||
asmStack.optimize();
|
asmStack.optimize();
|
||||||
obj = std::move(*asmStack.assemble(yul::AssemblyStack::Machine::EVM).bytecode);
|
obj = std::move(*asmStack.assemble(yul::AssemblyStack::Machine::EVM).bytecode);
|
||||||
|
obj.link(_libraryAddresses);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
|
Loading…
Reference in New Issue
Block a user