ELF: Create LinkerScript class to move code out of Writer.

Previously, we had code for linker scripts in Writer. This patch
separates that as LinkerScript class. The class provides a few
functions to query linker scripts and is also a container of some
linker-script-specific information.

Hopefully, Writer will only implement the default behavior and let
the new class handle gotchas regarding linker scripts.

llvm-svn: 260591
diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
new file mode 100644
index 0000000..61ad5946
--- /dev/null
+++ b/lld/ELF/LinkerScript.h
@@ -0,0 +1,45 @@
+//===- LinkerScript.h -------------------------------------------*- C++ -*-===//
+//
+//                             The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLD_ELF_LINKER_SCRIPT_H
+#define LLD_ELF_LINKER_SCRIPT_H
+
+#include "lld/Core/LLVM.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/MapVector.h"
+
+namespace lld {
+namespace elf2 {
+
+class ScriptParser;
+
+class LinkerScript {
+  friend class ScriptParser;
+
+public:
+  StringRef getOutputSection(StringRef InputSection);
+  bool isDiscarded(StringRef InputSection);
+  int compareSections(StringRef A, StringRef B);
+  void finalize();
+
+private:
+  // Map for SECTIONS command. The key is output section name
+  // and a value is a list of input section names.
+  llvm::MapVector<StringRef, std::vector<StringRef>> Sections;
+
+  // Inverse map of Sections.
+  llvm::DenseMap<StringRef, StringRef> RevSections;
+};
+
+extern LinkerScript *Script;
+
+} // namespace elf2
+} // namespace lld
+
+#endif