LIEF: Library to Instrument Executable Formats Version 0.17.0
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
16#ifndef LIEF_COFF_SYMBOL_H
17#define LIEF_COFF_SYMBOL_H
39 using auxiliary_symbols_t = std::vector<std::unique_ptr<AuxiliarySymbol>>;
40 using it_auxiliary_symbols_t = ref_iterator<auxiliary_symbols_t&, AuxiliarySymbol*>;
41 using it_const_auxiliary_symbols_t = const_ref_iterator<const auxiliary_symbols_t&, AuxiliarySymbol*>;
43 struct parsing_context_t {
44 std::function<String*(uint32_t)> find_string;
47 static std::unique_ptr<Symbol>
parse(
48 parsing_context_t& ctx, BinaryStream& stream,
size_t* idx);
56 static constexpr auto SYM_SEC_IDX_DEBUG = -2;
static constexpr auto SYM_SEC_IDX_ABS = -1;
static constexpr auto SYM_SEC_IDX_UNDEF = 0;
68 static constexpr auto SYM_COMPLEX_TYPE_SHIFT = 4;
69 enum class STORAGE_CLASS : int32_t {
89 UNDEFINED_STATIC = 14,
103 enum class BASE_TYPE : uint32_t {
122 enum class COMPLEX_TYPE : uint32_t {
133 uint16_t
type()
const {
144 return (STORAGE_CLASS)storage_class_;
149 return (BASE_TYPE)(type_ & 0x0F);
154 return (COMPLEX_TYPE)((type_ & 0xF0) >> SYM_COMPLEX_TYPE_SHIFT);
183 return storage_class() == STORAGE_CLASS::EXTERNAL;
187 return storage_class() == STORAGE_CLASS::WEAK_EXTERNAL;
191 return section_idx() == SYM_SEC_IDX_ABS;
195 return is_external() && section_idx() == SYM_SEC_IDX_UNDEF &&
200 return storage_class() == STORAGE_CLASS::FUNCTION;
204 return complex_type() == COMPLEX_TYPE::TY_FUNCTION;
208 return storage_class() == STORAGE_CLASS::FILE;
213 return auxiliary_symbols_;
217 return auxiliary_symbols_;
219 const std::string&
name()
const override;
245 storage_class_ = value;
253 AuxiliarySymbol&
add_aux(std::unique_ptr<AuxiliarySymbol> sym);
260 std::ostream&
operator<<(std::ostream& os,
const Symbol& entry)
270 static std::unique_ptr<Symbol> parse_impl(
271 parsing_context_t& ctx, BinaryStream& stream,
size_t* idx);
272 String* coff_name_ =
nullptr;
274 uint8_t storage_class_ = 0;
275 int16_t section_idx_ = 0;
276 auxiliary_symbols_t auxiliary_symbols_;
277 Section* section_ =
nullptr;
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
Class that represents an auxiliary symbol.
Definition AuxiliarySymbol.hpp:36
Definition COFF/Parser.hpp:34
This class represents a COFF section.
Definition COFF/Section.hpp:39
This class represents a string located in the COFF string table.
Definition String.hpp:33
This class represents a COFF symbol.
Definition COFF/Symbol.hpp:35
uint16_t type() const
The symbol type. The first byte represents the base type (see: base_type()) while the upper byte repr...
Definition COFF/Symbol.hpp:137
bool is_absolute() const
Definition COFF/Symbol.hpp:190
const std::string & name() const override
Name of the symbol. If the symbol does not use a short name, it returns the string pointed by the COF...
COMPLEX_TYPE
Definition COFF/Symbol.hpp:122
Symbol & storage_class(uint8_t value)
Definition COFF/Symbol.hpp:244
const Section * section() const
Definition COFF/Symbol.hpp:178
COMPLEX_TYPE complex_type() const
The complex type (if any)
Definition COFF/Symbol.hpp:153
bool is_function_line_info() const
Definition COFF/Symbol.hpp:199
Symbol & section_idx(int16_t idx)
Definition COFF/Symbol.hpp:249
bool is_file_record() const
Definition COFF/Symbol.hpp:207
Section * section()
Section associated with this symbol (if any)
Definition COFF/Symbol.hpp:174
bool is_function() const
Definition COFF/Symbol.hpp:203
BASE_TYPE base_type() const
The simple (base) data type.
Definition COFF/Symbol.hpp:148
bool is_external() const
Definition COFF/Symbol.hpp:182
BASE_TYPE
Definition COFF/Symbol.hpp:103
STORAGE_CLASS
Reference: https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#storage-class.
Definition COFF/Symbol.hpp:71
Symbol & type(uint16_t ty)
Definition COFF/Symbol.hpp:239
const String * coff_name() const
COFF string used to represents the (long) symbol name.
Definition COFF/Symbol.hpp:227
it_auxiliary_symbols_t auxiliary_symbols()
Auxiliary symbols associated with this symbol.
Definition COFF/Symbol.hpp:212
std::string to_string() const
String * coff_name()
Definition COFF/Symbol.hpp:231
static std::unique_ptr< Symbol > parse(parsing_context_t &ctx, BinaryStream &stream, size_t *idx)
int16_t section_idx() const
The signed integer that identifies the section, using a one-based index into the section table....
Definition COFF/Symbol.hpp:169
std::string & name() override
static constexpr bool is_reversed_sec_idx(int16_t idx)
Check if the given section index is a reserved value.
Definition COFF/Symbol.hpp:130
bool is_undefined() const
Definition COFF/Symbol.hpp:194
AuxiliarySymbol & add_aux(std::unique_ptr< AuxiliarySymbol > sym)
Add a new auxiliary record.
bool is_weak_external() const
Definition COFF/Symbol.hpp:186
Symbol & operator=(Symbol &&)
it_const_auxiliary_symbols_t auxiliary_symbols() const
Definition COFF/Symbol.hpp:216
Symbol & operator=(const Symbol &)
std::string demangled_name() const
Demangled representation of the symbol or an empty string if it can't be demangled.
STORAGE_CLASS storage_class() const
Storage class of the symbol which indicates what kind of definition a symbol represents.
Definition COFF/Symbol.hpp:143
friend std::ostream & operator<<(std::ostream &os, const Symbol &entry)
Definition COFF/Symbol.hpp:260
Definition AuxiliarySymbol.hpp:29
const char * to_string(AuxiliarySectionDefinition::COMDAT_SELECTION e)
bool is_bigobj(BinaryStream &stream)
Check if the COFF file wrapped by the given stream is a bigobj
Definition COFF/utils.hpp:51
LIEF namespace.
Definition Abstract/Binary.hpp:39
#define LIEF_API
Definition visibility.h:41