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