2015-08-14 14:12:54 +00:00
|
|
|
//===- Driver.h -------------------------------------------------*- C++ -*-===//
|
2015-07-24 21:03:07 +00: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 15:23:09 +00:00
|
|
|
#include "SymbolTable.h"
|
2015-07-24 21:03:07 +00:00
|
|
|
#include "lld/Core/LLVM.h"
|
2016-07-26 02:00:42 +00:00
|
|
|
#include "lld/Core/Reproduce.h"
|
2016-04-13 19:07:40 +00:00
|
|
|
#include "llvm/ADT/Optional.h"
|
2015-09-30 17:06:09 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2016-05-03 17:30:44 +00:00
|
|
|
#include "llvm/ADT/StringSet.h"
|
2016-09-29 01:45:22 +00:00
|
|
|
#include "llvm/IR/LLVMContext.h"
|
2015-07-24 21:03:07 +00:00
|
|
|
#include "llvm/Option/ArgList.h"
|
2016-02-02 22:49:32 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2015-07-24 21:03:07 +00:00
|
|
|
|
|
|
|
namespace lld {
|
2016-02-28 00:25:54 +00:00
|
|
|
namespace elf {
|
2015-07-24 21:03:07 +00:00
|
|
|
|
2015-10-01 15:23:09 +00:00
|
|
|
extern class LinkerDriver *Driver;
|
2015-09-30 17:06:09 +00:00
|
|
|
|
2015-07-24 21:03:07 +00:00
|
|
|
class LinkerDriver {
|
|
|
|
public:
|
2015-10-09 21:07:25 +00:00
|
|
|
void main(ArrayRef<const char *> Args);
|
2016-09-09 22:08:04 +00:00
|
|
|
void addFile(StringRef Path, bool KnownScript = false);
|
2016-02-02 21:13:09 +00:00
|
|
|
void addLibrary(StringRef Name);
|
2016-09-29 01:45:22 +00:00
|
|
|
llvm::LLVMContext Context; // to parse bitcode files
|
2016-05-15 17:10:23 +00:00
|
|
|
std::unique_ptr<CpioFile> Cpio; // for reproduce
|
2016-05-03 17:30:44 +00:00
|
|
|
|
2015-07-24 21:03:07 +00:00
|
|
|
private:
|
2016-03-31 23:12:18 +00:00
|
|
|
std::vector<MemoryBufferRef> getArchiveMembers(MemoryBufferRef MB);
|
2016-04-13 18:51:11 +00:00
|
|
|
llvm::Optional<MemoryBufferRef> readFile(StringRef Path);
|
2016-01-07 17:54:21 +00: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 09:13:03 +00:00
|
|
|
|
2016-04-07 19:24:51 +00:00
|
|
|
// True if we are in --whole-archive and --no-whole-archive.
|
2015-10-09 21:07:25 +00:00
|
|
|
bool WholeArchive = false;
|
2016-04-07 19:24:51 +00:00
|
|
|
|
|
|
|
// True if we are in --start-lib and --end-lib.
|
|
|
|
bool InLib = false;
|
|
|
|
|
|
|
|
llvm::BumpPtrAllocator Alloc;
|
2016-09-14 00:05:51 +00:00
|
|
|
std::vector<InputFile *> Files;
|
2015-10-01 15:23:09 +00:00
|
|
|
std::vector<std::unique_ptr<MemoryBuffer>> OwningMBs;
|
2015-07-24 21:03:07 +00:00
|
|
|
};
|
|
|
|
|
2015-10-11 18:19:01 +00:00
|
|
|
// Parses command line options.
|
2016-03-15 18:20:50 +00:00
|
|
|
class ELFOptTable : public llvm::opt::OptTable {
|
|
|
|
public:
|
|
|
|
ELFOptTable();
|
|
|
|
llvm::opt::InputArgList parse(ArrayRef<const char *> Argv);
|
|
|
|
|
|
|
|
private:
|
|
|
|
llvm::BumpPtrAllocator Alloc;
|
|
|
|
};
|
2015-10-11 18:19:01 +00:00
|
|
|
|
2015-07-24 21:03:07 +00: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 03:18:09 +00:00
|
|
|
void printHelp(const char *Argv0);
|
2016-05-13 21:55:56 +00:00
|
|
|
std::vector<uint8_t> parseHexstring(StringRef S);
|
2016-02-28 03:18:07 +00:00
|
|
|
|
2016-05-15 17:10:23 +00:00
|
|
|
std::string createResponseFile(const llvm::opt::InputArgList &Args);
|
2016-04-30 22:23:29 +00:00
|
|
|
|
2015-10-11 03:28:42 +00:00
|
|
|
std::string findFromSearchPaths(StringRef Path);
|
2015-10-11 03:28:39 +00:00
|
|
|
std::string searchLibrary(StringRef Path);
|
|
|
|
std::string buildSysrootedPath(llvm::StringRef Dir, llvm::StringRef File);
|
|
|
|
|
2016-02-28 00:25:54 +00:00
|
|
|
} // namespace elf
|
2015-07-24 21:03:07 +00:00
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif
|