LIEF: Library to Instrument Executable Formats Version 0.16.0
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
16#ifndef LIEF_MACHO_RELOCATION_COMMAND_H
17#define LIEF_MACHO_RELOCATION_COMMAND_H
42 friend class BinaryParser;
55 static constexpr auto R_SCATTERED = uint32_t(0x80000000);
56 static constexpr auto R_ABS = uint32_t(0);
63 void swap(Relocation& other)
noexcept;
67 virtual std::unique_ptr<Relocation>
clone()
const = 0;
75 virtual uint8_t
type()
const {
94 virtual ORIGIN
origin()
const = 0;
100 return symbol() !=
nullptr;
114 return section() !=
nullptr;
128 return segment() !=
nullptr;
142 static_assert(std::is_base_of<Relocation, T>::value,
"Require Relocation inheritance");
143 if (T::classof(*
this)) {
144 return static_cast<const T*
>(
this);
151 return const_cast<T*
>(
static_cast<const Relocation*
>(
this)->cast<T>());
155 virtual void type(uint8_t type);
157 void accept(Visitor& visitor)
const override;
159 virtual std::ostream&
print(std::ostream& os)
const;
164 Symbol* symbol_ =
nullptr;
166 Header::CPU_TYPE architecture_ = Header::CPU_TYPE::ANY;
167 Section* section_ =
nullptr;
168 SegmentCommand* segment_ =
nullptr;
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:74
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
const T * cast() const
Definition MachO/Relocation.hpp:141
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...
const Section * section() const
Definition MachO/Relocation.hpp:122
const SegmentCommand * segment() const
Definition MachO/Relocation.hpp:136
Relocation(uint64_t address, uint8_t type)
const Symbol * symbol() const
Definition MachO/Relocation.hpp:108
Section * section()
Section associated with the relocation, if any, otherwise a nullptr.
Definition MachO/Relocation.hpp:119
virtual std::unique_ptr< Relocation > clone() const =0
bool has_symbol() const
true if the relocation has a symbol associated with
Definition MachO/Relocation.hpp:99
void swap(Relocation &other) noexcept
virtual ORIGIN origin() const =0
Origin of the relocation.
ORIGIN
Definition MachO/Relocation.hpp:48
~Relocation() override=default
virtual std::ostream & print(std::ostream &os) const
bool has_segment() const
true if the relocation has a SegmentCommand associated with
Definition MachO/Relocation.hpp:127
void accept(Visitor &visitor) const override
bool has_section() const
true if the relocation has a section associated with
Definition MachO/Relocation.hpp:113
T * cast()
Definition MachO/Relocation.hpp:150
Relocation(const Relocation &other)
virtual void pc_relative(bool val)=0
Relocation & operator=(const Relocation &other)
friend std::ostream & operator<<(std::ostream &os, const Relocation &relocation)
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
virtual void type(uint8_t type)
Class that represents a Mach-O section.
Definition MachO/Section.hpp:46
Class which represents a LoadCommand::TYPE::SEGMENT / LoadCommand::TYPE::SEGMENT_64 command.
Definition SegmentCommand.hpp:50
Class that represents a Symbol in a Mach-O file.
Definition MachO/Symbol.hpp:47
virtual size_t size() const
Relocation size in bits
Definition Abstract/Relocation.hpp:53
virtual uint64_t address() const
Relocation's address.
Definition Abstract/Relocation.hpp:48
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
@ UNKNOWN
Definition MachO/enums.hpp:25
const char * to_string(BuildToolVersion::TOOLS tool)
LIEF namespace.
Definition Abstract/Binary.hpp:36
#define LIEF_API
Definition visibility.h:41