when called, this function resolves all relocations in every symbol.
96 auto& relocs = sym.
relocs();
97 std::for_each(relocs.begin(), relocs.end(), [&](reloc_t& reloc) {
98 if (reloc.offset() > sym.data().size()) {
100 "invalid relocation... writing outside of symbol length... offset: "
102 sym.offset(), sym.data().size());
104 assert(reloc.offset() > sym.data().size());
111 auto allocated_at = reloc_sym.has_value()
112 ? reloc_sym.value()->allocated_at()
113 : m_resolver(reloc.name());
116 spdlog::error(
"failed to resolve reloc from symbol: {} to symbol: {}",
117 sym.
name(), reloc.name());
119 assert(allocated_at);
122 switch (sym.
type()) {
127 *
reinterpret_cast<std::uintptr_t*
>(scn_sym.value()->data().data() +
128 reloc.offset()) = allocated_at;
132 *
reinterpret_cast<std::uintptr_t*
>(sym.
data().data() +
133 reloc.offset()) = allocated_at;
137 auto& transforms = reloc.get_transforms();
139 transforms.begin(), transforms.end(),
140 [&](std::pair<obf::transform::transform_t*, std::uint32_t>& t) {
141 allocated_at = (*t.first)(allocated_at, t.second);
144 *
reinterpret_cast<std::uintptr_t*
>(sym.
data().data() +
145 reloc.offset()) = allocated_at;
std::map< coff::section_header_t *, std::size_t > & scn_hash_tbl()
gets the section hash table section header --> hash of the section header ptr.
Definition: decomp.cpp:297
std::string name() const
gets the name of the symbol.
Definition: symbol.cpp:52
std::vector< recomp::reloc_t > & relocs()
returns a vector of relocations.
Definition: symbol.cpp:96
std::optional< decomp::symbol_t * > sym_from_hash(std::size_t hash)
returns an optional pointer to a symbol from the symbol table given the symbols hash (hash of its nam...
Definition: symbol_table.cpp:54
@ section
Definition: symbol.hpp:47
@ instruction
Definition: symbol.hpp:45
@ function
Definition: symbol.hpp:44