Skip to content

Commit

Permalink
[EraVM] Use full keccak256 hash value for linker symbols
Browse files Browse the repository at this point in the history
EF compiler uses only 18 bytes of the keccak256 hash value
when hashing linker symbols. Probably it's done to limit
size of unlinked contracts by increasing collision probability.
But this doesn't seem to make a big sense, so lets use full hash
values. Anyway, this doesn't affect size of executable bytecode.
  • Loading branch information
PavelKopyl authored and akiramenai committed Nov 1, 2024
1 parent a58b8f5 commit 022a80b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/Target/EraVM/MCTargetDesc/EraVMMCTargetDesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ EraVM::analyzeEncodedOpcode(unsigned EncodedOpcode, EncodedOperandMode &SrcMode,
}

// Returs the string of the following format:
// '__$KECCAK256(SymName.substr(0, 34))$__'
// '__$KECCAK256(SymName)$__'
std::string EraVM::getLinkerSymbolHash(StringRef SymName) {
std::array<uint8_t, 32> Hash = KECCAK::KECCAK_256(SymName);
SmallString<72> HexHash;
toHex(Hash, /*LowerCase*/ true, HexHash);
return (Twine("__$") + HexHash.substr(0, 34) + "$__").str();
return (Twine("__$") + HexHash + "$__").str();
}

// Returns concatenation of the Name with the SubIdx.
Expand Down

0 comments on commit 022a80b

Please sign in to comment.