summaryrefslogtreecommitdiff
path: root/tools/linker-script-test/linker-script-test.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-03-24 21:31:36 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-03-24 21:31:36 +0000
commitfb911942f1434f3d1750f83f25f5e42c80e60638 (patch)
tree1678c4a4f0182e4029a86d135aa4a1b7d09e3c41 /tools/linker-script-test/linker-script-test.cpp
Notes
Diffstat (limited to 'tools/linker-script-test/linker-script-test.cpp')
-rw-r--r--tools/linker-script-test/linker-script-test.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/tools/linker-script-test/linker-script-test.cpp b/tools/linker-script-test/linker-script-test.cpp
new file mode 100644
index 000000000000..027ecb36c382
--- /dev/null
+++ b/tools/linker-script-test/linker-script-test.cpp
@@ -0,0 +1,57 @@
+//===- utils/linker-script-test/linker-script-test.cpp --------------------===//
+//
+// The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// \brief Tool for testing linker script parsing.
+///
+//===----------------------------------------------------------------------===//
+
+#include "lld/ReaderWriter/LinkerScript.h"
+
+#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Signals.h"
+
+using namespace llvm;
+using namespace lld;
+using namespace script;
+
+int main(int argc, const char **argv) {
+ llvm::sys::PrintStackTraceOnErrorSignal();
+ llvm::PrettyStackTraceProgram X(argc, argv);
+
+ {
+ ErrorOr<std::unique_ptr<MemoryBuffer>> mb =
+ MemoryBuffer::getFileOrSTDIN(argv[1]);
+ if (std::error_code ec = mb.getError()) {
+ llvm::errs() << ec.message() << "\n";
+ return 1;
+ }
+ Lexer l(std::move(mb.get()));
+ Token tok;
+ while (true) {
+ l.lex(tok);
+ tok.dump(llvm::outs());
+ if (tok._kind == Token::eof || tok._kind == Token::unknown)
+ break;
+ }
+ }
+ {
+ ErrorOr<std::unique_ptr<MemoryBuffer>> mb =
+ MemoryBuffer::getFileOrSTDIN(argv[1]);
+ if (std::error_code ec = mb.getError()) {
+ llvm::errs() << ec.message() << "\n";
+ return 1;
+ }
+ Parser p(std::move(mb.get()));
+ if (!p.parse()) {
+ LinkerScript *ls = p.get();
+ ls->dump(llvm::outs());
+ }
+ }
+}