xref: /llvm-project/llvm/include/llvm/TextAPI/DylibReader.h (revision a4de589d117a4fd52554da3c61ae6eb26c90a0c8)
1e3627e26SCyndy Ishida //===- TextAPI/DylibReader.h - TAPI MachO Dylib Reader ----------*- C++ -*-===//
2e3627e26SCyndy Ishida //
3e3627e26SCyndy Ishida // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4e3627e26SCyndy Ishida // See https://llvm.org/LICENSE.txt for license information.
5e3627e26SCyndy Ishida // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6e3627e26SCyndy Ishida //
7e3627e26SCyndy Ishida //===----------------------------------------------------------------------===//
8e3627e26SCyndy Ishida ///
9e3627e26SCyndy Ishida /// Defines the MachO Dynamic Library Reader.
10e3627e26SCyndy Ishida ///
11e3627e26SCyndy Ishida //===----------------------------------------------------------------------===//
12e3627e26SCyndy Ishida 
13e3627e26SCyndy Ishida #ifndef LLVM_TEXTAPI_DYLIBREADER_H
14e3627e26SCyndy Ishida #define LLVM_TEXTAPI_DYLIBREADER_H
15e3627e26SCyndy Ishida 
16*a4de589dSCyndy Ishida #include "llvm/ADT/StringMap.h"
17e3627e26SCyndy Ishida #include "llvm/Support/Error.h"
18e3627e26SCyndy Ishida #include "llvm/Support/MemoryBuffer.h"
19e3627e26SCyndy Ishida #include "llvm/TextAPI/ArchitectureSet.h"
20e3627e26SCyndy Ishida #include "llvm/TextAPI/RecordsSlice.h"
21e3627e26SCyndy Ishida 
22e3627e26SCyndy Ishida namespace llvm::MachO::DylibReader {
23e3627e26SCyndy Ishida 
24e3627e26SCyndy Ishida struct ParseOption {
25e3627e26SCyndy Ishida   /// Determines arch slice to parse.
26e3627e26SCyndy Ishida   ArchitectureSet Archs = ArchitectureSet::All();
27e3627e26SCyndy Ishida   /// Capture Mach-O header from binary, primarily load commands.
28e3627e26SCyndy Ishida   bool MachOHeader = true;
29e3627e26SCyndy Ishida   /// Capture defined symbols out of export trie and n-list.
30e3627e26SCyndy Ishida   bool SymbolTable = true;
31e3627e26SCyndy Ishida   /// Capture undefined symbols too.
32e3627e26SCyndy Ishida   bool Undefineds = true;
33e3627e26SCyndy Ishida };
34e3627e26SCyndy Ishida 
35e3627e26SCyndy Ishida /// Parse Mach-O dynamic libraries to extract TAPI attributes.
36e3627e26SCyndy Ishida ///
37e3627e26SCyndy Ishida /// \param Buffer Data that points to dylib.
38e3627e26SCyndy Ishida /// \param Options Determines which attributes to extract.
39e3627e26SCyndy Ishida /// \return List of record slices.
40e3627e26SCyndy Ishida Expected<Records> readFile(MemoryBufferRef Buffer, const ParseOption &Opt);
41e3627e26SCyndy Ishida 
425ea15fabSCyndy Ishida /// Get TAPI file representation of binary dylib.
435ea15fabSCyndy Ishida ///
445ea15fabSCyndy Ishida /// \param Buffer Data that points to dylib.
455ea15fabSCyndy Ishida Expected<std::unique_ptr<InterfaceFile>> get(MemoryBufferRef Buffer);
465ea15fabSCyndy Ishida 
47*a4de589dSCyndy Ishida using SymbolToSourceLocMap = llvm::StringMap<RecordLoc>;
48*a4de589dSCyndy Ishida /// Get the source location for each symbol from dylib.
49*a4de589dSCyndy Ishida ///
50*a4de589dSCyndy Ishida /// \param DSYM Path to DSYM file.
51*a4de589dSCyndy Ishida /// \param T Requested target slice for dylib.
52*a4de589dSCyndy Ishida SymbolToSourceLocMap accumulateSourceLocFromDSYM(const StringRef DSYM,
53*a4de589dSCyndy Ishida                                                  const Target &T);
54*a4de589dSCyndy Ishida 
55e3627e26SCyndy Ishida } // namespace llvm::MachO::DylibReader
56e3627e26SCyndy Ishida 
57e3627e26SCyndy Ishida #endif // LLVM_TEXTAPI_DYLIBREADER_H
58