2020-04-03 02:54:05 +08:00
|
|
|
//===- Driver.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_DRIVER_H
|
|
|
|
#define LLD_MACHO_DRIVER_H
|
|
|
|
|
|
|
|
#include "lld/Common/LLVM.h"
|
2020-11-19 01:31:47 +08:00
|
|
|
#include "llvm/ADT/Optional.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
2020-04-03 02:54:05 +08:00
|
|
|
#include "llvm/Option/OptTable.h"
|
2020-11-19 01:31:47 +08:00
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
2020-04-03 02:54:05 +08:00
|
|
|
|
[lld-macho] Change loadReexport to handle the case where a TAPI re-exports to reference documents nested within other TBD.
Currently, it was delibrately impleneted to not handle this case, but as it has turnt out, we need this feature.
The concrete use case is
`System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa` reexports
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit , which then rexports
/System/Library/PrivateFrameworks/UIFoundation.framework/Versions/A/UIFoundation
The current implemention uses a global currentTopLevelTapi, which is not reset until it finishes loading the whole tree.
This is a problem because if the top-level is set to Cocoa, then when we get to UIFoundation, it will try to find UIFoundation in the current top level, which is Cocoa and will not find it.
The right thing should be:
- When loading a library from a TBD file, re-exports need to be looked up in the auxiliary documents within the same TBD.
- When loading from an actual dylib, no additional TBD documents need to be examined.
- In no case does a re-export mentioned in one TBD file need to be looked up in a document in an auxiliary document from a different TBD file
Differential Revision: https://reviews.llvm.org/D97438
2021-02-25 12:47:22 +08:00
|
|
|
namespace llvm {
|
|
|
|
namespace MachO {
|
|
|
|
class InterfaceFile;
|
|
|
|
} // namespace MachO
|
|
|
|
} // namespace llvm
|
|
|
|
|
2020-04-03 02:54:05 +08:00
|
|
|
namespace lld {
|
|
|
|
namespace macho {
|
|
|
|
|
2020-11-19 01:31:47 +08:00
|
|
|
class DylibFile;
|
2020-12-03 07:59:00 +08:00
|
|
|
class InputFile;
|
2020-11-19 01:31:47 +08:00
|
|
|
|
2020-04-03 02:54:05 +08:00
|
|
|
class MachOOptTable : public llvm::opt::OptTable {
|
|
|
|
public:
|
|
|
|
MachOOptTable();
|
|
|
|
llvm::opt::InputArgList parse(ArrayRef<const char *> argv);
|
2020-06-16 03:36:32 +08:00
|
|
|
void printHelp(const char *argv0, bool showHidden) const;
|
2020-04-03 02:54:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// Create enum with OPT_xxx values for each option in Options.td
|
|
|
|
enum {
|
|
|
|
OPT_INVALID = 0,
|
|
|
|
#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID,
|
|
|
|
#include "Options.inc"
|
|
|
|
#undef OPTION
|
|
|
|
};
|
|
|
|
|
2020-12-04 05:40:04 +08:00
|
|
|
void parseLCLinkerOption(InputFile*, unsigned argc, StringRef data);
|
|
|
|
|
2020-11-29 11:38:27 +08:00
|
|
|
std::string createResponseFile(const llvm::opt::InputArgList &args);
|
|
|
|
|
2020-11-19 01:31:47 +08:00
|
|
|
// Check for both libfoo.dylib and libfoo.tbd (in that order).
|
|
|
|
llvm::Optional<std::string> resolveDylibPath(llvm::StringRef path);
|
|
|
|
|
2020-12-10 14:29:28 +08:00
|
|
|
llvm::Optional<DylibFile *> loadDylib(llvm::MemoryBufferRef mbref,
|
2021-02-23 02:03:02 +08:00
|
|
|
DylibFile *umbrella = nullptr,
|
|
|
|
bool isBundleLoader = false);
|
2020-11-19 01:31:47 +08:00
|
|
|
|
2021-02-04 02:31:42 +08:00
|
|
|
llvm::Optional<InputFile *> loadArchiveMember(MemoryBufferRef, uint32_t modTime,
|
|
|
|
StringRef archiveName,
|
|
|
|
bool objCOnly);
|
|
|
|
|
2020-12-02 06:45:11 +08:00
|
|
|
uint32_t getModTime(llvm::StringRef path);
|
|
|
|
|
2020-12-03 07:57:30 +08:00
|
|
|
void printArchiveMemberLoad(StringRef reason, const InputFile *);
|
2020-12-03 07:59:00 +08:00
|
|
|
|
2020-04-03 02:54:05 +08:00
|
|
|
} // namespace macho
|
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif
|