blob: 1cc05302038a20203758032d885837685739abfe [file] [log] [blame]
Rafael Espindolabeee25e2015-08-14 14:12:54 +00001//===- Driver.h -------------------------------------------------*- C++ -*-===//
Michael J. Spencer84487f12015-07-24 21:03:07 +00002//
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
16namespace lld {
17namespace elf2 {
18
19class LinkerDriver;
20extern LinkerDriver *Driver;
21
22class InputFile;
23
24// Entry point of the ELF linker.
25void link(ArrayRef<const char *> Args);
26
Michael J. Spencer84487f12015-07-24 21:03:07 +000027class ArgParser {
28public:
29 // Parses command line options.
30 llvm::opt::InputArgList parse(ArrayRef<const char *> Args);
31};
32
33class LinkerDriver {
34public:
35 void link(ArrayRef<const char *> Args);
36
37private:
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
49enum {
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