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