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