LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
RelocationDyld.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_MACHO_RELOCATION_DYLD_COMMAND_H
17#define LIEF_MACHO_RELOCATION_DYLD_COMMAND_H
18#include <ostream>
19
20#include "LIEF/visibility.h"
21
22#include "LIEF/MachO/Relocation.hpp"
23
24namespace LIEF {
25namespace MachO {
26
27class BinaryParser;
28
33class LIEF_API RelocationDyld : public Relocation {
34
35 friend class BinaryParser;
36
37 public:
38 using Relocation::Relocation;
39 RelocationDyld() = default;
40
41 RelocationDyld& operator=(const RelocationDyld&) = default;
42 RelocationDyld(const RelocationDyld&) = default;
43
44 ~RelocationDyld() override = default;
45
46 std::unique_ptr<Relocation> clone() const override {
47 return std::unique_ptr<RelocationDyld>(new RelocationDyld(*this));
48 }
49
55 bool is_pc_relative() const override;
56
59 Relocation::ORIGIN origin() const override {
60 return Relocation::ORIGIN::DYLDINFO;
61 }
62
63 void pc_relative(bool val) override;
64
65 bool operator<(const RelocationDyld& rhs) const;
66 bool operator>=(const RelocationDyld& rhs) const {
67 return !(*this < rhs);
68 }
69
70 bool operator>(const RelocationDyld& rhs) const;
71 bool operator<=(const RelocationDyld& rhs) const {
72 return !(*this > rhs);
73 }
74
75 void accept(Visitor& visitor) const override;
76
77 static bool classof(const Relocation& r) {
78 return r.origin() == Relocation::ORIGIN::DYLDINFO;
79 }
80
81 std::ostream& print(std::ostream& os) const override {
82 return Relocation::print(os);
83 }
84};
85
86}
87}
88#endif
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:73
Class that represents a relocation found in the DyldInfo structure.
Definition RelocationDyld.hpp:33
bool is_pc_relative() const override
Indicates whether the item containing the address to be relocated is part of a CPU instruction that u...
Relocation::ORIGIN origin() const override
Origin of the relocation. For this concrete object, it should be Relocation::ORIGIN::DYLDINFO.
Definition RelocationDyld.hpp:59
Class that represents a Mach-O relocation.
Definition MachO/Relocation.hpp:40
LIEF namespace.
Definition Abstract/Binary.hpp:32