LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
Abstract/Symbol.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_ABSTRACT_SYMBOLS_H
16#define LIEF_ABSTRACT_SYMBOLS_H
17
18#include <string_view>
19#include <cstdint>
20#include <string>
21
22#include "LIEF/Object.hpp"
24#include "LIEF/visibility.h"
25
26namespace LIEF {
27
29class LIEF_API Symbol : public Object {
30 public:
31 Symbol() = default;
32 Symbol(std::string name) :
33 name_(std::move(name)) {}
34
35 Symbol(std::string name, uint64_t value) :
36 name_(std::move(name)),
37 value_(value) {}
38
39 Symbol(std::string name, uint64_t value, uint64_t size) :
40 name_(std::move(name)),
41 value_(value),
42 size_(size) {}
43
44 Symbol(const Symbol&) = default;
45 Symbol& operator=(const Symbol&) = default;
46
47 Symbol(Symbol&&) = default;
48 Symbol& operator=(Symbol&&) = default;
49
50 ~Symbol() override = default;
51
52 void swap(Symbol& other) noexcept;
53
55 virtual std::string_view name() const LIEF_LIFETIMEBOUND {
56 return name_;
57 }
58
59 virtual std::string& name() {
60 return name_;
61 }
62
64 virtual void name(std::string name) {
65 name_ = std::move(name);
66 }
67
69 virtual uint64_t value() const {
70 return value_;
71 }
72
73 virtual void value(uint64_t value) {
74 value_ = value;
75 }
76
78 virtual uint64_t size() const {
79 return size_;
80 }
81
82 virtual void size(uint64_t value) {
83 size_ = value;
84 }
85
87 void accept(Visitor& visitor) const override;
88
89 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Symbol& entry);
90
91 protected:
92 std::string name_;
93 uint64_t value_ = 0;
94 uint64_t size_ = 0;
95};
96}
97
98#endif
Symbol()=default
virtual uint64_t value() const
Symbol's value which is usually the address of the symbol.
Definition Abstract/Symbol.hpp:69
virtual uint64_t size() const
The size of the symbol (when applicable).
Definition Abstract/Symbol.hpp:78
Symbol(const Symbol &)=default
virtual void size(uint64_t value)
Definition Abstract/Symbol.hpp:82
Symbol(std::string name)
Definition Abstract/Symbol.hpp:32
virtual std::string_view name() const
Return the symbol's name.
Definition Abstract/Symbol.hpp:55
Symbol(std::string name, uint64_t value, uint64_t size)
Definition Abstract/Symbol.hpp:39
~Symbol() override=default
Symbol & operator=(Symbol &&)=default
virtual void value(uint64_t value)
Definition Abstract/Symbol.hpp:73
Symbol(Symbol &&)=default
Symbol & operator=(const Symbol &)=default
virtual void name(std::string name)
Set symbol name.
Definition Abstract/Symbol.hpp:64
Symbol(std::string name, uint64_t value)
Definition Abstract/Symbol.hpp:35
void accept(Visitor &visitor) const override
Method so that the visitor can visit us.
virtual std::string & name()
Definition Abstract/Symbol.hpp:59
void swap(Symbol &other) noexcept
friend std::ostream & operator<<(std::ostream &os, const Symbol &entry)
Definition Visitor.hpp:211
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
LIEF namespace.
Definition Abstract/Binary.hpp:41
#define LIEF_API
Definition visibility.h:44