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_RELOCATIONRESOLVER_H
16 #define LLVM_OBJECT_RELOCATIONRESOLVER_H
17 
18 #include <cstdint>
19 #include <utility>
20 
21 namespace llvm {
22 namespace object {
23 
24 class ObjectFile;
25 class RelocationRef;
26 
27 using SupportsRelocation = bool (*)(uint64_t);
28 using RelocationResolver = uint64_t (*)(uint64_t Type, uint64_t Offset,
29                                         uint64_t S, uint64_t LocData,
30                                         int64_t Addend);
31 
32 std::pair<SupportsRelocation, RelocationResolver>
33 getRelocationResolver(const ObjectFile &Obj);
34 
35 uint64_t resolveRelocation(RelocationResolver Resolver, const RelocationRef &R,
36                            uint64_t S, uint64_t LocData);
37 
38 } // end namespace object
39 } // end namespace llvm
40 
41 #endif // LLVM_OBJECT_RELOCATIONRESOLVER_H
42