16#ifndef LIEF_MACHO_RELOCATION_FIXUP_H
17#define LIEF_MACHO_RELOCATION_FIXUP_H
21#include "LIEF/visibility.h"
23#include "LIEF/MachO/Relocation.hpp"
24#include "LIEF/MachO/DyldChainedFormat.hpp"
30struct dyld_chained_ptr_arm64e_rebase;
31struct dyld_chained_ptr_arm64e_auth_rebase;
32struct dyld_chained_ptr_64_rebase;
33struct dyld_chained_ptr_32_rebase;
66 std::unique_ptr<Relocation> clone()
const override {
77 Relocation::ORIGIN
origin()
const override {
78 return Relocation::ORIGIN::CHAINED_FIXUPS;
81 DYLD_CHAINED_PTR_FORMAT ptr_format()
const {
89 void target(uint64_t target);
94 uint32_t offset()
const {
98 void offset(uint32_t offset) {
104 return imagebase_ + offset_;
109 offset_ = address - imagebase_;
112 void accept(
Visitor& visitor)
const override;
115 return r.
origin() == Relocation::ORIGIN::CHAINED_FIXUPS;
118 std::ostream& print(std::ostream& os)
const override;
121 enum class REBASE_TYPES {
130 void set(
const details::dyld_chained_ptr_arm64e_rebase& fixup);
131 void set(
const details::dyld_chained_ptr_arm64e_auth_rebase& fixup);
132 void set(
const details::dyld_chained_ptr_64_rebase& fixup);
133 void set(
const details::dyld_chained_ptr_32_rebase& fixup);
135 DYLD_CHAINED_PTR_FORMAT ptr_fmt_ = DYLD_CHAINED_PTR_FORMAT::PTR_32;
136 uint64_t imagebase_ = 0;
137 uint32_t offset_ = 0;
139 REBASE_TYPES rtypes_ = REBASE_TYPES::UNKNOWN;
142 details::dyld_chained_ptr_arm64e_rebase* arm64_rebase_ =
nullptr;
143 details::dyld_chained_ptr_arm64e_auth_rebase* arm64_auth_rebase_;
144 details::dyld_chained_ptr_64_rebase* p64_rebase_;
145 details::dyld_chained_ptr_32_rebase* p32_rebase_;
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:73
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:54
Class that represents a rebase relocation found in the LC_DYLD_CHAINED_FIXUPS command.
Definition RelocationFixup.hpp:49
uint64_t target() const
The value that should be set at LIEF::Relocation::address if the imagebase is LIEF::Binary::imagebase...
void pc_relative(bool) override
Not relevant for this kind of relocation.
Definition RelocationFixup.hpp:92
Relocation::ORIGIN origin() const override
Origin of the relocation. For this concrete object, it should be Relocation::ORIGIN::CHAINED_FIXUPS.
Definition RelocationFixup.hpp:77
uint64_t address() const override
The address of this relocation is bound to its offset.
Definition RelocationFixup.hpp:103
bool is_pc_relative() const override
Not relevant for this kind of relocation.
Definition RelocationFixup.hpp:71
void address(uint64_t address) override
Changing the address means changing the offset.
Definition RelocationFixup.hpp:108
Class that represents a Mach-O relocation.
Definition MachO/Relocation.hpp:40
virtual ORIGIN origin() const =0
Origin of the relocation.
Definition Visitor.hpp:219
LIEF namespace.
Definition Abstract/Binary.hpp:32