Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / tools / dsymutil / MachOUtils.h
blob059d9fdd788a66d4d97b9434425d025ca756c364
1 //===-- MachOUtils.h - Mach-o specific helpers for dsymutil --------------===//
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 #ifndef LLVM_TOOLS_DSYMUTIL_MACHOUTILS_H
9 #define LLVM_TOOLS_DSYMUTIL_MACHOUTILS_H
11 #include "SymbolMap.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Support/FileSystem.h"
15 #include "llvm/Support/VirtualFileSystem.h"
17 #include <string>
19 namespace llvm {
20 class MCStreamer;
21 class raw_fd_ostream;
22 namespace dsymutil {
23 class DebugMap;
24 struct LinkOptions;
25 namespace MachOUtils {
27 struct ArchAndFile {
28 std::string Arch;
29 std::string Path;
30 int FD = -1;
32 llvm::Error createTempFile();
33 llvm::StringRef getPath() const;
34 int getFD() const;
36 ArchAndFile(StringRef Arch) : Arch(std::string(Arch)) {}
37 ArchAndFile(ArchAndFile &&A) = default;
38 ArchAndFile &operator=(ArchAndFile &&A) = default;
39 ~ArchAndFile();
42 struct DwarfRelocationApplicationInfo {
43 // The position in the stream that should be patched, starting from the
44 // Dwarf's segment file address.
45 uint64_t AddressFromDwarfStart;
46 int32_t Value;
47 // If we should subtract the Dwarf segment's VM address from value before
48 // writing it.
49 bool ShouldSubtractDwarfVM;
51 DwarfRelocationApplicationInfo(uint64_t AddressFromDwarfVM, uint32_t Value,
52 bool ShouldSubtractDwarfVM)
53 : AddressFromDwarfStart(AddressFromDwarfVM), Value(Value),
54 ShouldSubtractDwarfVM(ShouldSubtractDwarfVM) {}
57 bool generateUniversalBinary(SmallVectorImpl<ArchAndFile> &ArchFiles,
58 StringRef OutputFileName, const LinkOptions &,
59 StringRef SDKPath, bool Fat64 = false);
60 bool generateDsymCompanion(
61 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, const DebugMap &DM,
62 SymbolMapTranslator &Translator, MCStreamer &MS, raw_fd_ostream &OutFile,
63 const std::vector<MachOUtils::DwarfRelocationApplicationInfo>
64 &RelocationsToApply);
66 std::string getArchName(StringRef Arch);
67 } // namespace MachOUtils
68 } // namespace dsymutil
69 } // namespace llvm
70 #endif // LLVM_TOOLS_DSYMUTIL_MACHOUTILS_H