Michael J. Spencer | 84487f1 | 2015-07-24 21:03:07 +0000 | [diff] [blame] | 1 | //===- Driver.h -----------------------------------------------------------===// |
| 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 "lld/Core/LLVM.h" |
| 14 | #include "llvm/Option/ArgList.h" |
| 15 | |
| 16 | namespace lld { |
| 17 | namespace elf2 { |
| 18 | |
| 19 | class LinkerDriver; |
| 20 | extern LinkerDriver *Driver; |
| 21 | |
| 22 | class InputFile; |
| 23 | |
| 24 | // Entry point of the ELF linker. |
| 25 | void link(ArrayRef<const char *> Args); |
| 26 | |
Michael J. Spencer | 84487f1 | 2015-07-24 21:03:07 +0000 | [diff] [blame] | 27 | class ArgParser { |
| 28 | public: |
| 29 | // Parses command line options. |
| 30 | llvm::opt::InputArgList parse(ArrayRef<const char *> Args); |
| 31 | }; |
| 32 | |
| 33 | class LinkerDriver { |
| 34 | public: |
| 35 | void link(ArrayRef<const char *> Args); |
| 36 | |
| 37 | private: |
| 38 | ArgParser Parser; |
| 39 | |
| 40 | // Opens a file. Path has to be resolved already. |
| 41 | MemoryBufferRef openFile(StringRef Path); |
| 42 | |
| 43 | // Driver is the owner of all opened files. |
| 44 | // InputFiles have MemoryBufferRefs to them. |
| 45 | std::vector<std::unique_ptr<MemoryBuffer>> OwningMBs; |
| 46 | }; |
| 47 | |
| 48 | // Create enum with OPT_xxx values for each option in Options.td |
| 49 | enum { |
| 50 | OPT_INVALID = 0, |
| 51 | #define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11) OPT_##ID, |
| 52 | #include "Options.inc" |
| 53 | #undef OPTION |
| 54 | }; |
| 55 | |
| 56 | } // namespace elf2 |
| 57 | } // namespace lld |
| 58 | |
| 59 | #endif |