]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/ELF/Driver.h
Merge lld trunk r351319, resolve conflicts, and update FREEBSD-Xlist.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lld / ELF / Driver.h
1 //===- Driver.h -------------------------------------------------*- C++ -*-===//
2 //
3 //                             The LLVM Linker
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLD_ELF_DRIVER_H
11 #define LLD_ELF_DRIVER_H
12
13 #include "SymbolTable.h"
14 #include "lld/Common/LLVM.h"
15 #include "lld/Common/Reproduce.h"
16 #include "llvm/ADT/Optional.h"
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/ADT/StringSet.h"
19 #include "llvm/Option/ArgList.h"
20 #include "llvm/Support/raw_ostream.h"
21
22 namespace lld {
23 namespace elf {
24
25 extern class LinkerDriver *Driver;
26
27 class LinkerDriver {
28 public:
29   void main(ArrayRef<const char *> Args);
30   void addFile(StringRef Path, bool WithLOption);
31   void addLibrary(StringRef Name);
32
33 private:
34   void readConfigs(llvm::opt::InputArgList &Args);
35   void createFiles(llvm::opt::InputArgList &Args);
36   void inferMachineType();
37   template <class ELFT> void link(llvm::opt::InputArgList &Args);
38
39   // True if we are in --whole-archive and --no-whole-archive.
40   bool InWholeArchive = false;
41
42   // True if we are in --start-lib and --end-lib.
43   bool InLib = false;
44
45   std::vector<InputFile *> Files;
46 };
47
48 // Parses command line options.
49 class ELFOptTable : public llvm::opt::OptTable {
50 public:
51   ELFOptTable();
52   llvm::opt::InputArgList parse(ArrayRef<const char *> Argv);
53 };
54
55 // Create enum with OPT_xxx values for each option in Options.td
56 enum {
57   OPT_INVALID = 0,
58 #define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID,
59 #include "ELF/Options.inc"
60 #undef OPTION
61 };
62
63 void printHelp();
64 std::string createResponseFile(const llvm::opt::InputArgList &Args);
65
66 llvm::Optional<std::string> findFromSearchPaths(StringRef Path);
67 llvm::Optional<std::string> searchScript(StringRef Path);
68 llvm::Optional<std::string> searchLibrary(StringRef Path);
69
70 } // namespace elf
71 } // namespace lld
72
73 #endif