retdec
symbol.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_FILEFORMAT_TYPES_SYMBOL_TABLE_SYMBOL_H
8 #define RETDEC_FILEFORMAT_TYPES_SYMBOL_TABLE_SYMBOL_H
9 
10 #include <string>
11 
12 namespace retdec {
13 namespace fileformat {
14 
18 class Symbol
19 {
20  public:
21  enum class Type
22  {
24  PRIVATE,
25  PUBLIC,
26  WEAK,
27  EXTERN,
28  ABSOLUTE_SYM,
29  COMMON
30  };
31 
32  enum class UsageType
33  {
34  UNKNOWN,
35  FUNCTION,
36  OBJECT,
37  FILE
38  };
39  private:
40  std::string name;
41  std::string originalName;
44  unsigned long long index = 0;
45  unsigned long long address = 0;
46  unsigned long long size = 0;
47  unsigned long long linkToSection = 0;
48  bool addressIsValid = false;
49  bool sizeIsValid = false;
50  bool linkIsValid = false;
51  bool thumbSymbol = false;
52  public:
55  bool isUndefined() const;
56  bool isPrivate() const;
57  bool isPublic() const;
58  bool isWeak() const;
59  bool isExtern() const;
60  bool isAbsolute() const;
61  bool isCommon() const;
63 
66  bool isUnknown() const;
67  bool isFunction() const;
68  bool isObject() const;
69  bool isFile() const;
71 
74  bool isThumbSymbol() const;
75  bool isEven() const;
76  bool isOdd() const;
77  bool hasEmptyName() const;
79 
82  const std::string &getName() const;
83  std::string getNormalizedName() const;
84  std::string getOriginalName() const;
85  Symbol::Type getType() const;
87  unsigned long long getIndex() const;
88  bool getAddress(unsigned long long &virtualAddress) const;
89  bool getRealAddress(unsigned long long &virtualAddress) const;
90  bool getSize(unsigned long long &symbolSize) const;
91  bool getLinkToSection(unsigned long long &sectionIndex) const;
93 
96  void setName(const std::string & symbolName);
97  void setOriginalName(const std::string & symbolOriginalName);
98  void setType(Symbol::Type symbolType);
99  void setUsageType(Symbol::UsageType symbolUsageType);
100  void setIndex(unsigned long long symbolIndex);
101  void setAddress(unsigned long long symbolAddress);
102  void setSize(unsigned long long symbolSize);
103  void setLinkToSection(unsigned long long sectionIndex);
104  void setIsThumbSymbol(bool b);
106 
109  void invalidateAddress();
110  void invalidateSize();
113 };
114 
115 } // namespace fileformat
116 } // namespace retdec
117 
118 #endif
Definition: symbol.h:19
std::string getNormalizedName() const
Definition: symbol.cpp:150
std::string name
symbol name (normalized name)
Definition: symbol.h:40
bool isFunction() const
Definition: symbol.cpp:82
std::string getOriginalName() const
Definition: symbol.cpp:159
bool isThumbSymbol() const
Definition: symbol.cpp:106
void setAddress(unsigned long long symbolAddress)
Definition: symbol.cpp:320
std::string originalName
original name of symbol
Definition: symbol.h:41
bool isCommon() const
Definition: symbol.cpp:66
void invalidateSize()
Definition: symbol.cpp:374
void invalidateAddress()
Definition: symbol.cpp:362
bool isAbsolute() const
Definition: symbol.cpp:58
bool getAddress(unsigned long long &virtualAddress) const
Definition: symbol.cpp:198
unsigned long long linkToSection
link to section
Definition: symbol.h:47
void setUsageType(Symbol::UsageType symbolUsageType)
Definition: symbol.cpp:302
void setLinkToSection(unsigned long long sectionIndex)
Definition: symbol.cpp:340
void setIndex(unsigned long long symbolIndex)
Definition: symbol.cpp:311
Type
Definition: symbol.h:22
@ WEAK
weak, may be replaced with another symbol
@ ABSOLUTE_SYM
not linked to a section
@ EXTERN
expected to be defined in another module
@ PUBLIC
public global symbol
bool hasEmptyName() const
Definition: symbol.cpp:132
bool isWeak() const
Definition: symbol.cpp:42
const std::string & getName() const
Definition: symbol.cpp:141
bool isOdd() const
Definition: symbol.cpp:123
bool isFile() const
Definition: symbol.cpp:98
UsageType usageType
usage of symbol
Definition: symbol.h:43
unsigned long long getIndex() const
Definition: symbol.cpp:186
bool addressIsValid
true if value of virtual address is valid
Definition: symbol.h:48
bool isEven() const
Definition: symbol.cpp:114
bool isExtern() const
Definition: symbol.cpp:50
void setIsThumbSymbol(bool b)
Definition: symbol.cpp:350
bool sizeIsValid
true if size of symbol is valid
Definition: symbol.h:49
void setSize(unsigned long long symbolSize)
Definition: symbol.cpp:330
bool isUnknown() const
Definition: symbol.cpp:74
bool isUndefined() const
Definition: symbol.cpp:18
bool linkIsValid
true if link to section is valid
Definition: symbol.h:50
bool isPublic() const
Definition: symbol.cpp:34
void setName(const std::string &symbolName)
Definition: symbol.cpp:275
bool isPrivate() const
Definition: symbol.cpp:26
Symbol::Type getType() const
Definition: symbol.cpp:168
void invalidateLinkToSection()
Definition: symbol.cpp:386
unsigned long long address
virtual address of symbol
Definition: symbol.h:45
void setOriginalName(const std::string &symbolOriginalName)
Definition: symbol.cpp:284
bool getLinkToSection(unsigned long long &sectionIndex) const
Definition: symbol.cpp:260
bool isObject() const
Definition: symbol.cpp:90
bool getSize(unsigned long long &symbolSize) const
Definition: symbol.cpp:243
unsigned long long size
size of symbol
Definition: symbol.h:46
bool getRealAddress(unsigned long long &virtualAddress) const
Definition: symbol.cpp:215
Symbol::UsageType getUsageType() const
Definition: symbol.cpp:177
Type type
symbol type
Definition: symbol.h:42
unsigned long long index
symbol index
Definition: symbol.h:44
UsageType
Definition: symbol.h:33
void setType(Symbol::Type symbolType)
Definition: symbol.cpp:293
bool thumbSymbol
true if symbol is THUMB symbol
Definition: symbol.h:51
Definition: archive_wrapper.h:19