diff options
author | chriseth <chris@ethereum.org> | 2017-11-14 19:58:04 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-01-19 23:27:44 +0800 |
commit | 6807010dc7864500d89a833e4f6e7f338e58b948 (patch) | |
tree | 90fa3b3d59ae85a752dc611b6a32e24fe91e9efb /libevmasm | |
parent | 33723c457a99213a545006162112b55351da5fe4 (diff) | |
download | dexon-solidity-6807010dc7864500d89a833e4f6e7f338e58b948.tar.gz dexon-solidity-6807010dc7864500d89a833e4f6e7f338e58b948.tar.zst dexon-solidity-6807010dc7864500d89a833e4f6e7f338e58b948.zip |
Prevent libraries from being called.
Diffstat (limited to 'libevmasm')
-rw-r--r-- | libevmasm/Assembly.cpp | 9 | ||||
-rw-r--r-- | libevmasm/AssemblyItem.cpp | 9 | ||||
-rw-r--r-- | libevmasm/AssemblyItem.h | 3 | ||||
-rw-r--r-- | libevmasm/GasMeter.cpp | 1 | ||||
-rw-r--r-- | libevmasm/SemanticInformation.cpp | 1 |
5 files changed, 22 insertions, 1 deletions
diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index 5fab24e1..b9fedf26 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -283,6 +283,11 @@ Json::Value Assembly::assemblyJSON(StringMap const& _sourceCodes) const createJsonValue("PUSHLIB", i.location().start, i.location().end, m_libraries.at(h256(i.data()))) ); break; + case PushDeployTimeAddress: + collection.append( + createJsonValue("PUSHDEPLOYADDRESS", i.location().start, i.location().end) + ); + break; case Tag: collection.append( createJsonValue("tag", i.location().start, i.location().end, string(i.data()))); @@ -590,6 +595,10 @@ LinkerObject const& Assembly::assemble() const ret.linkReferences[ret.bytecode.size()] = m_libraries.at(i.data()); ret.bytecode.resize(ret.bytecode.size() + 20); break; + case PushDeployTimeAddress: + ret.bytecode.push_back(byte(Instruction::PUSH20)); + ret.bytecode.resize(ret.bytecode.size() + 20); + break; case Tag: assertThrow(i.data() != 0, AssemblyException, "Invalid tag position."); assertThrow(i.splitForeignPushTag().first == size_t(-1), AssemblyException, "Foreign tag."); diff --git a/libevmasm/AssemblyItem.cpp b/libevmasm/AssemblyItem.cpp index 64963021..5af618ff 100644 --- a/libevmasm/AssemblyItem.cpp +++ b/libevmasm/AssemblyItem.cpp @@ -68,6 +68,7 @@ unsigned AssemblyItem::bytesRequired(unsigned _addressLength) const case PushSub: return 1 + _addressLength; case PushLibraryAddress: + case PushDeployTimeAddress: return 1 + 20; default: break; @@ -97,6 +98,7 @@ int AssemblyItem::returnValues() const case PushSubSize: case PushProgramSize: case PushLibraryAddress: + case PushDeployTimeAddress: return 1; case Tag: return 0; @@ -119,6 +121,7 @@ bool AssemblyItem::canBeFunctional() const case PushSubSize: case PushProgramSize: case PushLibraryAddress: + case PushDeployTimeAddress: return true; case Tag: return false; @@ -190,6 +193,9 @@ string AssemblyItem::toAssemblyText() const case PushLibraryAddress: text = string("linkerSymbol(\"") + toHex(data()) + string("\")"); break; + case PushDeployTimeAddress: + text = string("deployTimeAddress()"); + break; case UndefinedItem: assertThrow(false, AssemblyException, "Invalid assembly item."); break; @@ -252,6 +258,9 @@ ostream& dev::eth::operator<<(ostream& _out, AssemblyItem const& _item) _out << " PushLibraryAddress " << hash.substr(0, 8) + "..." + hash.substr(hash.length() - 8); break; } + case PushDeployTimeAddress: + _out << " PushDeployTimeAddress"; + break; case UndefinedItem: _out << " ???"; break; diff --git a/libevmasm/AssemblyItem.h b/libevmasm/AssemblyItem.h index d38db927..5319a2b6 100644 --- a/libevmasm/AssemblyItem.h +++ b/libevmasm/AssemblyItem.h @@ -46,7 +46,8 @@ enum AssemblyItemType { PushProgramSize, Tag, PushData, - PushLibraryAddress ///< Push a currently unknown address of another (library) contract. + PushLibraryAddress, ///< Push a currently unknown address of another (library) contract. + PushDeployTimeAddress ///< Push an address to be filled at deploy time. Should not be touched by the optimizer. }; class Assembly; diff --git a/libevmasm/GasMeter.cpp b/libevmasm/GasMeter.cpp index dad952bc..543f1cbc 100644 --- a/libevmasm/GasMeter.cpp +++ b/libevmasm/GasMeter.cpp @@ -52,6 +52,7 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _ case PushSubSize: case PushProgramSize: case PushLibraryAddress: + case PushDeployTimeAddress: gas = runGas(Instruction::PUSH1); break; case Tag: diff --git a/libevmasm/SemanticInformation.cpp b/libevmasm/SemanticInformation.cpp index 4c2290c4..03870f7c 100644 --- a/libevmasm/SemanticInformation.cpp +++ b/libevmasm/SemanticInformation.cpp @@ -35,6 +35,7 @@ bool SemanticInformation::breaksCSEAnalysisBlock(AssemblyItem const& _item) default: case UndefinedItem: case Tag: + case PushDeployTimeAddress: return true; case Push: case PushString: |