LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
Abstract/Relocation.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_ABSTRACT_RELOCATION_H
16#define LIEF_ABSTRACT_RELOCATION_H
17
18#include <cstdint>
19#include <ostream>
20
21#include "LIEF/Object.hpp"
22#include "LIEF/visibility.h"
23
24namespace LIEF {
26class LIEF_API Relocation : public Object {
27
28 public:
29 Relocation() = default;
30
32 Relocation(uint64_t address, uint8_t size) :
33 address_(address),
34 size_(size) {}
35
36 ~Relocation() override = default;
37
38 Relocation& operator=(const Relocation&) = default;
39 Relocation(const Relocation&) = default;
40 void swap(Relocation& other) {
41 std::swap(address_, other.address_);
42 std::swap(size_, other.size_);
43 }
44
46 virtual uint64_t address() const {
47 return address_;
48 }
49
51 virtual size_t size() const {
52 return size_;
53 }
54
55 virtual void address(uint64_t address) {
56 address_ = address;
57 }
58
59 virtual void size(size_t size) {
60 size_ = (uint8_t)size;
61 }
62
64 void accept(Visitor& visitor) const override;
65
66
68 virtual bool operator<(const Relocation& rhs) const {
69 return address() < rhs.address();
70 }
71
73 virtual bool operator<=(const Relocation& rhs) const {
74 return !(address() > rhs.address());
75 }
76
78 virtual bool operator>(const Relocation& rhs) const {
79 return address() > rhs.address();
80 }
81
83 virtual bool operator>=(const Relocation& rhs) const {
84 return !(address() < rhs.address());
85 }
86
87 LIEF_API friend std::ostream& operator<<(std::ostream& os,
88 const Relocation& entry);
89
90 protected:
91 uint64_t address_ = 0;
92 uint8_t size_ = 0;
93};
94
95
96}
97#endif
Definition Object.hpp:24
friend std::ostream & operator<<(std::ostream &os, const Relocation &entry)
void swap(Relocation &other)
Definition Abstract/Relocation.hpp:40
Relocation()=default
virtual void address(uint64_t address)
Definition Abstract/Relocation.hpp:55
Relocation & operator=(const Relocation &)=default
virtual void size(size_t size)
Definition Abstract/Relocation.hpp:59
Relocation(const Relocation &)=default
virtual bool operator<(const Relocation &rhs) const
Comparison based on the Relocation's address.
Definition Abstract/Relocation.hpp:68
virtual size_t size() const
Relocation size in bits.
Definition Abstract/Relocation.hpp:51
virtual bool operator<=(const Relocation &rhs) const
Comparison based on the Relocation's address.
Definition Abstract/Relocation.hpp:73
virtual bool operator>(const Relocation &rhs) const
Comparison based on the Relocation's address.
Definition Abstract/Relocation.hpp:78
virtual uint64_t address() const
Relocation's address.
Definition Abstract/Relocation.hpp:46
virtual bool operator>=(const Relocation &rhs) const
Comparison based on the Relocation's address.
Definition Abstract/Relocation.hpp:83
void accept(Visitor &visitor) const override
Method so that the visitor can visit us.
Relocation(uint64_t address, uint8_t size)
Constructor from a relocation's address and size.
Definition Abstract/Relocation.hpp:32
~Relocation() override=default
Definition Visitor.hpp:211
LIEF namespace.
Definition Abstract/Binary.hpp:41
#define LIEF_API
Definition visibility.h:44