diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-03-24 21:31:36 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-03-24 21:31:36 +0000 |
commit | fb911942f1434f3d1750f83f25f5e42c80e60638 (patch) | |
tree | 1678c4a4f0182e4029a86d135aa4a1b7d09e3c41 /tools/linker-script-test |
Notes
Diffstat (limited to 'tools/linker-script-test')
-rw-r--r-- | tools/linker-script-test/CMakeLists.txt | 8 | ||||
-rw-r--r-- | tools/linker-script-test/Makefile | 24 | ||||
-rw-r--r-- | tools/linker-script-test/linker-script-test.cpp | 57 |
3 files changed, 89 insertions, 0 deletions
diff --git a/tools/linker-script-test/CMakeLists.txt b/tools/linker-script-test/CMakeLists.txt new file mode 100644 index 000000000000..2492f10aa80c --- /dev/null +++ b/tools/linker-script-test/CMakeLists.txt @@ -0,0 +1,8 @@ +add_llvm_executable(linker-script-test + linker-script-test.cpp + ) + +target_link_libraries(linker-script-test + LLVMSupport + lldReaderWriter + ) diff --git a/tools/linker-script-test/Makefile b/tools/linker-script-test/Makefile new file mode 100644 index 000000000000..fd1b61accc07 --- /dev/null +++ b/tools/linker-script-test/Makefile @@ -0,0 +1,24 @@ +##===-------------- linker-script-test/Makefile ----------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===--------------------------------------------------------------------===## + +LLD_LEVEL := ../.. + +TOOLNAME = linker-script-test + +# No plugins, optimize startup time. +TOOL_NO_EXPORTS = 1 + +#include /Makefile.config +LEVEL := $(LLD_LEVEL)/../.. +include $(LEVEL)/Makefile.config + +LINK_COMPONENTS := $(TARGETS_TO_BUILD) +USEDLIBS = lldReaderWriter.a lldCore.a LLVMSupport.a + +include $(LLD_LEVEL)/Makefile 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()); + } + } +} |