LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
Abstract/Symbol.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2025 R. Thomas
2 * Copyright 2017 - 2025 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 <cstdint>
20#include <string>
21
22#include "LIEF/Object.hpp"
23#include "LIEF/visibility.h"
24
25namespace LIEF {
26class LIEF_API Symbol : public Object {
29 public:
30 Symbol() = default;
31 Symbol(std::string name) :
32 name_(std::move(name))
33 {}
34
35 Symbol(std::string name, uint64_t value) :
36 name_(std::move(name)), value_(value)
37 {}
38
39 Symbol(std::string name, uint64_t value, uint64_t size) :
40 name_(std::move(name)), value_(value), size_(size)
41 {}
42
43 Symbol(const Symbol&) = default;
44 Symbol& operator=(const Symbol&) = default;
45
46 Symbol(Symbol&&) = default;
47 Symbol& operator=(Symbol&&) = default;
48
49 ~Symbol() override = default;
50
51 void swap(Symbol& other) noexcept;
52 virtual const std::string& name() const {
55 return name_;
56 }
57
58 virtual std::string& name() {
59 return name_;
60 }
61 virtual void name(std::string name) {
64 name_ = std::move(name);
65 }
66
67 // Symbol's value which is usually the **address** of the symbol
68 virtual uint64_t value() const {
69 return value_;
70 }
71 virtual void value(uint64_t value) {
72 value_ = value;
73 }
74 virtual uint64_t size() const {
77 return size_;
78 }
79
80 virtual void size(uint64_t value) {
81 size_ = value;
82 }
83 void accept(Visitor& visitor) const override;
86
87 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Symbol& entry);
88
89 protected:
90 std::string name_;
91 uint64_t value_ = 0;
92 uint64_t size_ = 0;
93};
94}
95
96#endif
97
Object.hpp
LIEF::Object
Definition Object.hpp:25
LIEF::Symbol
This class represents a symbol in an executable format.
Definition Abstract/Symbol.hpp:28
LIEF::Symbol::Symbol
Symbol()=default
LIEF::Symbol::value
virtual uint64_t value() const
Definition Abstract/Symbol.hpp:68
LIEF::Symbol::size
virtual uint64_t size() const
This size of the symbol (when applicable)
Definition Abstract/Symbol.hpp:76
LIEF::Symbol::Symbol
Symbol(const Symbol &)=default
LIEF::Symbol::size
virtual void size(uint64_t value)
Definition Abstract/Symbol.hpp:80
LIEF::Symbol::Symbol
Symbol(std::string name)
Definition Abstract/Symbol.hpp:31
LIEF::Symbol::Symbol
Symbol(std::string name, uint64_t value, uint64_t size)
Definition Abstract/Symbol.hpp:39
LIEF::Symbol::~Symbol
~Symbol() override=default
LIEF::Symbol::operator=
Symbol & operator=(Symbol &&)=default
LIEF::Symbol::value
virtual void value(uint64_t value)
Definition Abstract/Symbol.hpp:71
LIEF::Symbol::Symbol
Symbol(Symbol &&)=default
LIEF::Symbol::operator=
Symbol & operator=(const Symbol &)=default
LIEF::Symbol::name
virtual void name(std::string name)
Set symbol name.
Definition Abstract/Symbol.hpp:63
LIEF::Symbol::Symbol
Symbol(std::string name, uint64_t value)
Definition Abstract/Symbol.hpp:35
LIEF::Symbol::accept
void accept(Visitor &visitor) const override
Method so that the visitor can visit us.
LIEF::Symbol::name
virtual std::string & name()
Definition Abstract/Symbol.hpp:58
LIEF::Symbol::swap
void swap(Symbol &other) noexcept
LIEF::Symbol::name
virtual const std::string & name() const
Return the symbol's name.
Definition Abstract/Symbol.hpp:54
LIEF::Symbol::operator<<
friend std::ostream & operator<<(std::ostream &os, const Symbol &entry)
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41