LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
DynamicEntryRpath.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_RPATH_H
17#define LIEF_ELF_DYNAMIC_ENTRY_RPATH_H
18
19#include <string>
20#include <vector>
21
22#include "LIEF/visibility.h"
24
25namespace LIEF {
26namespace ELF {
31 public:
32 static constexpr char delimiter = ':';
33 using DynamicEntry::DynamicEntry;
35 DynamicEntry::DynamicEntry(DynamicEntry::TAG::RPATH, 0)
36 {}
37
38 DynamicEntryRpath(std::string rpath) :
39 DynamicEntry::DynamicEntry(DynamicEntry::TAG::RPATH, 0),
40 rpath_(std::move(rpath))
41 {}
42 DynamicEntryRpath(const std::vector<std::string>& paths) :
45 DynamicEntry::DynamicEntry(DynamicEntry::TAG::RPATH, 0)
46 {
47 this->paths(paths);
48 }
49
50 DynamicEntryRpath& operator=(const DynamicEntryRpath&) = default;
51 DynamicEntryRpath(const DynamicEntryRpath&) = default;
52
53 std::unique_ptr<DynamicEntry> clone() const override {
54 return std::unique_ptr<DynamicEntryRpath>(new DynamicEntryRpath(*this));
55 }
56 const std::string& rpath() const {
59 return rpath_;
60 }
61
62 void rpath(std::string name) {
63 rpath_ = std::move(name);
64 }
65 std::vector<std::string> paths() const;
68 void paths(const std::vector<std::string>& paths);
69 DynamicEntryRpath& insert(size_t pos, const std::string& path);
72 DynamicEntryRpath& append(std::string path);
75 DynamicEntryRpath& remove(const std::string& path);
78
79 DynamicEntryRpath& operator+=(std::string path) {
80 return append(std::move(path));
81 }
82
83 DynamicEntryRpath& operator-=(const std::string& path) {
84 return remove(path);
85 }
86
87 static bool classof(const DynamicEntry* entry) {
88 return entry->tag() == DynamicEntry::TAG::RPATH;
89 }
90
91 void accept(Visitor& visitor) const override;
92
93 std::ostream& print(std::ostream& os) const override;
94
95 ~DynamicEntryRpath() = default;
96
97 private:
98 std::string rpath_;
99};
100}
101}
102
103#endif
DynamicEntry.hpp
LIEF::ELF::DynamicEntryRpath
Class which represents a DT_RPATH entry. This attribute is deprecated (cf. man ld) in favour of DT_RU...
Definition DynamicEntryRpath.hpp:30
LIEF::ELF::DynamicEntryRpath::DynamicEntryRpath
DynamicEntryRpath(const DynamicEntryRpath &)=default
LIEF::ELF::DynamicEntryRpath::print
std::ostream & print(std::ostream &os) const override
LIEF::ELF::DynamicEntryRpath::rpath
const std::string & rpath() const
The actual rpath as a string.
Definition DynamicEntryRpath.hpp:58
LIEF::ELF::DynamicEntryRpath::rpath
void rpath(std::string name)
Definition DynamicEntryRpath.hpp:62
LIEF::ELF::DynamicEntryRpath::insert
DynamicEntryRpath & insert(size_t pos, const std::string &path)
Insert a path at the given position
LIEF::ELF::DynamicEntryRpath::paths
std::vector< std::string > paths() const
Paths as a list.
LIEF::ELF::DynamicEntryRpath::operator=
DynamicEntryRpath & operator=(const DynamicEntryRpath &)=default
LIEF::ELF::DynamicEntryRpath::append
DynamicEntryRpath & append(std::string path)
Append the given path
LIEF::ELF::DynamicEntryRpath::remove
DynamicEntryRpath & remove(const std::string &path)
Remove the given path
LIEF::ELF::DynamicEntryRpath::operator-=
DynamicEntryRpath & operator-=(const std::string &path)
Definition DynamicEntryRpath.hpp:83
LIEF::ELF::DynamicEntryRpath::DynamicEntryRpath
DynamicEntryRpath(const std::vector< std::string > &paths)
Constructor from a list of paths.
Definition DynamicEntryRpath.hpp:44
LIEF::ELF::DynamicEntryRpath::accept
void accept(Visitor &visitor) const override
LIEF::ELF::DynamicEntryRpath::paths
void paths(const std::vector< std::string > &paths)
LIEF::ELF::DynamicEntryRpath::classof
static bool classof(const DynamicEntry *entry)
Definition DynamicEntryRpath.hpp:87
LIEF::ELF::DynamicEntryRpath::DynamicEntryRpath
DynamicEntryRpath(std::string rpath)
Definition DynamicEntryRpath.hpp:38
LIEF::ELF::DynamicEntryRpath::DynamicEntryRpath
DynamicEntryRpath()
Definition DynamicEntryRpath.hpp:34
LIEF::ELF::DynamicEntryRpath::clone
std::unique_ptr< DynamicEntry > clone() const override
Definition DynamicEntryRpath.hpp:53
LIEF::ELF::DynamicEntryRpath::~DynamicEntryRpath
~DynamicEntryRpath()=default
LIEF::ELF::DynamicEntryRpath::operator+=
DynamicEntryRpath & operator+=(std::string path)
Definition DynamicEntryRpath.hpp:79
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