LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
DynamicEntryRunPath.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_DYNAMIC_ENTRY_RUNPATH_H
17#define LIEF_ELF_DYNAMIC_ENTRY_RUNPATH_H
18
19#include <string>
20#include <vector>
21
22#include "LIEF/visibility.h"
24
25namespace LIEF {
26namespace ELF {
31
32 public:
33 static constexpr char delimiter = ':';
34 using DynamicEntry::DynamicEntry;
35
37 DynamicEntry::DynamicEntry(DynamicEntry::TAG::RUNPATH, 0)
38 {}
39 DynamicEntryRunPath(std::string runpath) :
42 DynamicEntry::DynamicEntry(DynamicEntry::TAG::RUNPATH, 0),
43 runpath_(std::move(runpath))
44 {}
45 DynamicEntryRunPath(const std::vector<std::string>& paths) :
48 DynamicEntry::DynamicEntry(DynamicEntry::TAG::RUNPATH, 0)
49 {
50 this->paths(paths);
51 }
52
53 DynamicEntryRunPath& operator=(const DynamicEntryRunPath&) = default;
54 DynamicEntryRunPath(const DynamicEntryRunPath&) = default;
55
56 std::unique_ptr<DynamicEntry> clone() const override {
57 return std::unique_ptr<DynamicEntry>(new DynamicEntryRunPath(*this));
58 }
59 const std::string& runpath() const {
62 return runpath_;
63 }
64
65 void runpath(std::string runpath) {
66 runpath_ = std::move(runpath);
67 }
68 std::vector<std::string> paths() const;
71 void paths(const std::vector<std::string>& paths);
72 DynamicEntryRunPath& insert(size_t pos, const std::string& path);
75 DynamicEntryRunPath& append(const std::string& path);
78 DynamicEntryRunPath& remove(const std::string& path);
81
82 DynamicEntryRunPath& operator+=(std::string path) {
83 return append(std::move(path));
84 }
85
86 DynamicEntryRunPath& operator-=(const std::string& path) {
87 return remove(path);
88 }
89
90 void accept(Visitor& visitor) const override;
91
92 static bool classof(const DynamicEntry* entry) {
93 return entry->tag() == DynamicEntry::TAG::RUNPATH;
94 }
95
96 std::ostream& print(std::ostream& os) const override;
97
98 ~DynamicEntryRunPath() = default;
99
100 private:
101 std::string runpath_;
102};
103}
104}
105#endif
DynamicEntry.hpp
LIEF::ELF::DynamicEntryRunPath
Class that represents a DT_RUNPATH wich is used by the loader to resolve libraries (DynamicEntryLibra...
Definition DynamicEntryRunPath.hpp:30
LIEF::ELF::DynamicEntryRunPath::accept
void accept(Visitor &visitor) const override
LIEF::ELF::DynamicEntryRunPath::clone
std::unique_ptr< DynamicEntry > clone() const override
Definition DynamicEntryRunPath.hpp:56
LIEF::ELF::DynamicEntryRunPath::insert
DynamicEntryRunPath & insert(size_t pos, const std::string &path)
Insert a path at the given position
LIEF::ELF::DynamicEntryRunPath::DynamicEntryRunPath
DynamicEntryRunPath(const DynamicEntryRunPath &)=default
LIEF::ELF::DynamicEntryRunPath::operator+=
DynamicEntryRunPath & operator+=(std::string path)
Definition DynamicEntryRunPath.hpp:82
LIEF::ELF::DynamicEntryRunPath::append
DynamicEntryRunPath & append(const std::string &path)
Append the given path
LIEF::ELF::DynamicEntryRunPath::remove
DynamicEntryRunPath & remove(const std::string &path)
Remove the given path
LIEF::ELF::DynamicEntryRunPath::DynamicEntryRunPath
DynamicEntryRunPath(std::string runpath)
Constructor from (run)path.
Definition DynamicEntryRunPath.hpp:41
LIEF::ELF::DynamicEntryRunPath::paths
void paths(const std::vector< std::string > &paths)
LIEF::ELF::DynamicEntryRunPath::~DynamicEntryRunPath
~DynamicEntryRunPath()=default
LIEF::ELF::DynamicEntryRunPath::DynamicEntryRunPath
DynamicEntryRunPath(const std::vector< std::string > &paths)
Constructor from a list of paths.
Definition DynamicEntryRunPath.hpp:47
LIEF::ELF::DynamicEntryRunPath::runpath
void runpath(std::string runpath)
Definition DynamicEntryRunPath.hpp:65
LIEF::ELF::DynamicEntryRunPath::print
std::ostream & print(std::ostream &os) const override
LIEF::ELF::DynamicEntryRunPath::runpath
const std::string & runpath() const
Runpath raw value.
Definition DynamicEntryRunPath.hpp:61
LIEF::ELF::DynamicEntryRunPath::paths
std::vector< std::string > paths() const
Paths as a list.
LIEF::ELF::DynamicEntryRunPath::operator-=
DynamicEntryRunPath & operator-=(const std::string &path)
Definition DynamicEntryRunPath.hpp:86
LIEF::ELF::DynamicEntryRunPath::classof
static bool classof(const DynamicEntry *entry)
Definition DynamicEntryRunPath.hpp:92
LIEF::ELF::DynamicEntryRunPath::DynamicEntryRunPath
DynamicEntryRunPath()
Definition DynamicEntryRunPath.hpp:36
LIEF::ELF::DynamicEntryRunPath::operator=
DynamicEntryRunPath & operator=(const DynamicEntryRunPath &)=default
LIEF::ELF::DynamicEntry
Class which represents an entry in the dynamic table These entries are located in the ....
Definition DynamicEntry.hpp:36
LIEF::ELF::DynamicEntry::tag
TAG tag() const
Tag of the current entry. The most common tags are: DT_NEEDED, DT_INIT, ...
Definition DynamicEntry.hpp:205
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