CommandLineInterface: Report an error if library appears multiple times in the --libraries option

This commit is contained in:
Kamil Śliwak 2020-11-13 22:31:04 +01:00
parent c3b862c073
commit 1a4d38c0ac
10 changed files with 47 additions and 1 deletions

View File

@ -19,6 +19,7 @@ Compiler Features:
Bugfixes:
* Command Line Interface: Reject duplicate libraries in ``--libraries`` option instead of arbitrarily choosing one.
* SMTChecker: Fix lack of reporting potential violations when using only the CHC engine.
* SMTChecker: Fix internal error on conversion from string literal to byte.
* SMTChecker: Fix internal error when using tuples of rational literals inside the conditional operator.

View File

@ -664,9 +664,16 @@ bool CommandLineInterface::parseLibraryOption(string const& _input)
serr() << "Colon separator missing in library address specifier \"" << lib << "\"" << endl;
return false;
}
string libName(lib.begin(), lib.begin() + static_cast<ptrdiff_t>(colon));
string addrString(lib.begin() + static_cast<ptrdiff_t>(colon) + 1, lib.end());
boost::trim(libName);
if (m_libraries.count(libName))
{
serr() << "Address specified more than once for library \"" << libName << "\"." << endl;
return false;
}
string addrString(lib.begin() + static_cast<ptrdiff_t>(colon) + 1, lib.end());
boost::trim(addrString);
if (addrString.substr(0, 2) == "0x")
addrString = addrString.substr(2);

View File

@ -0,0 +1 @@
--strict-assembly --libraries library.sol:L:0x1234567890123456789012345678901234567890,library.sol:L:0x0987654321098765432109876543210987654321

View File

@ -0,0 +1 @@
Address specified more than once for library "library.sol:L".

View File

@ -0,0 +1,5 @@
object "a" {
code {
let addr := linkersymbol("library.sol:L")
}
}

View File

@ -0,0 +1 @@
--strict-assembly --libraries library1.sol:L:0x1111111111111111111111111111111111111111,library2.sol:L:0x2222222222222222222222222222222222222222

View File

@ -0,0 +1 @@
Warning: Yul is still experimental. Please use the output with care.

View File

@ -0,0 +1,6 @@
object "a" {
code {
let addr1 := linkersymbol("library1.sol:L")
let addr2 := linkersymbol("library2.sol:L")
}
}

View File

@ -0,0 +1,22 @@
======= linking_strict_assembly_same_library_name_different_files/input.yul (EVM) =======
Pretty printed source:
object "a" {
code {
let addr1 := linkersymbol("library1.sol:L")
let addr2 := linkersymbol("library2.sol:L")
}
}
Binary representation:
7311111111111111111111111111111111111111117322222222222222222222222222222222222222225050
Text representation:
linkerSymbol("f3ffc10c396a7cc41ae954b050792839d20947bf73497d30c49a9fda1ea477ec")
/* "linking_strict_assembly_same_library_name_different_files/input.yul":32:75 */
linkerSymbol("c3523432985587641d17c68161d2f700c57aaf4ed21cda4f25d76193c831f97f")
/* "linking_strict_assembly_same_library_name_different_files/input.yul":22:133 */
pop
pop