RelocationResolver.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #ifndef LLVM_OBJECT_RELOCATIONRESOLVER_H
  15. #define LLVM_OBJECT_RELOCATIONRESOLVER_H
  16. #include "llvm/ADT/Triple.h"
  17. #include "llvm/BinaryFormat/ELF.h"
  18. #include "llvm/BinaryFormat/MachO.h"
  19. #include "llvm/Object/COFF.h"
  20. #include "llvm/Object/ELFObjectFile.h"
  21. #include "llvm/Object/MachO.h"
  22. #include "llvm/Object/ObjectFile.h"
  23. #include "llvm/Object/Wasm.h"
  24. #include "llvm/Support/Casting.h"
  25. #include "llvm/Support/ErrorHandling.h"
  26. #include <cstdint>
  27. #include <system_error>
  28. namespace llvm {
  29. namespace object {
  30. using SupportsRelocation = bool (*)(uint64_t);
  31. using RelocationResolver = uint64_t (*)(uint64_t Type, uint64_t Offset,
  32. uint64_t S, uint64_t LocData,
  33. int64_t Addend);
  34. std::pair<SupportsRelocation, RelocationResolver>
  35. getRelocationResolver(const ObjectFile &Obj);
  36. uint64_t resolveRelocation(RelocationResolver Resolver, const RelocationRef &R,
  37. uint64_t S, uint64_t LocData);
  38. } // end namespace object
  39. } // end namespace llvm
  40. #endif // LLVM_OBJECT_RELOCATIONRESOLVER_H