blob: a83abb559ddaa04d9a150ac76d867ae75dc44ee7 [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"
Rui Ueyamaf5c4aca2015-09-30 17:06:09 +000014#include "llvm/ADT/StringRef.h"
Michael J. Spencer84487f12015-07-24 21:03:07 +000015#include "llvm/Option/ArgList.h"
16
17namespace lld {
18namespace elf2 {
19
Rui Ueyamaf5c4aca2015-09-30 17:06:09 +000020class SymbolTable;
21
22// The owner of all opened files.
23extern std::vector<std::unique_ptr<MemoryBuffer>> *MemoryBufferPool;
24MemoryBufferRef openFile(StringRef Path);
25
Michael J. Spencer84487f12015-07-24 21:03:07 +000026// Entry point of the ELF linker.
27void link(ArrayRef<const char *> Args);
28
Michael J. Spencer84487f12015-07-24 21:03:07 +000029class ArgParser {
30public:
31 // Parses command line options.
32 llvm::opt::InputArgList parse(ArrayRef<const char *> Args);
Rui Ueyamaeeb22f82015-09-25 15:37:33 +000033
34private:
35 llvm::BumpPtrAllocator Alloc;
Michael J. Spencer84487f12015-07-24 21:03:07 +000036};
37
38class LinkerDriver {
39public:
40 void link(ArrayRef<const char *> Args);
41
42private:
43 ArgParser Parser;
Michael J. Spencer84487f12015-07-24 21:03:07 +000044};
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
Rui Ueyamaf5c4aca2015-09-30 17:06:09 +000054// Parses a linker script. Calling this function updates the Symtab and Config.
55void readLinkerScript(SymbolTable *Symtab, MemoryBufferRef MB);
56
Michael J. Spencer84487f12015-07-24 21:03:07 +000057} // namespace elf2
58} // namespace lld
59
60#endif