LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
Abstract/Relocation.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_ABSTRACT_RELOCATION_H
17#define LIEF_ABSTRACT_RELOCATION_H
18
19#include <ostream>
20#include <cstdint>
21
22#include "LIEF/Object.hpp"
23#include "LIEF/visibility.h"
24
25namespace LIEF {class LIEF_API Relocation : public Object {
28
29 public:
30 Relocation() = default;
31 Relocation(uint64_t address, uint8_t size) :
34 address_(address),
35 size_(size)
36 {}
37
38 ~Relocation() override = default;
39
40 Relocation& operator=(const Relocation&) = default;
41 Relocation(const Relocation&) = default;
42 void swap(Relocation& other) {
43 std::swap(address_, other.address_);
44 std::swap(size_, other.size_);
45 }
46 virtual uint64_t address() const {
49 return address_;
50 }
51 virtual size_t size() const {
54 return size_;
55 }
56
57 virtual void address(uint64_t address) {
58 address_ = address;
59 }
60
61 virtual void size(size_t size) {
62 size_ = (uint8_t)size;
63 }
64 void accept(Visitor& visitor) const override;
67
68 virtual bool operator<(const Relocation& rhs) const {
71 return address() < rhs.address();
72 }
73 virtual bool operator<=(const Relocation& rhs) const {
76 return !(address() > rhs.address());
77 }
78 virtual bool operator>(const Relocation& rhs) const {
81 return address() > rhs.address();
82 }
83 virtual bool operator>=(const Relocation& rhs) const {
86 return !(address() < rhs.address());
87 }
88
89 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Relocation& entry);
90
91 protected:
92 uint64_t address_ = 0;
93 uint8_t size_ = 0;
94};
95
96
97}
98#endif
Object.hpp
LIEF::Object
Definition Object.hpp:25
LIEF::Relocation
Class which represents an abstracted Relocation.
Definition Abstract/Relocation.hpp:27
LIEF::Relocation::operator<<
friend std::ostream & operator<<(std::ostream &os, const Relocation &entry)
LIEF::Relocation::swap
void swap(Relocation &other)
Definition Abstract/Relocation.hpp:42
LIEF::Relocation::Relocation
Relocation()=default
LIEF::Relocation::address
virtual void address(uint64_t address)
Definition Abstract/Relocation.hpp:57
LIEF::Relocation::operator=
Relocation & operator=(const Relocation &)=default
LIEF::Relocation::size
virtual void size(size_t size)
Definition Abstract/Relocation.hpp:61
LIEF::Relocation::Relocation
Relocation(const Relocation &)=default
LIEF::Relocation::operator<
virtual bool operator<(const Relocation &rhs) const
Comparaison based on the Relocation's address
Definition Abstract/Relocation.hpp:70
LIEF::Relocation::size
virtual size_t size() const
Relocation size in bits
Definition Abstract/Relocation.hpp:53
LIEF::Relocation::operator<=
virtual bool operator<=(const Relocation &rhs) const
Comparaison based on the Relocation's address
Definition Abstract/Relocation.hpp:75
LIEF::Relocation::operator>
virtual bool operator>(const Relocation &rhs) const
Comparaison based on the Relocation's address
Definition Abstract/Relocation.hpp:80
LIEF::Relocation::address
virtual uint64_t address() const
Relocation's address.
Definition Abstract/Relocation.hpp:48
LIEF::Relocation::operator>=
virtual bool operator>=(const Relocation &rhs) const
Comparaison based on the Relocation's address
Definition Abstract/Relocation.hpp:85
LIEF::Relocation::accept
void accept(Visitor &visitor) const override
Method so that the visitor can visit us.
LIEF::Relocation::Relocation
Relocation(uint64_t address, uint8_t size)
Constructor from a relocation's address and size.
Definition Abstract/Relocation.hpp:33
LIEF::Relocation::~Relocation
~Relocation() override=default
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41