blob: 8e243d9ac0b3843c7a0bb0151ba88aa5ffc4dd25 [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);
Rui Ueyamaeeb22f82015-09-25 15:37:33 +000031
32private:
33 llvm::BumpPtrAllocator Alloc;
Michael J. Spencer84487f12015-07-24 21:03:07 +000034};
35
36class LinkerDriver {
37public:
38 void link(ArrayRef<const char *> Args);
39
40private:
41 ArgParser Parser;
42
43 // Opens a file. Path has to be resolved already.
44 MemoryBufferRef openFile(StringRef Path);
45
46 // Driver is the owner of all opened files.
47 // InputFiles have MemoryBufferRefs to them.
48 std::vector<std::unique_ptr<MemoryBuffer>> OwningMBs;
49};
50
51// Create enum with OPT_xxx values for each option in Options.td
52enum {
53 OPT_INVALID = 0,
54#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11) OPT_##ID,
55#include "Options.inc"
56#undef OPTION
57};
58
59} // namespace elf2
60} // namespace lld
61
62#endif