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