ELFObjHandler.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- ELFObjHandler.h ------------------------------------------*- 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. /// \file
  14. /// This supports reading and writing of elf dynamic shared objects.
  15. ///
  16. //===-----------------------------------------------------------------------===/
  17. #ifndef LLVM_INTERFACESTUB_ELFOBJHANDLER_H
  18. #define LLVM_INTERFACESTUB_ELFOBJHANDLER_H
  19. #include "llvm/ADT/StringRef.h"
  20. #include "llvm/Support/Error.h"
  21. #include "llvm/Support/MemoryBufferRef.h"
  22. #include <memory>
  23. namespace llvm {
  24. namespace ifs {
  25. struct IFSStub;
  26. /// Attempt to read a binary ELF file from a MemoryBuffer.
  27. Expected<std::unique_ptr<IFSStub>> readELFFile(MemoryBufferRef Buf);
  28. /// Attempt to write a binary ELF stub.
  29. /// This function determines appropriate ELFType using the passed ELFTarget and
  30. /// then writes a binary ELF stub to a specified file path.
  31. ///
  32. /// @param FilePath File path for writing the ELF binary.
  33. /// @param Stub Source ELFStub to generate a binary ELF stub from.
  34. /// @param WriteIfChanged Whether or not to preserve timestamp if
  35. /// the output stays the same.
  36. Error writeBinaryStub(StringRef FilePath, const IFSStub &Stub,
  37. bool WriteIfChanged = false);
  38. } // end namespace ifs
  39. } // end namespace llvm
  40. #endif // LLVM_INTERFACESTUB_ELFOBJHANDLER_H
  41. #ifdef __GNUC__
  42. #pragma GCC diagnostic pop
  43. #endif