2015-08-14 22:12:54 +08:00
|
|
|
//===- Driver.h -------------------------------------------------*- C++ -*-===//
|
2015-07-25 05:03:07 +08:00
|
|
|
//
|
|
|
|
// The LLVM Linker
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_ELF_DRIVER_H
|
|
|
|
#define LLD_ELF_DRIVER_H
|
|
|
|
|
2015-10-01 23:23:09 +08:00
|
|
|
#include "SymbolTable.h"
|
2015-07-25 05:03:07 +08:00
|
|
|
#include "lld/Core/LLVM.h"
|
2016-04-14 03:07:40 +08:00
|
|
|
#include "llvm/ADT/Optional.h"
|
2015-10-01 01:06:09 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2015-07-25 05:03:07 +08:00
|
|
|
#include "llvm/Option/ArgList.h"
|
2016-02-03 06:49:32 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2015-07-25 05:03:07 +08:00
|
|
|
|
|
|
|
namespace lld {
|
2016-02-28 08:25:54 +08:00
|
|
|
namespace elf {
|
2015-07-25 05:03:07 +08:00
|
|
|
|
2015-10-01 23:23:09 +08:00
|
|
|
extern class LinkerDriver *Driver;
|
2015-10-01 01:06:09 +08:00
|
|
|
|
2015-07-25 05:03:07 +08:00
|
|
|
class LinkerDriver {
|
|
|
|
public:
|
2015-10-10 05:07:25 +08:00
|
|
|
void main(ArrayRef<const char *> Args);
|
2015-10-01 23:23:09 +08:00
|
|
|
void addFile(StringRef Path);
|
2016-02-03 05:13:09 +08:00
|
|
|
void addLibrary(StringRef Name);
|
2016-04-29 03:30:41 +08:00
|
|
|
llvm::LLVMContext Context;
|
2015-07-25 05:03:07 +08:00
|
|
|
|
|
|
|
private:
|
2016-04-01 07:12:18 +08:00
|
|
|
std::vector<MemoryBufferRef> getArchiveMembers(MemoryBufferRef MB);
|
2016-04-14 02:51:11 +08:00
|
|
|
llvm::Optional<MemoryBufferRef> readFile(StringRef Path);
|
2016-01-08 01:54:21 +08:00
|
|
|
void readConfigs(llvm::opt::InputArgList &Args);
|
|
|
|
void createFiles(llvm::opt::InputArgList &Args);
|
|
|
|
template <class ELFT> void link(llvm::opt::InputArgList &Args);
|
2015-10-07 17:13:03 +08:00
|
|
|
|
2016-04-08 03:24:51 +08:00
|
|
|
// True if we are in --whole-archive and --no-whole-archive.
|
2015-10-10 05:07:25 +08:00
|
|
|
bool WholeArchive = false;
|
2016-04-08 03:24:51 +08:00
|
|
|
|
|
|
|
// True if we are in --start-lib and --end-lib.
|
|
|
|
bool InLib = false;
|
|
|
|
|
|
|
|
llvm::BumpPtrAllocator Alloc;
|
2015-10-10 05:07:25 +08:00
|
|
|
std::vector<std::unique_ptr<InputFile>> Files;
|
2015-10-01 23:23:09 +08:00
|
|
|
std::vector<std::unique_ptr<MemoryBuffer>> OwningMBs;
|
2015-07-25 05:03:07 +08:00
|
|
|
};
|
|
|
|
|
2015-10-12 02:19:01 +08:00
|
|
|
// Parses command line options.
|
2016-03-16 02:20:50 +08:00
|
|
|
class ELFOptTable : public llvm::opt::OptTable {
|
|
|
|
public:
|
|
|
|
ELFOptTable();
|
|
|
|
llvm::opt::InputArgList parse(ArrayRef<const char *> Argv);
|
|
|
|
|
|
|
|
private:
|
|
|
|
llvm::BumpPtrAllocator Alloc;
|
|
|
|
};
|
2015-10-12 02:19:01 +08:00
|
|
|
|
2015-07-25 05:03:07 +08:00
|
|
|
// Create enum with OPT_xxx values for each option in Options.td
|
|
|
|
enum {
|
|
|
|
OPT_INVALID = 0,
|
|
|
|
#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11) OPT_##ID,
|
|
|
|
#include "Options.inc"
|
|
|
|
#undef OPTION
|
|
|
|
};
|
|
|
|
|
2016-02-28 11:18:09 +08:00
|
|
|
void printHelp(const char *Argv0);
|
2016-02-28 11:18:07 +08:00
|
|
|
void printVersion();
|
|
|
|
|
2016-04-27 04:41:32 +08:00
|
|
|
std::string concat_paths(StringRef S, StringRef T);
|
|
|
|
void copyFile(StringRef Src, StringRef Dest);
|
|
|
|
|
2015-10-11 11:28:42 +08:00
|
|
|
std::string findFromSearchPaths(StringRef Path);
|
2015-10-11 11:28:39 +08:00
|
|
|
std::string searchLibrary(StringRef Path);
|
|
|
|
std::string buildSysrootedPath(llvm::StringRef Dir, llvm::StringRef File);
|
|
|
|
|
2016-02-28 08:25:54 +08:00
|
|
|
} // namespace elf
|
2015-07-25 05:03:07 +08:00
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif
|