xref: /freebsd/contrib/llvm-project/llvm/include/llvm/Object/RelocationResolver.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
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 "llvm/Support/Compiler.h"
19 #include <cstdint>
20 #include <utility>
21 
22 namespace llvm {
23 namespace object {
24 
25 class ObjectFile;
26 class RelocationRef;
27 
28 using SupportsRelocation = bool (*)(uint64_t);
29 using RelocationResolver = uint64_t (*)(uint64_t Type, uint64_t Offset,
30                                         uint64_t S, uint64_t LocData,
31                                         int64_t Addend);
32 
33 LLVM_ABI std::pair<SupportsRelocation, RelocationResolver>
34 getRelocationResolver(const ObjectFile &Obj);
35 
36 LLVM_ABI uint64_t resolveRelocation(RelocationResolver Resolver,
37                                     const RelocationRef &R, uint64_t S,
38                                     uint64_t LocData);
39 
40 } // end namespace object
41 } // end namespace llvm
42 
43 #endif // LLVM_OBJECT_RELOCATIONRESOLVER_H
44