]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/ELF/Driver.h
Merge ^/head r311546 through r311683.
[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/Core/LLVM.h"
15 #include "lld/Core/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/TarWriter.h"
21 #include "llvm/Support/raw_ostream.h"
22
23 namespace lld {
24 namespace elf {
25
26 extern class LinkerDriver *Driver;
27
28 class LinkerDriver {
29 public:
30   void main(ArrayRef<const char *> Args, bool CanExitEarly);
31   void addFile(StringRef Path);
32   void addLibrary(StringRef Name);
33   std::unique_ptr<llvm::TarWriter> Tar; // for reproduce
34
35 private:
36   std::vector<MemoryBufferRef> getArchiveMembers(MemoryBufferRef MB);
37   llvm::Optional<MemoryBufferRef> readFile(StringRef Path);
38   void readConfigs(llvm::opt::InputArgList &Args);
39   void createFiles(llvm::opt::InputArgList &Args);
40   void inferMachineType();
41   template <class ELFT> void link(llvm::opt::InputArgList &Args);
42
43   // True if we are in --whole-archive and --no-whole-archive.
44   bool InWholeArchive = false;
45
46   // True if we are in --start-lib and --end-lib.
47   bool InLib = false;
48
49   // True if we are in -format=binary and -format=elf.
50   bool InBinary = false;
51
52   std::vector<InputFile *> Files;
53 };
54
55 // Parses command line options.
56 class ELFOptTable : public llvm::opt::OptTable {
57 public:
58   ELFOptTable();
59   llvm::opt::InputArgList parse(ArrayRef<const char *> Argv);
60 };
61
62 // Create enum with OPT_xxx values for each option in Options.td
63 enum {
64   OPT_INVALID = 0,
65 #define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11) OPT_##ID,
66 #include "ELF/Options.inc"
67 #undef OPTION
68 };
69
70 void printHelp(const char *Argv0);
71 std::vector<uint8_t> parseHexstring(StringRef S);
72
73 std::string createResponseFile(const llvm::opt::InputArgList &Args);
74
75 llvm::Optional<std::string> findFromSearchPaths(StringRef Path);
76 llvm::Optional<std::string> searchLibrary(StringRef Path);
77
78 } // namespace elf
79 } // namespace lld
80
81 #endif