LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
SymbolVersionRequirement.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_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;
32
33namespace details {
34struct Elf64_Verneed;
35struct Elf32_Verneed;
36}
37class LIEF_API SymbolVersionRequirement : public Object {
40 friend class Parser;
41
42 public:
43 using aux_requirement_t = std::vector<std::unique_ptr<SymbolVersionAuxRequirement>>;
44 using it_aux_requirement = ref_iterator<aux_requirement_t&, SymbolVersionAuxRequirement*>;
45 using it_const_aux_requirement = const_ref_iterator<const aux_requirement_t&, const SymbolVersionAuxRequirement*>;
46
48 SymbolVersionRequirement(const details::Elf64_Verneed& header);
49 SymbolVersionRequirement(const details::Elf32_Verneed& header);
50 ~SymbolVersionRequirement() override = default;
51
52 SymbolVersionRequirement& operator=(SymbolVersionRequirement other);
53 SymbolVersionRequirement(const SymbolVersionRequirement& other);
54 void swap(SymbolVersionRequirement& other);
55 uint16_t version() const {
61 return version_;
62 }
63 size_t cnt() const {
66 return aux_requirements_.size();
67 }
68 it_aux_requirement auxiliary_symbols() {
71 return aux_requirements_;
72 }
73
74 it_const_aux_requirement auxiliary_symbols() const {
75 return aux_requirements_;
76 }
77 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 SymbolVersionAuxRequirement& add_aux_requirement(const SymbolVersionAuxRequirement& aux_requirement);
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
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::SymbolVersionAuxRequirement
Definition SymbolVersionAuxRequirement.hpp:35
LIEF::ELF::SymbolVersionRequirement
Class which represents an entry in the DT_VERNEED or .gnu.version_r table.
Definition SymbolVersionRequirement.hpp:39
LIEF::ELF::SymbolVersionRequirement::accept
void accept(Visitor &visitor) const override
LIEF::ELF::SymbolVersionRequirement::cnt
size_t cnt() const
Number of auxiliary entries.
Definition SymbolVersionRequirement.hpp:65
LIEF::ELF::SymbolVersionRequirement::swap
void swap(SymbolVersionRequirement &other)
LIEF::ELF::SymbolVersionRequirement::version
void version(uint16_t version)
Definition SymbolVersionRequirement.hpp:83
LIEF::ELF::SymbolVersionRequirement::auxiliary_symbols
it_const_aux_requirement auxiliary_symbols() const
Definition SymbolVersionRequirement.hpp:74
LIEF::ELF::SymbolVersionRequirement::SymbolVersionRequirement
SymbolVersionRequirement(const details::Elf64_Verneed &header)
LIEF::ELF::SymbolVersionRequirement::name
const std::string & name() const
Return the library name associated with this requirement (e.g. libc.so.6)
Definition SymbolVersionRequirement.hpp:79
LIEF::ELF::SymbolVersionRequirement::version
uint16_t version() const
Version revision.
Definition SymbolVersionRequirement.hpp:60
LIEF::ELF::SymbolVersionRequirement::operator=
SymbolVersionRequirement & operator=(SymbolVersionRequirement other)
LIEF::ELF::SymbolVersionRequirement::auxiliary_symbols
it_aux_requirement auxiliary_symbols()
Auxiliary entries as an iterator over SymbolVersionAuxRequirement.
Definition SymbolVersionRequirement.hpp:70
LIEF::ELF::SymbolVersionRequirement::operator<<
friend std::ostream & operator<<(std::ostream &os, const SymbolVersionRequirement &symr)
Definition SymbolVersionRequirement.hpp:97
LIEF::ELF::SymbolVersionRequirement::SymbolVersionRequirement
SymbolVersionRequirement(const SymbolVersionRequirement &other)
LIEF::ELF::SymbolVersionRequirement::~SymbolVersionRequirement
~SymbolVersionRequirement() override=default
LIEF::ELF::SymbolVersionRequirement::name
void name(const std::string &name)
Definition SymbolVersionRequirement.hpp:87
LIEF::ELF::SymbolVersionRequirement::add_aux_requirement
SymbolVersionAuxRequirement & add_aux_requirement(const SymbolVersionAuxRequirement &aux_requirement)
Add a version auxiliary requirement to the existing list.
LIEF::ELF::SymbolVersionRequirement::SymbolVersionRequirement
SymbolVersionRequirement()=default
LIEF::ELF::SymbolVersionRequirement::SymbolVersionRequirement
SymbolVersionRequirement(const details::Elf32_Verneed &header)
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
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41