2015-08-14 22:12:54 +08:00
|
|
|
//===- Driver.h -------------------------------------------------*- C++ -*-===//
|
2015-07-25 05:03:07 +08:00
|
|
|
//
|
|
|
|
// The LLVM Linker
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_ELF_DRIVER_H
|
|
|
|
#define LLD_ELF_DRIVER_H
|
|
|
|
|
2015-10-01 23:23:09 +08:00
|
|
|
#include "SymbolTable.h"
|
2017-10-03 05:00:41 +08:00
|
|
|
#include "lld/Common/LLVM.h"
|
|
|
|
#include "lld/Common/Reproduce.h"
|
2016-04-14 03:07:40 +08:00
|
|
|
#include "llvm/ADT/Optional.h"
|
2015-10-01 01:06:09 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2016-05-04 01:30:44 +08:00
|
|
|
#include "llvm/ADT/StringSet.h"
|
2015-07-25 05:03:07 +08:00
|
|
|
#include "llvm/Option/ArgList.h"
|
2016-02-03 06:49:32 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2015-07-25 05:03:07 +08:00
|
|
|
|
|
|
|
namespace lld {
|
2016-02-28 08:25:54 +08:00
|
|
|
namespace elf {
|
2015-07-25 05:03:07 +08:00
|
|
|
|
2015-10-01 23:23:09 +08:00
|
|
|
extern class LinkerDriver *Driver;
|
2015-10-01 01:06:09 +08:00
|
|
|
|
2015-07-25 05:03:07 +08:00
|
|
|
class LinkerDriver {
|
|
|
|
public:
|
2016-10-27 02:59:00 +08:00
|
|
|
void main(ArrayRef<const char *> Args, bool CanExitEarly);
|
2017-04-12 08:13:48 +08:00
|
|
|
void addFile(StringRef Path, bool WithLOption);
|
2016-02-03 05:13:09 +08:00
|
|
|
void addLibrary(StringRef Name);
|
2016-05-04 01:30:44 +08:00
|
|
|
|
2015-07-25 05:03:07 +08:00
|
|
|
private:
|
2016-01-08 01:54:21 +08:00
|
|
|
void readConfigs(llvm::opt::InputArgList &Args);
|
|
|
|
void createFiles(llvm::opt::InputArgList &Args);
|
2016-10-20 12:47:47 +08:00
|
|
|
void inferMachineType();
|
2016-01-08 01:54:21 +08:00
|
|
|
template <class ELFT> void link(llvm::opt::InputArgList &Args);
|
2015-10-07 17:13:03 +08:00
|
|
|
|
2016-04-08 03:24:51 +08:00
|
|
|
// True if we are in --whole-archive and --no-whole-archive.
|
2016-10-26 12:01:07 +08:00
|
|
|
bool InWholeArchive = false;
|
2016-04-08 03:24:51 +08:00
|
|
|
|
|
|
|
// True if we are in --start-lib and --end-lib.
|
|
|
|
bool InLib = false;
|
|
|
|
|
2016-10-20 13:12:29 +08:00
|
|
|
// True if we are in -format=binary and -format=elf.
|
|
|
|
bool InBinary = false;
|
|
|
|
|
2016-09-14 08:05:51 +08:00
|
|
|
std::vector<InputFile *> Files;
|
2015-07-25 05:03:07 +08:00
|
|
|
};
|
|
|
|
|
2015-10-12 02:19:01 +08:00
|
|
|
// Parses command line options.
|
2016-03-16 02:20:50 +08:00
|
|
|
class ELFOptTable : public llvm::opt::OptTable {
|
|
|
|
public:
|
|
|
|
ELFOptTable();
|
|
|
|
llvm::opt::InputArgList parse(ArrayRef<const char *> Argv);
|
|
|
|
};
|
2015-10-12 02:19:01 +08:00
|
|
|
|
2015-07-25 05:03:07 +08:00
|
|
|
// Create enum with OPT_xxx values for each option in Options.td
|
|
|
|
enum {
|
|
|
|
OPT_INVALID = 0,
|
2017-06-21 00:31:31 +08:00
|
|
|
#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID,
|
2015-07-25 05:03:07 +08:00
|
|
|
#include "Options.inc"
|
|
|
|
#undef OPTION
|
|
|
|
};
|
|
|
|
|
2018-02-07 06:37:05 +08:00
|
|
|
void printHelp();
|
2016-05-16 01:10:23 +08:00
|
|
|
std::string createResponseFile(const llvm::opt::InputArgList &Args);
|
2016-05-01 06:23:29 +08:00
|
|
|
|
2016-11-20 03:23:58 +08:00
|
|
|
llvm::Optional<std::string> findFromSearchPaths(StringRef Path);
|
2017-11-20 23:43:20 +08:00
|
|
|
llvm::Optional<std::string> searchLinkerScript(StringRef Path);
|
2016-11-20 03:23:58 +08:00
|
|
|
llvm::Optional<std::string> searchLibrary(StringRef Path);
|
2015-10-11 11:28:39 +08:00
|
|
|
|
2016-02-28 08:25:54 +08:00
|
|
|
} // namespace elf
|
2015-07-25 05:03:07 +08:00
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif
|