Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 1 | //===- RelocVisitor.h - Visitor for object file relocations -----*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file provides a wrapper around all the different types of relocations |
| 10 | // in different file formats, such that a client can handle them in a unified |
| 11 | // manner by only implementing a minimal number of functions. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_OBJECT_RELOCVISITOR_H |
| 16 | #define LLVM_OBJECT_RELOCVISITOR_H |
| 17 | |
| 18 | #include "llvm/ADT/Triple.h" |
| 19 | #include "llvm/BinaryFormat/ELF.h" |
| 20 | #include "llvm/BinaryFormat/MachO.h" |
| 21 | #include "llvm/Object/COFF.h" |
| 22 | #include "llvm/Object/ELFObjectFile.h" |
| 23 | #include "llvm/Object/MachO.h" |
| 24 | #include "llvm/Object/ObjectFile.h" |
| 25 | #include "llvm/Object/Wasm.h" |
| 26 | #include "llvm/Support/Casting.h" |
| 27 | #include "llvm/Support/ErrorHandling.h" |
| 28 | #include <cstdint> |
| 29 | #include <system_error> |
| 30 | |
| 31 | namespace llvm { |
| 32 | namespace object { |
| 33 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 34 | using SupportsRelocation = bool (*)(uint64_t); |
| 35 | using RelocationResolver = uint64_t (*)(uint64_t Type, uint64_t Offset, |
| 36 | uint64_t S, uint64_t LocData, |
| 37 | int64_t Addend); |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 38 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 39 | std::pair<SupportsRelocation, RelocationResolver> |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 40 | getRelocationResolver(const ObjectFile &Obj); |
| 41 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 42 | uint64_t resolveRelocation(RelocationResolver Resolver, const RelocationRef &R, |
| 43 | uint64_t S, uint64_t LocData); |
| 44 | |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 45 | } // end namespace object |
| 46 | } // end namespace llvm |
| 47 | |
| 48 | #endif // LLVM_OBJECT_RELOCVISITOR_H |