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
25namespace LIEF {
26namespace ELF {
27
28class SymbolVersionAux;
29class Parser;
30
31namespace details {
32struct Elf64_Verdef;
33struct Elf32_Verdef;
34}
35
37class LIEF_API SymbolVersionDefinition : public Object {
38 friend class Parser;
39 public:
40 using version_aux_t = std::vector<std::unique_ptr<SymbolVersionAux>>;
43
44 SymbolVersionDefinition() = default;
45 SymbolVersionDefinition(const details::Elf64_Verdef& header);
46 SymbolVersionDefinition(const details::Elf32_Verdef& header);
47 ~SymbolVersionDefinition() override;
48
51 void swap(SymbolVersionDefinition& other);
52
57 uint16_t version() const {
58 return version_;
59 }
60
62 uint16_t flags() const {
63 return flags_;
64 }
65
69 uint16_t ndx() const {
70 return ndx_;
71 }
72
74 uint32_t hash() const {
75 return hash_;
76 }
77
80 return symbol_version_aux_;
81 }
82
83 it_const_version_aux symbols_aux() const {
84 return symbol_version_aux_;
85 }
86
87 void version(uint16_t version) {
88 version_ = version;
89 }
90
91 void flags(uint16_t flags) {
92 flags_ = flags;
93 }
94
95 void hash(uint32_t hash) {
96 hash_ = hash;
97 }
98
99 void accept(Visitor& visitor) const override;
100
101 LIEF_API friend std::ostream& operator<<(std::ostream& os, const SymbolVersionDefinition& sym);
102
103 private:
104 uint16_t version_ = 1;
105 uint16_t flags_ = 0;
106 uint16_t ndx_ = 0;
107 uint32_t hash_ = 0;
108 version_aux_t symbol_version_aux_;
109};
110}
111}
112#endif
113
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:37
it_version_aux symbols_aux()
SymbolVersionAux entries.
Definition SymbolVersionDefinition.hpp:79
uint32_t hash() const
Hash value of the symbol's name (using ELF hash function)
Definition SymbolVersionDefinition.hpp:74
uint16_t ndx() const
Version index.
Definition SymbolVersionDefinition.hpp:69
uint16_t version() const
Version revision.
Definition SymbolVersionDefinition.hpp:57
uint16_t flags() const
Version information.
Definition SymbolVersionDefinition.hpp:62
Definition Object.hpp:25
Iterator which returns reference on container's values.
Definition iterators.hpp:48
LIEF namespace.
Definition Abstract/Binary.hpp:31