summaryrefslogtreecommitdiff
path: root/tools
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
Notes
Diffstat (limited to 'tools')
-rw-r--r--tools/CMakeLists.txt2
-rw-r--r--tools/Makefile17
-rw-r--r--tools/linker-script-test/CMakeLists.txt8
-rw-r--r--tools/linker-script-test/Makefile24
-rw-r--r--tools/linker-script-test/linker-script-test.cpp57
-rw-r--r--tools/lld/CMakeLists.txt25
-rw-r--r--tools/lld/Makefile30
-rw-r--r--tools/lld/TODO.txt2
-rw-r--r--tools/lld/lld.cpp36
9 files changed, 201 insertions, 0 deletions
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
new file mode 100644
index 000000000000..1151404441b4
--- /dev/null
+++ b/tools/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory(linker-script-test)
+add_subdirectory(lld)
diff --git a/tools/Makefile b/tools/Makefile
new file mode 100644
index 000000000000..93d2a58c3068
--- /dev/null
+++ b/tools/Makefile
@@ -0,0 +1,17 @@
+##===- tools/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 := ..
+LEVEL := $(LLD_LEVEL)/../..
+
+include $(LLD_LEVEL)/../../Makefile.config
+
+PARALLEL_DIRS := linker-script-test lld
+
+include $(LLD_LEVEL)/Makefile
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());
+ }
+ }
+}
diff --git a/tools/lld/CMakeLists.txt b/tools/lld/CMakeLists.txt
new file mode 100644
index 000000000000..47f26b5300c2
--- /dev/null
+++ b/tools/lld/CMakeLists.txt
@@ -0,0 +1,25 @@
+add_llvm_executable(lld
+ lld.cpp
+ )
+
+target_link_libraries(lld
+ lldDriver
+ LLVMSupport
+ )
+
+install(TARGETS lld
+ RUNTIME DESTINATION bin)
+
+# Create the lld-link[.exe] symlink in the build directory. If symlink is not
+# supported by the operating system, create a copy instead.
+if(UNIX)
+ set(command create_symlink)
+ # Make relative symlink
+ set(src "lld${CMAKE_EXECUTABLE_SUFFIX}")
+else()
+ set(command copy)
+ set(src "${LLVM_RUNTIME_OUTPUT_INTDIR}/lld${CMAKE_EXECUTABLE_SUFFIX}")
+endif()
+set(dst "${LLVM_RUNTIME_OUTPUT_INTDIR}/lld-link${CMAKE_EXECUTABLE_SUFFIX}")
+add_custom_command(TARGET lld POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E ${command} ${src} ${dst})
diff --git a/tools/lld/Makefile b/tools/lld/Makefile
new file mode 100644
index 000000000000..77b0abbef9d0
--- /dev/null
+++ b/tools/lld/Makefile
@@ -0,0 +1,30 @@
+##===------- lld/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 = lld
+
+# 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 = lldDriver.a lldConfig.a \
+ lldELF.a lldMachO.a lldPECOFF.a lldYAML.a \
+ lldReaderWriter.a lldCore.a lldNative.a \
+ lldHexagonELFTarget.a lldMipsELFTarget.a \
+ lldX86ELFTarget.a lldExampleSubTarget.a lldX86_64ELFTarget.a \
+ lldAArch64ELFTarget.a lldARMELFTarget.a \
+ LLVMOption.a
+
+include $(LLD_LEVEL)/Makefile
diff --git a/tools/lld/TODO.txt b/tools/lld/TODO.txt
new file mode 100644
index 000000000000..20f8db0fcf10
--- /dev/null
+++ b/tools/lld/TODO.txt
@@ -0,0 +1,2 @@
+tools/lld
+~~~~~~~~~
diff --git a/tools/lld/lld.cpp b/tools/lld/lld.cpp
new file mode 100644
index 000000000000..24c3a66a3ac3
--- /dev/null
+++ b/tools/lld/lld.cpp
@@ -0,0 +1,36 @@
+//===- tools/lld/lld.cpp - Linker Driver Dispatcher -----------------------===//
+//
+// The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+///
+/// This is the entry point to the lld driver. This is a thin wrapper which
+/// dispatches to the given platform specific driver.
+///
+//===----------------------------------------------------------------------===//
+
+#include "lld/Core/LLVM.h"
+#include "lld/Driver/Driver.h"
+#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Signals.h"
+
+using namespace lld;
+
+
+/// Universal linker main(). This linker eumulates the gnu, darwin, or
+/// windows linker based on the tool name or if the first argument is
+/// -flavor.
+int main(int argc, const char *argv[]) {
+ // Standard set up, so program fails gracefully.
+ llvm::sys::PrintStackTraceOnErrorSignal();
+ llvm::PrettyStackTraceProgram stackPrinter(argc, argv);
+ llvm::llvm_shutdown_obj shutdown;
+
+ return UniversalDriver::link(argc, argv) ? 0 : 1;
+}