aboutsummaryrefslogtreecommitdiffstats
path: root/libevmasm/LinkerObject.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-10-12 21:53:45 +0800
committerGitHub <noreply@github.com>2018-10-12 21:53:45 +0800
commit94526b2d92e469fc8679be1f5a2b56c4c1ed25be (patch)
treea85bb55dbb29de2d3e271160af3e5afcc7d9c228 /libevmasm/LinkerObject.cpp
parent1d312c8e4073e2e7ce9a23a721013942e1e5c727 (diff)
parent914668c622b60eab4129d0a6b3776c20d8e614bd (diff)
downloaddexon-solidity-94526b2d92e469fc8679be1f5a2b56c4c1ed25be.tar
dexon-solidity-94526b2d92e469fc8679be1f5a2b56c4c1ed25be.tar.gz
dexon-solidity-94526b2d92e469fc8679be1f5a2b56c4c1ed25be.tar.bz2
dexon-solidity-94526b2d92e469fc8679be1f5a2b56c4c1ed25be.tar.lz
dexon-solidity-94526b2d92e469fc8679be1f5a2b56c4c1ed25be.tar.xz
dexon-solidity-94526b2d92e469fc8679be1f5a2b56c4c1ed25be.tar.zst
dexon-solidity-94526b2d92e469fc8679be1f5a2b56c4c1ed25be.zip
Merge pull request #5145 from ethereum/hashLinker
Hash linker
Diffstat (limited to 'libevmasm/LinkerObject.cpp')
-rw-r--r--libevmasm/LinkerObject.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/libevmasm/LinkerObject.cpp b/libevmasm/LinkerObject.cpp
index 1d5efecb..a11f2378 100644
--- a/libevmasm/LinkerObject.cpp
+++ b/libevmasm/LinkerObject.cpp
@@ -21,6 +21,7 @@
#include <libevmasm/LinkerObject.h>
#include <libdevcore/CommonData.h>
+#include <libdevcore/SHA3.h>
using namespace dev;
using namespace dev::eth;
@@ -50,14 +51,19 @@ string LinkerObject::toHex() const
for (auto const& ref: linkReferences)
{
size_t pos = ref.first * 2;
- string const& name = ref.second;
+ string hash = libraryPlaceholder(ref.second);
hex[pos] = hex[pos + 1] = hex[pos + 38] = hex[pos + 39] = '_';
for (size_t i = 0; i < 36; ++i)
- hex[pos + 2 + i] = i < name.size() ? name[i] : '_';
+ hex[pos + 2 + i] = hash.at(i);
}
return hex;
}
+string LinkerObject::libraryPlaceholder(string const& _libraryName)
+{
+ return "$" + keccak256(_libraryName).hex().substr(0, 34) + "$";
+}
+
h160 const*
LinkerObject::matchLibrary(
string const& _linkRefName,