aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-09-02 07:16:03 +0800
committerchriseth <c@ethdev.com>2016-09-02 07:17:02 +0800
commita787e705948255e1ff2e1b70c6d8c5160e892fa3 (patch)
treed1877ab948581e27d72d8653d073be4c9f6bb6e2
parentb5d941d3d9f32193c7f9094dee20511585508f6a (diff)
downloaddexon-solidity-a787e705948255e1ff2e1b70c6d8c5160e892fa3.tar
dexon-solidity-a787e705948255e1ff2e1b70c6d8c5160e892fa3.tar.gz
dexon-solidity-a787e705948255e1ff2e1b70c6d8c5160e892fa3.tar.bz2
dexon-solidity-a787e705948255e1ff2e1b70c6d8c5160e892fa3.tar.lz
dexon-solidity-a787e705948255e1ff2e1b70c6d8c5160e892fa3.tar.xz
dexon-solidity-a787e705948255e1ff2e1b70c6d8c5160e892fa3.tar.zst
dexon-solidity-a787e705948255e1ff2e1b70c6d8c5160e892fa3.zip
Fix linking for libraries with underscores.
-rw-r--r--Changelog.md1
-rw-r--r--solc/CommandLineInterface.cpp35
2 files changed, 19 insertions, 17 deletions
diff --git a/Changelog.md b/Changelog.md
index 25890890..2baed6b4 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -38,6 +38,7 @@ Bugfixes:
* JSON AST: nodes were added at wrong parent
* Why3 translator: crash fix for exponentiation
+ * Commandline Interface: linking libraries with underscores in their name.
* Type Checker: Fallback function cannot return data anymore.
Lots of changes to the documentation mainly by voluntary external contributors.
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index fbef56f0..48e7578f 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -778,37 +778,38 @@ void CommandLineInterface::actOnInput()
bool CommandLineInterface::link()
{
+ map<string, h160> librariesReplacements;
+ for (auto const& library: m_libraries)
+ {
+ string const& name = library.first;
+ string replacement = "__";
+ for (size_t i = 0; i < 36; ++i)
+ replacement.push_back(i < name.size() ? name[i] : '_');
+ replacement += "__";
+ librariesReplacements[replacement] = library.second;
+ }
for (auto& src: m_sourceCodes)
{
auto end = src.second.end();
for (auto it = src.second.begin(); it != end;)
{
while (it != end && *it != '_') ++it;
- auto insertStart = it;
- while (it != end && *it == '_') ++it;
- auto nameStart = it;
- while (it != end && *it != '_') ++it;
- auto nameEnd = it;
- while (it != end && *it == '_') ++it;
- auto insertEnd = it;
-
- if (insertStart == end)
- break;
-
- if (insertEnd - insertStart != 40)
+ if (it == end) break;
+ if (end - it < 40)
{
- cerr << "Error in binary object file " << src.first << " at position " << (insertStart - src.second.begin()) << endl;
+ cerr << "Error in binary object file " << src.first << " at position " << (end - src.second.begin()) << endl;
return false;
}
- string name(nameStart, nameEnd);
- if (m_libraries.count(name))
+ string name(it, it + 40);
+ if (librariesReplacements.count(name))
{
- string hexStr(toHex(m_libraries.at(name).asBytes()));
- copy(hexStr.begin(), hexStr.end(), insertStart);
+ string hexStr(toHex(librariesReplacements.at(name).asBytes()));
+ copy(hexStr.begin(), hexStr.end(), it);
}
else
cerr << "Reference \"" << name << "\" in file \"" << src.first << "\" still unresolved." << endl;
+ it += 40;
}
}
return true;