LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
SymbolVersion.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_ELF_SYMBOL_VERSION_H
17#define LIEF_ELF_SYMBOL_VERSION_H
18#include <ostream>
19#include <cstdint>
20#include <cassert>
21
22#include "LIEF/Object.hpp"
23#include "LIEF/visibility.h"
24
25namespace LIEF {
26namespace ELF {
27class Parser;
30
34 friend class Parser;
35
36 public:
37 static constexpr auto LOCAL_VERSION = 0;
38 static constexpr auto GLOBAL_VERSION = 1;
39
40 SymbolVersion(uint16_t value) :
41 value_(value)
42 {}
43 SymbolVersion() = default;
44
48 }
49
53 }
54
55 ~SymbolVersion() override = default;
56
58 SymbolVersion(const SymbolVersion&) = default;
59
66 uint16_t value() const {
67 return value_;
68 }
69
71 bool has_auxiliary_version() const {
72 return symbol_version_auxiliary() != nullptr;
73 }
74
78 return symbol_aux_;
79 }
80
82 return symbol_aux_;
83 }
84
92
94 void drop_version(uint16_t value) {
95 if (symbol_aux_ == nullptr) {
96 return;
97 }
98 assert(value == LOCAL_VERSION || value == GLOBAL_VERSION);
99 value_ = value;
100 symbol_aux_ = nullptr;
101 }
102
106 void as_global() {
108 }
109
113 void as_local() {
115 }
116
117 void value(uint16_t v) {
118 value_ = v;
119 }
120
121 void accept(Visitor& visitor) const override;
122
123 LIEF_API friend std::ostream& operator<<(std::ostream& os, const SymbolVersion& symv);
124
125 private:
126 uint16_t value_ = 0;
127 SymbolVersionAux* symbol_aux_ = nullptr;
128};
129}
130}
131#endif
Class which parses and transforms an ELF file into a ELF::Binary object.
Definition ELF/Parser.hpp:45
Definition SymbolVersionAuxRequirement.hpp:35
Class which represents an Auxiliary Symbol version.
Definition SymbolVersionAux.hpp:30
const SymbolVersionAux * symbol_version_auxiliary() const
Definition SymbolVersion.hpp:81
bool has_auxiliary_version() const
Whether the current SymbolVersion has an auxiliary one.
Definition SymbolVersion.hpp:71
static constexpr auto GLOBAL_VERSION
Definition SymbolVersion.hpp:38
SymbolVersion & operator=(const SymbolVersion &)=default
void drop_version(uint16_t value)
Drop the versioning requirement and replace the value (local/global).
Definition SymbolVersion.hpp:94
static SymbolVersion local()
Generate a local SymbolVersion.
Definition SymbolVersion.hpp:46
static constexpr auto LOCAL_VERSION
Definition SymbolVersion.hpp:37
~SymbolVersion() override=default
friend std::ostream & operator<<(std::ostream &os, const SymbolVersion &symv)
void accept(Visitor &visitor) const override
SymbolVersion(const SymbolVersion &)=default
friend class Parser
Definition SymbolVersion.hpp:34
void symbol_version_auxiliary(SymbolVersionAuxRequirement &svauxr)
Set the version's auxiliary requirement The given SymbolVersionAuxRequirement must be an existing ref...
static SymbolVersion global()
Generate a global SymbolVersion.
Definition SymbolVersion.hpp:51
void as_local()
Redefine this version as local by dropping its auxiliary version.
Definition SymbolVersion.hpp:113
void as_global()
Redefine this version as global by dropping its auxiliary version.
Definition SymbolVersion.hpp:106
SymbolVersion(uint16_t value)
Definition SymbolVersion.hpp:40
void value(uint16_t v)
Definition SymbolVersion.hpp:117
SymbolVersionAux * symbol_version_auxiliary()
SymbolVersionAux associated with the current Version if any, or a nullptr.
Definition SymbolVersion.hpp:77
uint16_t value() const
Value associated with the symbol.
Definition SymbolVersion.hpp:66
Definition Visitor.hpp:210
Namespace related to the LIEF's ELF module.
Definition Abstract/Header.hpp:28
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:41