2020-04-03 02:54:05 +08:00
|
|
|
//===- Config.h -------------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_MACHO_CONFIG_H
|
|
|
|
#define LLD_MACHO_CONFIG_H
|
|
|
|
|
2020-05-06 07:37:34 +08:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2020-04-03 02:54:05 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2020-04-29 07:58:22 +08:00
|
|
|
#include "llvm/BinaryFormat/MachO.h"
|
2020-08-11 09:47:16 +08:00
|
|
|
#include "llvm/Support/VersionTuple.h"
|
2020-06-06 10:54:58 +08:00
|
|
|
#include "llvm/TextAPI/MachO/Architecture.h"
|
2020-08-11 09:47:16 +08:00
|
|
|
#include "llvm/TextAPI/MachO/Platform.h"
|
2020-04-03 02:54:05 +08:00
|
|
|
|
2020-04-22 04:37:57 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2020-04-03 02:54:05 +08:00
|
|
|
namespace lld {
|
|
|
|
namespace macho {
|
|
|
|
|
|
|
|
class Symbol;
|
2020-05-06 07:37:34 +08:00
|
|
|
struct SymbolPriorityEntry;
|
2020-04-03 02:54:05 +08:00
|
|
|
|
2020-08-11 09:47:16 +08:00
|
|
|
struct PlatformInfo {
|
|
|
|
llvm::MachO::PlatformKind kind;
|
|
|
|
llvm::VersionTuple minimum;
|
|
|
|
llvm::VersionTuple sdk;
|
|
|
|
};
|
|
|
|
|
2020-04-03 02:54:05 +08:00
|
|
|
struct Configuration {
|
2020-04-29 02:30:57 +08:00
|
|
|
Symbol *entry;
|
2020-04-24 11:16:49 +08:00
|
|
|
bool hasReexports = false;
|
2020-08-26 11:00:42 +08:00
|
|
|
bool allLoad = false;
|
2020-08-19 05:37:04 +08:00
|
|
|
bool forceLoadObjC = false;
|
2020-09-22 04:21:45 +08:00
|
|
|
bool staticLink = false;
|
2020-12-10 07:08:05 +08:00
|
|
|
bool implicitDylibs = false;
|
2020-09-06 01:55:33 +08:00
|
|
|
bool isPic = false;
|
2020-09-22 02:04:13 +08:00
|
|
|
bool headerPadMaxInstallNames = false;
|
2020-12-03 07:57:30 +08:00
|
|
|
bool printEachFile = false;
|
2020-12-03 07:59:00 +08:00
|
|
|
bool printWhyLoad = false;
|
2020-09-20 23:37:20 +08:00
|
|
|
bool searchDylibsFirst = false;
|
2020-10-27 10:18:29 +08:00
|
|
|
bool saveTemps = false;
|
2020-07-31 05:28:45 +08:00
|
|
|
uint32_t headerPad;
|
2020-04-29 07:58:22 +08:00
|
|
|
llvm::StringRef installName;
|
|
|
|
llvm::StringRef outputFile;
|
2020-12-03 12:34:17 +08:00
|
|
|
llvm::StringRef ltoObjPath;
|
clang+lld: Improve clang+ld.darwinnew.lld interaction, pass -demangle
This patch:
- adds an ld64.lld.darwinnew symlink for lld, to go with f2710d4b576,
so that `clang -fuse-ld=lld.darwinnew` can be used to test new
Mach-O lld while it's in bring-up. (The expectation is that we'll
remove this again once new Mach-O lld is the defauld and only Mach-O
lld.)
- lets the clang driver know if the linker is lld (currently
only triggered if `-fuse-ld=lld` or `-fuse-ld=lld.darwinnew` is
passed). Currently only used for the next point, but could be used
to implement other features that need close coordination between
compiler and linker, e.g. having a diag for calling `clang++` instead
of `clang` when link errors are caused by a missing C++ stdlib.
- lets the clang driver pass `-demangle` to Mach-O lld (both old and
new), in addition to ld64
- implements -demangle for new Mach-O lld
- changes demangleItanium() to accept _Z, __Z, ___Z, ____Z prefixes
(and updates one test added in D68014). Mach-O has an extra
underscore for symbols, and the three (or, on Mach-O, four)
underscores are used for block names.
Differential Revision: https://reviews.llvm.org/D91884
2020-11-21 02:57:44 +08:00
|
|
|
bool demangle = false;
|
2020-06-06 10:54:58 +08:00
|
|
|
llvm::MachO::Architecture arch;
|
2020-08-11 09:47:16 +08:00
|
|
|
PlatformInfo platform;
|
2020-04-24 11:16:49 +08:00
|
|
|
llvm::MachO::HeaderFileType outputType;
|
2020-08-14 04:48:47 +08:00
|
|
|
std::vector<llvm::StringRef> systemLibraryRoots;
|
2020-06-18 10:59:27 +08:00
|
|
|
std::vector<llvm::StringRef> librarySearchPaths;
|
|
|
|
std::vector<llvm::StringRef> frameworkSearchPaths;
|
2020-08-13 10:50:28 +08:00
|
|
|
std::vector<llvm::StringRef> runtimePaths;
|
2020-05-06 07:37:34 +08:00
|
|
|
llvm::DenseMap<llvm::StringRef, SymbolPriorityEntry> priorities;
|
|
|
|
};
|
|
|
|
|
|
|
|
// The symbol with the highest priority should be ordered first in the output
|
|
|
|
// section (modulo input section contiguity constraints). Using priority
|
|
|
|
// (highest first) instead of order (lowest first) has the convenient property
|
|
|
|
// that the default-constructed zero priority -- for symbols/sections without a
|
|
|
|
// user-defined order -- naturally ends up putting them at the end of the
|
|
|
|
// output.
|
|
|
|
struct SymbolPriorityEntry {
|
|
|
|
// The priority given to a matching symbol, regardless of which object file
|
|
|
|
// it originated from.
|
|
|
|
size_t anyObjectFile = 0;
|
|
|
|
// The priority given to a matching symbol from a particular object file.
|
|
|
|
llvm::DenseMap<llvm::StringRef, size_t> objectFiles;
|
2020-04-03 02:54:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
extern Configuration *config;
|
|
|
|
|
|
|
|
} // namespace macho
|
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif
|