LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
DyldBindingInfo.hpp
Go to the documentation of this file.
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_DYLD_INFO_BINDING_INFO_H
17#define LIEF_MACHO_DYLD_INFO_BINDING_INFO_H
18#include <ostream>
19#include <cstdint>
20
21#include "LIEF/visibility.h"
23
24namespace LIEF {
25namespace MachO {
35 friend class BinaryParser;
36
37 public:
38 enum class CLASS: uint64_t {
39 WEAK = 1u,
40 LAZY = 2u,
41 STANDARD = 3u,
42 THREADED = 100u
43 };
44
45 enum class TYPE: uint64_t {
46 POINTER = 1u,
47 TEXT_ABSOLUTE32 = 2u,
48 TEXT_PCREL32 = 3u
49 };
50
51 public:
52 DyldBindingInfo() = default;
53 DyldBindingInfo(CLASS cls, TYPE type,
54 uint64_t address, int64_t addend = 0,
55 int32_t oridnal = 0, bool is_weak = false,
56 bool is_non_weak_definition = false, uint64_t offset = 0);
57
58 DyldBindingInfo& operator=(const DyldBindingInfo& other) = default;
59 DyldBindingInfo(const DyldBindingInfo& other) = default;
60
61 DyldBindingInfo(DyldBindingInfo&&) noexcept = default;
62
63 void swap(DyldBindingInfo& other) noexcept;
64 CLASS binding_class() const {
67 return class_;
68 }
69 void binding_class(CLASS bind_class) {
70 class_ = bind_class;
71 }
72 TYPE binding_type() const {
75 return binding_type_;
76 }
77
78 void binding_type(TYPE type) {
79 binding_type_ = type;
80 }
81
83 return this->is_non_weak_definition_;
84 }
85
86 void set_non_weak_definition(bool val) {
87 this->is_non_weak_definition_ = val;
88 }
89 uint64_t original_offset() const {
92 return offset_;
93 }
94
95 BindingInfo::TYPES type() const override {
96 return BindingInfo::TYPES::DYLD_INFO;
97 }
98
99 static bool classof(const BindingInfo* info) {
100 return info->type() == BindingInfo::TYPES::DYLD_INFO;
101 }
102
103 ~DyldBindingInfo() override = default;
104
105 void accept(Visitor& visitor) const override;
106
107 LIEF_API friend
108 std::ostream& operator<<(std::ostream& os, const DyldBindingInfo& info) {
109 os << static_cast<const BindingInfo&>(info);
110 return os;
111 }
112
113 private:
114 CLASS class_ = CLASS::STANDARD;
115 TYPE binding_type_ = TYPE::POINTER;
116 bool is_non_weak_definition_ = false;
117 uint64_t offset_ = 0;
118};
119
120LIEF_API const char* to_string(DyldBindingInfo::CLASS e);
121LIEF_API const char* to_string(DyldBindingInfo::TYPE e);
122
123}
124}
125#endif
BindingInfo.hpp
LIEF::MachO::BindingInfo
Class that provides an interface over a binding operation.
Definition BindingInfo.hpp:39
LIEF::MachO::DyldBindingInfo
This class represents a symbol binding operation associated with the LC_DYLD_INFO bytecode.
Definition DyldBindingInfo.hpp:34
LIEF::MachO::DyldBindingInfo::original_offset
uint64_t original_offset() const
Original relative offset of the binding opcodes.
Definition DyldBindingInfo.hpp:91
LIEF::MachO::DyldBindingInfo::classof
static bool classof(const BindingInfo *info)
Definition DyldBindingInfo.hpp:99
LIEF::MachO::DyldBindingInfo::DyldBindingInfo
DyldBindingInfo()=default
LIEF::MachO::DyldBindingInfo::accept
void accept(Visitor &visitor) const override
LIEF::MachO::DyldBindingInfo::operator=
DyldBindingInfo & operator=(const DyldBindingInfo &other)=default
LIEF::MachO::DyldBindingInfo::DyldBindingInfo
DyldBindingInfo(const DyldBindingInfo &other)=default
LIEF::MachO::DyldBindingInfo::DyldBindingInfo
DyldBindingInfo(CLASS cls, TYPE type, uint64_t address, int64_t addend=0, int32_t oridnal=0, bool is_weak=false, bool is_non_weak_definition=false, uint64_t offset=0)
LIEF::MachO::DyldBindingInfo::operator<<
friend std::ostream & operator<<(std::ostream &os, const DyldBindingInfo &info)
Definition DyldBindingInfo.hpp:108
LIEF::MachO::DyldBindingInfo::binding_type
void binding_type(TYPE type)
Definition DyldBindingInfo.hpp:78
LIEF::MachO::DyldBindingInfo::CLASS
CLASS
Definition DyldBindingInfo.hpp:38
LIEF::MachO::DyldBindingInfo::~DyldBindingInfo
~DyldBindingInfo() override=default
LIEF::MachO::DyldBindingInfo::type
BindingInfo::TYPES type() const override
The type of the binding. This type provides the origin of the binding (LC_DYLD_INFO or LC_DYLD_CHAINE...
Definition DyldBindingInfo.hpp:95
LIEF::MachO::DyldBindingInfo::is_non_weak_definition
bool is_non_weak_definition() const
Definition DyldBindingInfo.hpp:82
LIEF::MachO::DyldBindingInfo::TYPE
TYPE
Definition DyldBindingInfo.hpp:45
LIEF::MachO::DyldBindingInfo::set_non_weak_definition
void set_non_weak_definition(bool val)
Definition DyldBindingInfo.hpp:86
LIEF::MachO::DyldBindingInfo::binding_class
void binding_class(CLASS bind_class)
Definition DyldBindingInfo.hpp:69
LIEF::MachO::DyldBindingInfo::binding_type
TYPE binding_type() const
Type of the binding. Most of the times it's TYPE::POINTER.
Definition DyldBindingInfo.hpp:74
LIEF::MachO::DyldBindingInfo::DyldBindingInfo
DyldBindingInfo(DyldBindingInfo &&) noexcept=default
LIEF::MachO
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
LIEF::MachO::to_string
const char * to_string(BuildToolVersion::TOOLS tool)
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41