1 | //===- TextAPI/DylibReader.h - TAPI MachO Dylib Reader ----------*- 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 | /// Defines the MachO Dynamic Library Reader. |
10 | /// |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #ifndef LLVM_TEXTAPI_DYLIBREADER_H |
14 | #define LLVM_TEXTAPI_DYLIBREADER_H |
15 | |
16 | #include "llvm/ADT/StringMap.h" |
17 | #include "llvm/Support/Error.h" |
18 | #include "llvm/Support/MemoryBuffer.h" |
19 | #include "llvm/TextAPI/ArchitectureSet.h" |
20 | #include "llvm/TextAPI/RecordsSlice.h" |
21 | |
22 | namespace llvm::MachO::DylibReader { |
23 | |
24 | struct ParseOption { |
25 | /// Determines arch slice to parse. |
26 | ArchitectureSet Archs = ArchitectureSet::All(); |
27 | /// Capture Mach-O header from binary, primarily load commands. |
28 | bool = true; |
29 | /// Capture defined symbols out of export trie and n-list. |
30 | bool SymbolTable = true; |
31 | /// Capture undefined symbols too. |
32 | bool Undefineds = true; |
33 | }; |
34 | |
35 | /// Parse Mach-O dynamic libraries to extract TAPI attributes. |
36 | /// |
37 | /// \param Buffer Data that points to dylib. |
38 | /// \param Options Determines which attributes to extract. |
39 | /// \return List of record slices. |
40 | Expected<Records> readFile(MemoryBufferRef Buffer, const ParseOption &Opt); |
41 | |
42 | /// Get TAPI file representation of binary dylib. |
43 | /// |
44 | /// \param Buffer Data that points to dylib. |
45 | Expected<std::unique_ptr<InterfaceFile>> get(MemoryBufferRef Buffer); |
46 | |
47 | using SymbolToSourceLocMap = llvm::StringMap<RecordLoc>; |
48 | /// Get the source location for each symbol from dylib. |
49 | /// |
50 | /// \param DSYM Path to DSYM file. |
51 | /// \param T Requested target slice for dylib. |
52 | SymbolToSourceLocMap accumulateSourceLocFromDSYM(const StringRef DSYM, |
53 | const Target &T); |
54 | |
55 | } // namespace llvm::MachO::DylibReader |
56 | |
57 | #endif // LLVM_TEXTAPI_DYLIBREADER_H |
58 | |