Skip to content

Commit

Permalink
Fix subassembly references in parent object
Browse files Browse the repository at this point in the history
  • Loading branch information
rodiazet committed Dec 6, 2024
1 parent b67593a commit 7e6960f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libevmasm/Assembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,16 @@ LinkerObject const& Assembly::assembleEOF() const
}

for (auto i: referencedSubIds)
ret.bytecode += m_subs[i]->assemble().bytecode;
{
size_t const subAssemblyPostionInParentObject = ret.bytecode.size();
auto const& subAssemblyLinkerObject = m_subs[i]->assemble();
// Append subassembly bytecode to the parent assembly result bytecode
ret.bytecode += subAssemblyLinkerObject.bytecode;
// Add subassembly link references to parent linker object.
// Offset accordingly to subassembly position in parent obejct bytecode
for (auto const& [subAssemblyLinkRefPosition, linkRef]: subAssemblyLinkerObject.linkReferences)
ret.linkReferences[subAssemblyPostionInParentObject + subAssemblyLinkRefPosition] = linkRef;
}

// TODO: Fill functionDebugData for EOF. It probably should be handled for new code section in the loop above.
solRequire(m_namedTags.empty(), AssemblyException, "Named tags must be empty in EOF context.");
Expand Down

0 comments on commit 7e6960f

Please sign in to comment.