LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
SymbolVersionRequirement.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_REQUIREMENTS_H
17#define LIEF_ELF_SYMBOL_VERSION_REQUIREMENTS_H
18
19#include <string>
20#include <ostream>
21#include <vector>
22#include <memory>
23
24#include "LIEF/Object.hpp"
25#include "LIEF/visibility.h"
26#include "LIEF/iterators.hpp"
27
28namespace LIEF {
29namespace ELF {
30class Parser;
31class SymbolVersionAuxRequirement;
32
33namespace details {
34struct Elf64_Verneed;
35struct Elf32_Verneed;
36}
37
39class LIEF_API SymbolVersionRequirement : public Object {
40 friend class Parser;
41
42 public:
43 using aux_requirement_t = std::vector<std::unique_ptr<SymbolVersionAuxRequirement>>;
46
47 SymbolVersionRequirement() = default;
48 SymbolVersionRequirement(const details::Elf64_Verneed& header);
49 SymbolVersionRequirement(const details::Elf32_Verneed& header);
50 ~SymbolVersionRequirement() override = default;
51
54 void swap(SymbolVersionRequirement& other);
55
60 uint16_t version() const {
61 return version_;
62 }
63
65 size_t cnt() const {
66 return aux_requirements_.size();
67 }
68
71 return aux_requirements_;
72 }
73
74 it_const_aux_requirement auxiliary_symbols() const {
75 return aux_requirements_;
76 }
77
79 const std::string& name() const {
80 return name_;
81 }
82
83 void version(uint16_t version) {
84 version_ = version;
85 }
86
87 void name(const std::string& name) {
88 name_ = name;
89 }
90
93
94 void accept(Visitor& visitor) const override;
95
96 LIEF_API friend
97 std::ostream& operator<<(std::ostream& os, const SymbolVersionRequirement& symr) {
98 os << symr.version() << " " << symr.name();
99 return os;
100 }
101
102 private:
103 aux_requirement_t aux_requirements_;
104 uint16_t version_ = 0;
105 std::string name_;
106};
107
108}
109}
110#endif
111
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 entry in the DT_VERNEED or .gnu.version_r table.
Definition SymbolVersionRequirement.hpp:39
size_t cnt() const
Number of auxiliary entries.
Definition SymbolVersionRequirement.hpp:65
const std::string & name() const
Return the library name associated with this requirement (e.g. libc.so.6)
Definition SymbolVersionRequirement.hpp:79
uint16_t version() const
Version revision.
Definition SymbolVersionRequirement.hpp:60
it_aux_requirement auxiliary_symbols()
Auxiliary entries as an iterator over SymbolVersionAuxRequirement.
Definition SymbolVersionRequirement.hpp:70
SymbolVersionAuxRequirement & add_aux_requirement(const SymbolVersionAuxRequirement &aux_requirement)
Add a version auxiliary requirement to the existing list.
Definition Object.hpp:25
Definition Visitor.hpp:219
Iterator which returns reference on container's values.
Definition iterators.hpp:48
LIEF namespace.
Definition Abstract/Binary.hpp:32