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 * Copyright 2017 - 2026 Quarkslab
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef LIEF_ABSTRACT_SYMBOLS_H
17#define LIEF_ABSTRACT_SYMBOLS_H
18
19#include <string_view>
20#include <cstdint>
21#include <string>
22
23#include "LIEF/Object.hpp"
25#include "LIEF/visibility.h"
26
27namespace LIEF {
28
30class LIEF_API Symbol : public Object {
31 public:
32 Symbol() = default;
33 Symbol(std::string name) :
34 name_(std::move(name)) {}
35
36 Symbol(std::string name, uint64_t value) :
37 name_(std::move(name)),
38 value_(value) {}
39
40 Symbol(std::string name, uint64_t value, uint64_t size) :
41 name_(std::move(name)),
42 value_(value),
43 size_(size) {}
44
45 Symbol(const Symbol&) = default;
46 Symbol& operator=(const Symbol&) = default;
47
48 Symbol(Symbol&&) = default;
49 Symbol& operator=(Symbol&&) = default;
50
51 ~Symbol() override = default;
52
53 void swap(Symbol& other) noexcept;
54
56 virtual std::string_view name() const LIEF_LIFETIMEBOUND {
57 return name_;
58 }
59
60 virtual std::string& name() {
61 return name_;
62 }
63
65 virtual void name(std::string name) {
66 name_ = std::move(name);
67 }
68
70 virtual uint64_t value() const {
71 return value_;
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:70
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:33
virtual std::string_view name() const
Return the symbol's name.
Definition Abstract/Symbol.hpp:56
Symbol(std::string name, uint64_t value, uint64_t size)
Definition Abstract/Symbol.hpp:40
~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:65
Symbol(std::string name, uint64_t value)
Definition Abstract/Symbol.hpp:36
void accept(Visitor &visitor) const override
Method so that the visitor can visit us.
virtual std::string & name()
Definition Abstract/Symbol.hpp:60
void swap(Symbol &other) noexcept
friend std::ostream & operator<<(std::ostream &os, const Symbol &entry)
Definition Visitor.hpp:212
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
LIEF namespace.
Definition Abstract/Binary.hpp:41
#define LIEF_API
Definition visibility.h:45