16#ifndef LIEF_ELF_SYMBOL_H
17#define LIEF_ELF_SYMBOL_H
23#include "LIEF/visibility.h"
24#include "LIEF/Abstract/Symbol.hpp"
25#include "LIEF/ELF/enums.hpp"
81 static BINDING binding_from(uint32_t value, ARCH) {
82 return BINDING(value);
85 static TYPE type_from(uint32_t value, ARCH) {
89 static uint8_t to_value(BINDING binding) {
90 return static_cast<uint8_t
>(binding);
93 static uint8_t to_value(TYPE type) {
94 return static_cast<uint8_t
>(type);
98 ~Symbol()
override =
default;
100 Symbol& operator=(Symbol other);
101 Symbol(
const Symbol& other);
102 void swap(Symbol& other);
137 const Section* section()
const {
158 uint64_t
size()
const override {
169 return symbol_version_ !=
nullptr;
175 return symbol_version_;
179 return symbol_version_;
182 bool is_local()
const {
183 return binding() == BINDING::LOCAL;
186 bool is_global()
const {
187 return binding() == BINDING::GLOBAL;
190 bool is_weak()
const {
191 return binding() == BINDING::WEAK;
197 void type(
TYPE type) {
201 void binding(BINDING binding) {
205 void other(uint8_t other) {
209 void visibility(VISIBILITY visibility) {
210 other_ =
static_cast<uint8_t
>(visibility);
213 void information(uint8_t info);
215 void shndx(uint16_t idx) {
219 void value(uint64_t value)
override {
223 void size(uint64_t size)
override {
241 return this->binding() == BINDING::GLOBAL;
246 return this->type() == TYPE::FUNC;
251 return this->type() == TYPE::OBJECT;
254 void accept(
Visitor& visitor)
const override;
256 LIEF_API
friend std::ostream& operator<<(std::ostream& os,
const Symbol& entry);
262 TYPE type_ = TYPE::NOTYPE;
263 BINDING binding_ = BINDING::LOCAL;
268 ARCH arch_ = ARCH::NONE;
Class which represents an ELF binary.
Definition ELF/Binary.hpp:59
Class which parses and transforms an ELF file into a ELF::Binary object.
Definition ELF/Parser.hpp:45
Class wich represents an ELF Section.
Definition ELF/Section.hpp:46
Class which represents an entry defined in the DT_VERSYM dynamic entry.
Definition SymbolVersion.hpp:32
Class which represents an ELF symbol.
Definition ELF/Symbol.hpp:35
void set_imported(bool flag=true)
Set whether or not the symbol is imported.
uint8_t other() const
Alias for visibility()
Definition ELF/Symbol.hpp:118
std::string demangled_name() const
Symbol's unmangled name. If not available, it returns an empty string.
bool is_exported() const
Check if the current symbol is exported.
uint8_t information() const
This member specifies the symbol's type and binding attributes.
TYPE type() const
The symbol's type provides a general classification for the associated entity.
Definition ELF/Symbol.hpp:105
uint64_t size() const override
Symbol size.
Definition ELF/Symbol.hpp:158
BINDING
Definition ELF/Symbol.hpp:40
bool is_variable() const
True if the symbol represent a variable.
Definition ELF/Symbol.hpp:250
BINDING binding() const
The symbol's binding determines the linkage visibility and behavior.
Definition ELF/Symbol.hpp:110
SECTION_INDEX
Special section indices.
Definition ELF/Symbol.hpp:70
uint16_t shndx() const
Definition ELF/Symbol.hpp:163
uint16_t section_idx() const
ELF::Section index associated with the symbol.
Definition ELF/Symbol.hpp:123
TYPE
Type of the symbol. This enum matches the STT_xxx values of the ELF specs.
Definition ELF/Symbol.hpp:49
void set_exported(bool flag=true)
Set whether or not the symbol is exported.
bool is_imported() const
Check if the current symbol is imported.
Section * section()
Section associated with the symbol or a nullptr if it does not exist.
Definition ELF/Symbol.hpp:133
bool has_version() const
Check if this symbols has a symbol version .
Definition ELF/Symbol.hpp:168
VISIBILITY visibility() const
Symbol visibility.
Definition ELF/Symbol.hpp:128
SymbolVersion * symbol_version()
Return the SymbolVersion associated with this symbol. If there is no symbol version,...
Definition ELF/Symbol.hpp:174
uint64_t value() const override
This member has slightly different interpretations:
Definition ELF/Symbol.hpp:149
bool is_static() const
True if the symbol is a static one.
Definition ELF/Symbol.hpp:240
bool is_function() const
True if the symbol represent a function.
Definition ELF/Symbol.hpp:245
VISIBILITY
Visibility of the symbol. This enum matches the STV_xxx values of the official ELF specs.
Definition ELF/Symbol.hpp:62
This class represents a symbol in an executable format.
Definition Abstract/Symbol.hpp:28
Definition Visitor.hpp:219
ARCH
Machine architectures See current registered ELF machine architectures at: http://www....
Definition ELF/enums.hpp:30
LIEF namespace.
Definition Abstract/Binary.hpp:32