LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
RelocationObject.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 * Copyright 2017 - 2026 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_OBJECT_COMMAND_H
17#define LIEF_MACHO_RELOCATION_OBJECT_COMMAND_H
18#include <ostream>
19
20#include "LIEF/visibility.h"
21
23
24namespace LIEF {
25namespace MachO {
26
27class BinaryParser;
28
29namespace details {
30struct relocation_info;
31struct scattered_relocation_info;
32}
33
39
40 friend class BinaryParser;
41
42 public:
44 RelocationObject() = default;
45 RelocationObject(const details::relocation_info& relocinfo);
46 RelocationObject(const details::scattered_relocation_info& scattered_relocinfo);
47
49 RelocationObject(const RelocationObject& other) = default;
50
51 void swap(RelocationObject& other) noexcept;
52
53 ~RelocationObject() override = default;
54
55 std::unique_ptr<Relocation> clone() const override {
56 return std::unique_ptr<RelocationObject>(new RelocationObject(*this));
57 }
58
60 bool is_pc_relative() const override {
61 return is_pcrel_;
62 }
63
65 size_t size() const override;
66
70 uint64_t address() const override;
71
73 bool is_scattered() const {
74 return is_scattered_;
75 }
76
85 int32_t value() const;
86
89 ORIGIN origin() const override {
91 }
92
93 void pc_relative(bool val) override {
94 is_pcrel_ = val;
95 }
96 void size(size_t size) override;
97
98 void value(int32_t value);
99
100 void accept(Visitor& visitor) const override;
101
102 std::ostream& print(std::ostream& os) const override {
103 return Relocation::print(os);
104 }
105
106 static bool classof(const Relocation& r) {
108 }
109
110 private:
111 bool is_pcrel_ = false;
112 bool is_scattered_ = false;
113 int32_t value_ = 0;
114};
115
116}
117}
118#endif
Class used to parse a single binary (i.e. non-FAT).
Definition BinaryParser.hpp:78
void value(int32_t value)
bool is_scattered() const
true if the relocation is a scattered one
Definition RelocationObject.hpp:73
friend class BinaryParser
Definition RelocationObject.hpp:40
static bool classof(const Relocation &r)
Definition RelocationObject.hpp:106
std::unique_ptr< Relocation > clone() const override
Definition RelocationObject.hpp:55
void size(size_t size) override
void swap(RelocationObject &other) noexcept
void pc_relative(bool val) override
Definition RelocationObject.hpp:93
int32_t value() const
For scattered relocations: The address of the relocatable expression for the item in the file that ne...
RelocationObject & operator=(const RelocationObject &other)=default
bool is_pc_relative() const override
Whether the relocation is PC relative.
Definition RelocationObject.hpp:60
uint64_t address() const override
Address where the relocation is applied This address is relative to the start of the section where th...
size_t size() const override
Size of the relocation.
RelocationObject(const details::scattered_relocation_info &scattered_relocinfo)
RelocationObject(const RelocationObject &other)=default
void accept(Visitor &visitor) const override
~RelocationObject() override=default
ORIGIN origin() const override
Origin of the relocation. For this object it should be Relocation::ORIGIN::RELOC_TABLE).
Definition RelocationObject.hpp:89
std::ostream & print(std::ostream &os) const override
Definition RelocationObject.hpp:102
RelocationObject(const details::relocation_info &relocinfo)
virtual ORIGIN origin() const =0
Origin of the relocation.
ORIGIN
Definition MachO/Relocation.hpp:48
@ RELOC_TABLE
Definition MachO/Relocation.hpp:51
virtual std::ostream & print(std::ostream &os) const
Definition Visitor.hpp:212
Definition endianness_support.hpp:60
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:43