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 - 2024 R. Thomas
2 * Copyright 2017 - 2024 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 Symbol(std::string name, uint64_t value) :
35 name_(std::move(name)),
36 value_(value)
37 {}
38 Symbol(std::string name, uint64_t value, uint64_t size) :
39 name_(std::move(name)),
40 value_(value),
41 size_(size)
42 {}
43
44 Symbol(const Symbol&) = default;
45 Symbol& operator=(const Symbol&) = default;
46 ~Symbol() override = default;
47
48 void swap(Symbol& other) noexcept;
49 virtual const std::string& name() const {
52 return name_;
53 }
54 virtual std::string& name() {
55 return name_;
56 }
57 virtual void name(std::string name) {
60 name_ = std::move(name);
61 }
62
63 // Symbol's value which is usually the **address** of the symbol
64 virtual uint64_t value() const {
65 return value_;
66 }
67 virtual void value(uint64_t value) {
68 value_ = value;
69 }
70 virtual uint64_t size() const {
73 return size_;
74 }
75
76 virtual void size(uint64_t value) {
77 size_ = value;
78 }
79 void accept(Visitor& visitor) const override;
82
83 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Symbol& entry);
84
85 protected:
86 std::string name_;
87 uint64_t value_ = 0;
88 uint64_t size_ = 0;
89};
90}
91
92#endif
93
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:64
LIEF::Symbol::size
virtual uint64_t size() const
This size of the symbol (when applicable)
Definition Abstract/Symbol.hpp:72
LIEF::Symbol::Symbol
Symbol(const Symbol &)=default
LIEF::Symbol::size
virtual void size(uint64_t value)
Definition Abstract/Symbol.hpp:76
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:38
LIEF::Symbol::~Symbol
~Symbol() override=default
LIEF::Symbol::value
virtual void value(uint64_t value)
Definition Abstract/Symbol.hpp:67
LIEF::Symbol::operator=
Symbol & operator=(const Symbol &)=default
LIEF::Symbol::name
virtual void name(std::string name)
Set symbol name.
Definition Abstract/Symbol.hpp:59
LIEF::Symbol::Symbol
Symbol(std::string name, uint64_t value)
Definition Abstract/Symbol.hpp:34
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:54
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:51
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