16#ifndef LIEF_MACHO_RELOCATION_COMMAND_H
17#define LIEF_MACHO_RELOCATION_COMMAND_H
21#include "LIEF/Abstract/Relocation.hpp"
23#include "LIEF/MachO/Header.hpp"
24#include "LIEF/visibility.h"
25#include "LIEF/Object.hpp"
55 static constexpr auto R_SCATTERED = uint32_t(0x80000000);
56 static constexpr auto R_ABS = uint32_t(0);
67 virtual std::unique_ptr<Relocation> clone()
const = 0;
86 virtual uint8_t
type()
const {
100 return symbol() !=
nullptr;
108 const Symbol* symbol()
const {
114 return section() !=
nullptr;
122 const Section* section()
const {
128 return segment() !=
nullptr;
140 virtual void pc_relative(
bool val) = 0;
141 virtual void type(uint8_t type);
143 void accept(
Visitor& visitor)
const override;
145 virtual std::ostream& print(std::ostream& os)
const;
147 LIEF_API
friend std::ostream& operator<<(std::ostream& os,
const Relocation& relocation);
150 Symbol* symbol_ =
nullptr;
152 Header::CPU_TYPE architecture_ = Header::CPU_TYPE::ANY;
154 SegmentCommand* segment_ =
nullptr;
158LIEF_API
const char* to_string(Relocation::ORIGIN e);
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:73
Class that represents a Mach-O relocation.
Definition MachO/Relocation.hpp:40
Header::CPU_TYPE architecture() const
Achitecture targeted by this relocation.
Definition MachO/Relocation.hpp:91
SegmentCommand * segment()
SegmentCommand associated with the relocation, if any, otherwise a nullptr.
Definition MachO/Relocation.hpp:133
virtual bool is_pc_relative() const =0
Indicates whether the item containing the address to be relocated is part of a CPU instruction that u...
Section * section()
Section associated with the relocation, if any, otherwise a nullptr.
Definition MachO/Relocation.hpp:119
bool has_symbol() const
true if the relocation has a symbol associated with
Definition MachO/Relocation.hpp:99
virtual ORIGIN origin() const =0
Origin of the relocation.
bool has_segment() const
true if the relocation has a SegmentCommand associated with
Definition MachO/Relocation.hpp:127
bool has_section() const
true if the relocation has a section associated with
Definition MachO/Relocation.hpp:113
virtual uint8_t type() const
Type of the relocation according to the Relocation::architecture and/or the Relocation::origin.
Definition MachO/Relocation.hpp:86
Symbol * symbol()
Symbol associated with the relocation, if any, otherwise a nullptr.
Definition MachO/Relocation.hpp:105
Class that represents a Mach-O section.
Definition MachO/Section.hpp:44
Class which represents a LoadCommand::TYPE::SEGMENT / LoadCommand::TYPE::SEGMENT_64 command.
Definition SegmentCommand.hpp:48
Class that represents a Symbol in a Mach-O file.
Definition MachO/Symbol.hpp:47
Class which represents an abstracted Relocation.
Definition Abstract/Relocation.hpp:27
virtual size_t size() const
Relocation size in bits
virtual uint64_t address() const
Relocation's address.
Class which represents an abstracted section.
Definition Abstract/Section.hpp:29
This class represents a symbol in an executable format.
Definition Abstract/Symbol.hpp:28
Definition Visitor.hpp:219
LIEF namespace.
Definition Abstract/Binary.hpp:32