LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
SymbolVersionDefinition.hpp
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_ELF_SYMBOL_VERSION_DEFINITION_H
17#define LIEF_ELF_SYMBOL_VERSION_DEFINITION_H
18#include <ostream>
19#include <memory>
20
21#include "LIEF/Object.hpp"
22#include "LIEF/visibility.h"
23#include "LIEF/iterators.hpp"
24
25#include "LIEF/ELF/enums.hpp"
26
27namespace LIEF {
28namespace ELF {
29
30class SymbolVersionAux;
31class Parser;
32
33namespace details {
34struct Elf64_Verdef;
35struct Elf32_Verdef;
36}
37
39class LIEF_API SymbolVersionDefinition : public Object {
40 friend class Parser;
41 public:
42 using version_aux_t = std::vector<std::unique_ptr<SymbolVersionAux>>;
45
46 SymbolVersionDefinition() = default;
47 SymbolVersionDefinition(const details::Elf64_Verdef& header);
48 SymbolVersionDefinition(const details::Elf32_Verdef& header);
49 ~SymbolVersionDefinition() override;
50
53 void swap(SymbolVersionDefinition& other);
54
59 uint16_t version() const {
60 return version_;
61 }
62
64 uint16_t flags() const {
65 return flags_;
66 }
67
71 uint16_t ndx() const {
72 return ndx_;
73 }
74
76 uint32_t hash() const {
77 return hash_;
78 }
79
82 return symbol_version_aux_;
83 }
84
85 it_const_version_aux symbols_aux() const {
86 return symbol_version_aux_;
87 }
88
89 void version(uint16_t version) {
90 version_ = version;
91 }
92
93 void flags(uint16_t flags) {
94 flags_ = flags;
95 }
96
97 void hash(uint32_t hash) {
98 hash_ = hash;
99 }
100
101 void accept(Visitor& visitor) const override;
102
103 LIEF_API friend std::ostream& operator<<(std::ostream& os, const SymbolVersionDefinition& sym);
104
105 private:
106 uint16_t version_ = 1;
107 uint16_t flags_ = 0;
108 uint16_t ndx_ = 0;
109 uint32_t hash_ = 0;
110 version_aux_t symbol_version_aux_;
111};
112}
113}
114#endif
115
Class which parses and transforms an ELF file into a ELF::Binary object.
Definition ELF/Parser.hpp:45
Class which represents an entry defined in DT_VERDEF or .gnu.version_d
Definition SymbolVersionDefinition.hpp:39
it_version_aux symbols_aux()
SymbolVersionAux entries.
Definition SymbolVersionDefinition.hpp:81
uint32_t hash() const
Hash value of the symbol's name (using ELF hash function)
Definition SymbolVersionDefinition.hpp:76
uint16_t ndx() const
Version index.
Definition SymbolVersionDefinition.hpp:71
uint16_t version() const
Version revision.
Definition SymbolVersionDefinition.hpp:59
uint16_t flags() const
Version information.
Definition SymbolVersionDefinition.hpp:64
Definition Object.hpp:25
Iterator which returns reference on container's values.
Definition iterators.hpp:48
LIEF namespace.
Definition Abstract/Binary.hpp:32