RelocationResolver.h 1.9 KB

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