2015-08-05 18:27:44 +00:00
|
|
|
//===-- MachOUtils.h - Mach-o specific helpers for dsymutil --------------===//
|
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-08-05 18:27:44 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_TOOLS_DSYMUTIL_MACHOUTILS_H
|
|
|
|
#define LLVM_TOOLS_DSYMUTIL_MACHOUTILS_H
|
|
|
|
|
2019-01-07 23:27:25 +00:00
|
|
|
#include "SymbolMap.h"
|
|
|
|
|
2015-08-05 18:27:44 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2018-07-29 14:56:15 +00:00
|
|
|
#include "llvm/Support/FileSystem.h"
|
2020-05-05 03:19:15 +00:00
|
|
|
#include "llvm/Support/VirtualFileSystem.h"
|
2019-01-07 23:27:25 +00:00
|
|
|
|
2018-02-22 11:32:51 +00:00
|
|
|
#include <string>
|
2015-08-05 18:27:44 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
2015-09-02 16:49:13 +00:00
|
|
|
class MCStreamer;
|
|
|
|
class raw_fd_ostream;
|
2015-08-05 18:27:44 +00:00
|
|
|
namespace dsymutil {
|
2015-09-02 16:49:13 +00:00
|
|
|
class DebugMap;
|
2015-08-05 18:27:44 +00:00
|
|
|
struct LinkOptions;
|
|
|
|
namespace MachOUtils {
|
|
|
|
|
2018-07-29 14:56:15 +00:00
|
|
|
struct ArchAndFile {
|
|
|
|
std::string Arch;
|
2023-08-17 18:35:40 +00:00
|
|
|
std::string Path;
|
|
|
|
int FD = -1;
|
2018-07-29 14:56:15 +00:00
|
|
|
|
|
|
|
llvm::Error createTempFile();
|
2023-08-17 18:35:40 +00:00
|
|
|
llvm::StringRef getPath() const;
|
|
|
|
int getFD() const;
|
2018-07-29 14:56:15 +00:00
|
|
|
|
2020-01-28 19:23:46 +00:00
|
|
|
ArchAndFile(StringRef Arch) : Arch(std::string(Arch)) {}
|
2018-07-29 14:56:15 +00:00
|
|
|
ArchAndFile(ArchAndFile &&A) = default;
|
2019-06-05 17:14:32 +00:00
|
|
|
ArchAndFile &operator=(ArchAndFile &&A) = default;
|
2018-07-29 14:56:15 +00:00
|
|
|
~ArchAndFile();
|
2015-08-05 18:27:44 +00:00
|
|
|
};
|
|
|
|
|
2022-02-25 18:20:02 +00:00
|
|
|
struct DwarfRelocationApplicationInfo {
|
|
|
|
// The position in the stream that should be patched, starting from the
|
|
|
|
// Dwarf's segment file address.
|
|
|
|
uint64_t AddressFromDwarfStart;
|
|
|
|
int32_t Value;
|
|
|
|
// If we should subtract the Dwarf segment's VM address from value before
|
|
|
|
// writing it.
|
|
|
|
bool ShouldSubtractDwarfVM;
|
|
|
|
|
|
|
|
DwarfRelocationApplicationInfo(uint64_t AddressFromDwarfVM, uint32_t Value,
|
|
|
|
bool ShouldSubtractDwarfVM)
|
|
|
|
: AddressFromDwarfStart(AddressFromDwarfVM), Value(Value),
|
|
|
|
ShouldSubtractDwarfVM(ShouldSubtractDwarfVM) {}
|
|
|
|
};
|
|
|
|
|
2018-07-29 14:56:15 +00:00
|
|
|
bool generateUniversalBinary(SmallVectorImpl<ArchAndFile> &ArchFiles,
|
2015-10-08 22:35:53 +00:00
|
|
|
StringRef OutputFileName, const LinkOptions &,
|
2023-03-27 16:25:21 +00:00
|
|
|
StringRef SDKPath, bool Fat64 = false);
|
2022-02-25 18:20:02 +00:00
|
|
|
bool generateDsymCompanion(
|
|
|
|
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, const DebugMap &DM,
|
|
|
|
SymbolMapTranslator &Translator, MCStreamer &MS, raw_fd_ostream &OutFile,
|
|
|
|
const std::vector<MachOUtils::DwarfRelocationApplicationInfo>
|
|
|
|
&RelocationsToApply);
|
2015-09-02 16:49:13 +00:00
|
|
|
|
2015-08-25 23:15:26 +00:00
|
|
|
std::string getArchName(StringRef Arch);
|
2018-02-22 11:32:51 +00:00
|
|
|
} // namespace MachOUtils
|
|
|
|
} // namespace dsymutil
|
|
|
|
} // namespace llvm
|
2015-08-05 18:27:44 +00:00
|
|
|
#endif // LLVM_TOOLS_DSYMUTIL_MACHOUTILS_H
|