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