LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
SymbolVersionDefinition.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_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
29class Parser;
30
31namespace details {
32struct Elf64_Verdef;
33struct Elf32_Verdef;
34}
35class LIEF_API SymbolVersionDefinition : public Object {
38 friend class Parser;
39 public:
40 using version_aux_t = std::vector<std::unique_ptr<SymbolVersionAux>>;
41 using it_version_aux = ref_iterator<version_aux_t&, SymbolVersionAux*>;
42 using it_const_version_aux = const_ref_iterator<const version_aux_t&, const SymbolVersionAux*>;
43
45 SymbolVersionDefinition(const details::Elf64_Verdef& header);
46 SymbolVersionDefinition(const details::Elf32_Verdef& header);
48
49 SymbolVersionDefinition& operator=(SymbolVersionDefinition other);
50 SymbolVersionDefinition(const SymbolVersionDefinition& other);
51 void swap(SymbolVersionDefinition& other);
52 uint16_t version() const {
58 return version_;
59 }
60 uint16_t flags() const {
63 return flags_;
64 }
65 uint16_t ndx() const {
70 return ndx_;
71 }
72 uint32_t hash() const {
75 return hash_;
76 }
77 it_version_aux symbols_aux() {
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
Object.hpp
LIEF::ELF::Parser
Class which parses and transforms an ELF file into a ELF::Binary object.
Definition ELF/Parser.hpp:45
LIEF::ELF::SymbolVersionAux
Class which represents an Auxiliary Symbol version.
Definition SymbolVersionAux.hpp:30
LIEF::ELF::SymbolVersionDefinition
Class which represents an entry defined in DT_VERDEF or .gnu.version_d
Definition SymbolVersionDefinition.hpp:37
LIEF::ELF::SymbolVersionDefinition::hash
void hash(uint32_t hash)
Definition SymbolVersionDefinition.hpp:95
LIEF::ELF::SymbolVersionDefinition::SymbolVersionDefinition
SymbolVersionDefinition(const SymbolVersionDefinition &other)
LIEF::ELF::SymbolVersionDefinition::symbols_aux
it_version_aux symbols_aux()
SymbolVersionAux entries.
Definition SymbolVersionDefinition.hpp:79
LIEF::ELF::SymbolVersionDefinition::SymbolVersionDefinition
SymbolVersionDefinition(const details::Elf64_Verdef &header)
LIEF::ELF::SymbolVersionDefinition::SymbolVersionDefinition
SymbolVersionDefinition()=default
LIEF::ELF::SymbolVersionDefinition::accept
void accept(Visitor &visitor) const override
LIEF::ELF::SymbolVersionDefinition::hash
uint32_t hash() const
Hash value of the symbol's name (using ELF hash function)
Definition SymbolVersionDefinition.hpp:74
LIEF::ELF::SymbolVersionDefinition::ndx
uint16_t ndx() const
Version index.
Definition SymbolVersionDefinition.hpp:69
LIEF::ELF::SymbolVersionDefinition::operator<<
friend std::ostream & operator<<(std::ostream &os, const SymbolVersionDefinition &sym)
LIEF::ELF::SymbolVersionDefinition::flags
void flags(uint16_t flags)
Definition SymbolVersionDefinition.hpp:91
LIEF::ELF::SymbolVersionDefinition::version
uint16_t version() const
Version revision.
Definition SymbolVersionDefinition.hpp:57
LIEF::ELF::SymbolVersionDefinition::~SymbolVersionDefinition
~SymbolVersionDefinition() override
LIEF::ELF::SymbolVersionDefinition::SymbolVersionDefinition
SymbolVersionDefinition(const details::Elf32_Verdef &header)
LIEF::ELF::SymbolVersionDefinition::symbols_aux
it_const_version_aux symbols_aux() const
Definition SymbolVersionDefinition.hpp:83
LIEF::ELF::SymbolVersionDefinition::operator=
SymbolVersionDefinition & operator=(SymbolVersionDefinition other)
LIEF::ELF::SymbolVersionDefinition::swap
void swap(SymbolVersionDefinition &other)
LIEF::ELF::SymbolVersionDefinition::version
void version(uint16_t version)
Definition SymbolVersionDefinition.hpp:87
LIEF::ELF::SymbolVersionDefinition::flags
uint16_t flags() const
Version information.
Definition SymbolVersionDefinition.hpp:62
iterators.hpp
LIEF::ELF::details
Definition DynamicEntry.hpp:29
LIEF::ELF
Namespace related to the LIEF's ELF module.
Definition Abstract/Header.hpp:28
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
LIEF::hash
Hash::value_type hash(const Object &v)
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41