#include "llvm/ADT/STLExtras.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/IRObjectFile.h"
#include "llvm/Object/MachO.h"
#include "llvm/Object/MachOUniversal.h"
#include "llvm/Object/MachOUniversalWriter.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileOutputBuffer.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/WithColor.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/TextAPI/Architecture.h"
#include <optional>
usingnamespacellvm;
usingnamespacellvm::object;
static const StringRef ToolName = …;
[[noreturn]] static void reportError(Twine Message) { … }
[[noreturn]] static void reportError(Error E) { … }
[[noreturn]] static void reportError(StringRef File, Error E) { … }
namespace {
enum LipoID { … };
namespace lipo {
#define PREFIX …
#include "LipoOpts.inc"
#undef PREFIX
usingnamespacellvm::opt;
static constexpr opt::OptTable::Info LipoInfoTable[] = …;
}
class LipoOptTable : public opt::GenericOptTable { … };
enum class LipoAction { … };
struct InputFile { … };
struct Config { … };
static Slice createSliceFromArchive(LLVMContext &LLVMCtx, const Archive &A) { … }
static Slice createSliceFromIR(const IRObjectFile &IRO, unsigned Align) { … }
}
static void validateArchitectureName(StringRef ArchitectureName) { … }
static Config parseLipoOptions(ArrayRef<const char *> ArgsArr) { … }
static SmallVector<OwningBinary<Binary>, 1>
readInputBinaries(LLVMContext &LLVMCtx, ArrayRef<InputFile> InputFiles) { … }
[[noreturn]] static void
verifyArch(ArrayRef<OwningBinary<Binary>> InputBinaries,
ArrayRef<std::string> VerifyArchList) { … }
static void printBinaryArchs(LLVMContext &LLVMCtx, const Binary *Binary,
raw_ostream &OS) { … }
[[noreturn]] static void
printArchs(LLVMContext &LLVMCtx, ArrayRef<OwningBinary<Binary>> InputBinaries) { … }
[[noreturn]] static void
printInfo(LLVMContext &LLVMCtx, ArrayRef<OwningBinary<Binary>> InputBinaries) { … }
[[noreturn]] static void thinSlice(LLVMContext &LLVMCtx,
ArrayRef<OwningBinary<Binary>> InputBinaries,
StringRef ArchType,
StringRef OutputFileName) { … }
static void checkArchDuplicates(ArrayRef<Slice> Slices) { … }
template <typename Range>
static void updateAlignments(Range &Slices,
const StringMap<const uint32_t> &Alignments) { … }
static void checkUnusedAlignments(ArrayRef<Slice> Slices,
const StringMap<const uint32_t> &Alignments) { … }
static SmallVector<Slice, 2>
buildSlices(LLVMContext &LLVMCtx, ArrayRef<OwningBinary<Binary>> InputBinaries,
const StringMap<const uint32_t> &Alignments,
SmallVectorImpl<std::unique_ptr<SymbolicFile>> &ExtractedObjects) { … }
[[noreturn]] static void
createUniversalBinary(LLVMContext &LLVMCtx,
ArrayRef<OwningBinary<Binary>> InputBinaries,
const StringMap<const uint32_t> &Alignments,
StringRef OutputFileName, FatHeaderType HeaderType) { … }
[[noreturn]] static void
extractSlice(LLVMContext &LLVMCtx, ArrayRef<OwningBinary<Binary>> InputBinaries,
const StringMap<const uint32_t> &Alignments, StringRef ArchType,
StringRef OutputFileName) { … }
static StringMap<Slice>
buildReplacementSlices(ArrayRef<OwningBinary<Binary>> ReplacementBinaries,
const StringMap<const uint32_t> &Alignments) { … }
[[noreturn]] static void
replaceSlices(LLVMContext &LLVMCtx,
ArrayRef<OwningBinary<Binary>> InputBinaries,
const StringMap<const uint32_t> &Alignments,
StringRef OutputFileName, ArrayRef<InputFile> ReplacementFiles) { … }
int llvm_lipo_main(int argc, char **argv, const llvm::ToolContext &) { … }