LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
SymbolVersionRequirement.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 * Copyright 2017 - 2026 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_REQUIREMENTS_H
17#define LIEF_ELF_SYMBOL_VERSION_REQUIREMENTS_H
18
19#include <cstdint>
20#include <string>
21#include <ostream>
22#include <vector>
23#include <memory>
24
25#include "LIEF/Object.hpp"
26#include "LIEF/visibility.h"
27#include "LIEF/iterators.hpp"
28
29namespace LIEF {
30namespace ELF {
31class Parser;
33
34namespace details {
35struct Elf64_Verneed;
36struct Elf32_Verneed;
37}
38
41 friend class Parser;
42
43 public:
45 std::vector<std::unique_ptr<SymbolVersionAuxRequirement>>;
51
53 SymbolVersionRequirement(const details::Elf64_Verneed& header);
54 SymbolVersionRequirement(const details::Elf32_Verneed& header);
55 ~SymbolVersionRequirement() override = default;
56
60
65 uint16_t version() const {
66 return version_;
67 }
68
70 size_t cnt() const {
71 return aux_requirements_.size();
72 }
73
76 return aux_requirements_;
77 }
78
80 return aux_requirements_;
81 }
82
84 const std::string& name() const {
85 return name_;
86 }
87
88 void version(uint16_t version) {
89 version_ = version;
90 }
91
92 void name(const std::string& name) {
93 name_ = name;
94 }
95
99
102 const SymbolVersionAuxRequirement* find_aux(const std::string& name) const;
103
105 return const_cast<SymbolVersionAuxRequirement*>(
106 static_cast<const SymbolVersionRequirement*>(this)->find_aux(name)
107 );
108 }
109
117 bool remove_aux_requirement(const std::string& name) {
119 return remove_aux_requirement(*aux);
120 }
121 return false;
122 }
123
132
133 void accept(Visitor& visitor) const override;
134
135 LIEF_API friend std::ostream& operator<<(std::ostream& os,
136 const SymbolVersionRequirement& symr) {
137 os << symr.version() << " " << symr.name();
138 return os;
139 }
140
141 private:
142 aux_requirement_t aux_requirements_;
143 uint16_t version_ = 0;
144 std::string name_;
145};
146
147}
148}
149#endif
Class which parses and transforms an ELF file into a ELF::Binary object.
Definition ELF/Parser.hpp:45
Definition SymbolVersionAuxRequirement.hpp:35
void accept(Visitor &visitor) const override
size_t cnt() const
Number of auxiliary entries.
Definition SymbolVersionRequirement.hpp:70
void swap(SymbolVersionRequirement &other)
std::vector< std::unique_ptr< SymbolVersionAuxRequirement > > aux_requirement_t
Definition SymbolVersionRequirement.hpp:44
const_ref_iterator< const aux_requirement_t &, const SymbolVersionAuxRequirement * > it_const_aux_requirement
Definition SymbolVersionRequirement.hpp:48
bool remove_aux_requirement(SymbolVersionAuxRequirement &aux)
Try to remove the given auxiliary requirement symbol. The function returns true if the operation succ...
void version(uint16_t version)
Definition SymbolVersionRequirement.hpp:88
const SymbolVersionAuxRequirement * find_aux(const std::string &name) const
Try to find the SymbolVersionAuxRequirement with the given name (e.g. GLIBC_2.27).
it_const_aux_requirement auxiliary_symbols() const
Definition SymbolVersionRequirement.hpp:79
SymbolVersionRequirement(const details::Elf64_Verneed &header)
const std::string & name() const
Return the library name associated with this requirement (e.g. libc.so.6).
Definition SymbolVersionRequirement.hpp:84
uint16_t version() const
Version revision.
Definition SymbolVersionRequirement.hpp:65
bool remove_aux_requirement(const std::string &name)
Try to remove the auxiliary requirement symbol with the given name. The function returns true if the ...
Definition SymbolVersionRequirement.hpp:117
SymbolVersionRequirement & operator=(SymbolVersionRequirement other)
it_aux_requirement auxiliary_symbols()
Auxiliary entries as an iterator over SymbolVersionAuxRequirement.
Definition SymbolVersionRequirement.hpp:75
friend class Parser
Definition SymbolVersionRequirement.hpp:41
friend std::ostream & operator<<(std::ostream &os, const SymbolVersionRequirement &symr)
Definition SymbolVersionRequirement.hpp:135
SymbolVersionRequirement(const SymbolVersionRequirement &other)
SymbolVersionAuxRequirement * find_aux(const std::string &name)
Definition SymbolVersionRequirement.hpp:104
~SymbolVersionRequirement() override=default
void name(const std::string &name)
Definition SymbolVersionRequirement.hpp:92
SymbolVersionAuxRequirement & add_aux_requirement(const SymbolVersionAuxRequirement &aux_requirement)
Add a version auxiliary requirement to the existing list.
SymbolVersionRequirement(const details::Elf32_Verneed &header)
ref_iterator< aux_requirement_t &, SymbolVersionAuxRequirement * > it_aux_requirement
Definition SymbolVersionRequirement.hpp:46
Definition Visitor.hpp:212
Iterator which returns reference on container's values.
Definition iterators.hpp:45
Definition DynamicEntry.hpp:29
Namespace related to the LIEF's ELF module.
Definition Abstract/Header.hpp:28
LIEF namespace.
Definition Abstract/Binary.hpp:40
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which return const ref on container's values.
Definition iterators.hpp:286
#define LIEF_API
Definition visibility.h:43