Theodosius v3.0
Jit linker, symbol mapper, and obfuscator
|
symbol_t is an abstraction upon the coff symbol. this allows for easier manipulation of the symbol. symbols can be different things, sections, functions, and even instructions (when functions are broken down). More...
#include "symbol.hpp"
Public Member Functions | |
symbol_t (coff::image_t *img, std::string name, std::uintptr_t offset, std::vector< std::uint8_t > data, coff::section_header_t *scn={}, coff::symbol_t *sym={}, std::vector< recomp::reloc_t > relocs={}, sym_type_t dcmp_type={}) | |
the explicit constructor of this symbol. More... | |
std::string | name () const |
gets the name of the symbol. More... | |
std::uintptr_t | offset () const |
gets the offset into the section where the symbol is located. More... | |
std::uintptr_t | allocated_at () const |
returns the address where the symbol is allocated. More... | |
std::uint32_t | size () const |
returns the size of the symbol. More... | |
coff::section_header_t * | scn () const |
gets the section header of the section in which the symbol is contained. More... | |
coff::image_t * | img () const |
gets the imagine in which the symbol is located inside of. More... | |
std::vector< std::uint8_t > & | data () |
returns a vector by reference of bytes containing the data of the symbol. More... | |
coff::symbol_t * | sym () const |
returns a pointer to the coff symbol object. More... | |
sym_type_t | type () const |
returns the type of the symbol. More... | |
std::vector< recomp::reloc_t > & | relocs () |
returns a vector of relocations. More... | |
void | allocated_at (std::uintptr_t allocated_at) |
set the address where the symbol is allocated at. More... | |
std::size_t | hash () |
gets the hash of the symbol name. More... | |
Static Public Member Functions | |
static std::size_t | hash (const std::string &sym) |
generate a hash given the name of the symbol. More... | |
static std::string | name (const coff::image_t *img, coff::symbol_t *sym) |
get the name of a symbol. this function will create a symbol name if the symbol is opaquely named. More... | |
symbol_t is an abstraction upon the coff symbol. this allows for easier manipulation of the symbol. symbols can be different things, sections, functions, and even instructions (when functions are broken down).
this class is used throughout theodosius and is a keystone of the project. ensure you understand how this class works and what it contains.
Definition at line 59 of file symbol.hpp.
|
explicit |
the explicit constructor of this symbol.
img | the image in which the symbol is located in. |
name | the name of the symbol. |
offset | offset into the section where this symbol is located. |
data | the data of the symbol. there can be no data. |
scn | the section header describing the section which contains the symbol. |
sym | the coff symbol itself. |
relocs | a vector of relocations this symbol has (if any). |
dcmp_type | the type of symbol |
Definition at line 34 of file symbol.cpp.
std::uintptr_t theo::decomp::symbol_t::allocated_at | ( | ) | const |
returns the address where the symbol is allocated.
Definition at line 60 of file symbol.cpp.
Referenced by allocated_at(), and theo::recomp::recomp_t::copy_syms().
void theo::decomp::symbol_t::allocated_at | ( | std::uintptr_t | allocated_at | ) |
set the address where the symbol is allocated at.
allocated_at | where the symbol is allocated at. |
Definition at line 84 of file symbol.cpp.
References allocated_at().
std::vector< std::uint8_t > & theo::decomp::symbol_t::data | ( | ) |
returns a vector by reference of bytes containing the data of the symbol.
Definition at line 76 of file symbol.cpp.
Referenced by theo::recomp::recomp_t::copy_syms(), theo::recomp::recomp_t::resolve(), theo::obf::jcc_rewrite_pass_t::run(), theo::obf::next_inst_pass_t::run(), and theo::obf::reloc_transform_pass_t::run().
std::size_t theo::decomp::symbol_t::hash | ( | ) |
gets the hash of the symbol name.
Definition at line 88 of file symbol.cpp.
References hash().
Referenced by theo::decomp::routine_t::decompose(), hash(), theo::recomp::symbol_table_t::put_symbol(), theo::recomp::recomp_t::resolve(), theo::theo_t::resolve(), theo::obf::hello_world_pass_t::run(), and theo::obf::jcc_rewrite_pass_t::run().
|
static |
generate a hash given the name of the symbol.
sym | the symbol name to create a hash from. |
Definition at line 100 of file symbol.cpp.
References sym().
coff::image_t * theo::decomp::symbol_t::img | ( | ) | const |
gets the imagine in which the symbol is located inside of.
Definition at line 68 of file symbol.cpp.
Referenced by name(), and theo::obf::jcc_rewrite_pass_t::run().
std::string theo::decomp::symbol_t::name | ( | ) | const |
gets the name of the symbol.
Definition at line 52 of file symbol.cpp.
Referenced by theo::decomp::routine_t::decompose(), theo::recomp::recomp_t::resolve(), theo::obf::hello_world_pass_t::run(), and theo::obf::reloc_transform_pass_t::run().
|
static |
get the name of a symbol. this function will create a symbol name if the symbol is opaquely named.
for example in c++ if you define something like this:
some_struct_t val = { value_one, value_two };
"val" will be stored in the .data section of the coff file. however the symbol name will be opaque (the name of the symbol will be ".data"). this causes issues with theo since each symbol needs its own unqiue name to generate a unique symbol name hash. for symbols like this, theo will create a name for it with the following format:
.data::section_index!coff_file_timestamp+offset_into_section
img | the coff file containing the symbol. |
sym | the coff symbol itself. |
Definition at line 104 of file symbol.cpp.
std::uintptr_t theo::decomp::symbol_t::offset | ( | ) | const |
gets the offset into the section where the symbol is located.
Definition at line 56 of file symbol.cpp.
Referenced by theo::obf::jcc_rewrite_pass_t::run().
std::vector< recomp::reloc_t > & theo::decomp::symbol_t::relocs | ( | ) |
returns a vector of relocations.
Definition at line 96 of file symbol.cpp.
Referenced by theo::recomp::recomp_t::resolve(), and theo::obf::jcc_rewrite_pass_t::run().
coff::section_header_t * theo::decomp::symbol_t::scn | ( | ) | const |
gets the section header of the section in which the symbol is contained.
Definition at line 64 of file symbol.cpp.
Referenced by name(), and theo::recomp::recomp_t::resolve().
std::uint32_t theo::decomp::symbol_t::size | ( | ) | const |
returns the size of the symbol.
Definition at line 72 of file symbol.cpp.
coff::symbol_t * theo::decomp::symbol_t::sym | ( | ) | const |
returns a pointer to the coff symbol object.
Definition at line 92 of file symbol.cpp.
Referenced by hash(), name(), and theo::obf::jcc_rewrite_pass_t::run().
sym_type_t theo::decomp::symbol_t::type | ( | ) | const |
returns the type of the symbol.
Definition at line 80 of file symbol.cpp.
Referenced by theo::recomp::recomp_t::allocate(), and theo::recomp::recomp_t::resolve().