[lld] r230594 - Add Example Sub Target.
Michael J. Spencer
bigcheesegs at gmail.com
Wed Feb 25 16:48:11 PST 2015
Author: mspencer
Date: Wed Feb 25 18:48:10 2015
New Revision: 230594
URL: http://llvm.org/viewvc/llvm-project?rev=230594&view=rev
Log:
Add Example Sub Target.
Added:
lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/
lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/CMakeLists.txt
lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleLinkingContext.cpp
lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleLinkingContext.h
lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleTargetHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleTargetHandler.h
lld/trunk/test/elf/X86_64/ExampleTarget/
lld/trunk/test/elf/X86_64/ExampleTarget/triple.test
Modified:
lld/trunk/include/lld/ReaderWriter/ELFTargets.h
lld/trunk/lib/Driver/CMakeLists.txt
lld/trunk/lib/Driver/GnuLdDriver.cpp
lld/trunk/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt
Modified: lld/trunk/include/lld/ReaderWriter/ELFTargets.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFTargets.h?rev=230594&r1=230593&r2=230594&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/ELFTargets.h (original)
+++ lld/trunk/include/lld/ReaderWriter/ELFTargets.h Wed Feb 25 18:48:10 2015
@@ -27,6 +27,7 @@ LLVM_TARGET(ARM)
LLVM_TARGET(Hexagon)
LLVM_TARGET(Mips)
LLVM_TARGET(X86)
+LLVM_TARGET(Example)
LLVM_TARGET(X86_64)
#undef LLVM_TARGET
Modified: lld/trunk/lib/Driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/CMakeLists.txt?rev=230594&r1=230593&r2=230594&view=diff
==============================================================================
--- lld/trunk/lib/Driver/CMakeLists.txt (original)
+++ lld/trunk/lib/Driver/CMakeLists.txt Wed Feb 25 18:48:10 2015
@@ -28,6 +28,7 @@ add_llvm_library(lldDriver
lldHexagonELFTarget
lldMipsELFTarget
lldX86ELFTarget
+ lldExampleSubTarget
lldX86_64ELFTarget
lldCore
lldNative
Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=230594&r1=230593&r2=230594&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Wed Feb 25 18:48:10 2015
@@ -353,6 +353,7 @@ GnuLdDriver::createELFLinkingContext(llv
LLVM_TARGET(Hexagon)
LLVM_TARGET(Mips)
LLVM_TARGET(X86)
+ LLVM_TARGET(Example)
LLVM_TARGET(X86_64)
#undef LLVM_TARGET
return nullptr;
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt?rev=230594&r1=230593&r2=230594&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt Wed Feb 25 18:48:10 2015
@@ -9,3 +9,5 @@ add_llvm_library(lldX86_64ELFTarget
LLVMObject
LLVMSupport
)
+
+add_subdirectory(ExampleSubTarget)
Added: lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/CMakeLists.txt?rev=230594&view=auto
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/CMakeLists.txt (added)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/CMakeLists.txt Wed Feb 25 18:48:10 2015
@@ -0,0 +1,6 @@
+add_llvm_library(lldExampleSubTarget
+ ExampleLinkingContext.cpp
+ ExampleTargetHandler.cpp
+ LINK_LIBS
+ lldX86_64ELFTarget
+ )
Added: lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleLinkingContext.cpp?rev=230594&view=auto
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleLinkingContext.cpp (added)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleLinkingContext.cpp Wed Feb 25 18:48:10 2015
@@ -0,0 +1,36 @@
+//===- lib/ReaderWriter/ELF/X86_64/ExampleTarget/ExampleLinkingContext.cpp ----===//
+//
+// The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "ExampleLinkingContext.h"
+
+#include "ExampleTargetHandler.h"
+
+using namespace lld;
+using namespace elf;
+
+std::unique_ptr<ELFLinkingContext>
+ExampleLinkingContext::create(llvm::Triple triple) {
+ if (triple.getVendorName() == "example")
+ return llvm::make_unique<ExampleLinkingContext>(triple);
+ return nullptr;
+}
+
+ExampleLinkingContext::ExampleLinkingContext(llvm::Triple triple)
+ : X86_64LinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
+ new ExampleTargetHandler(*this))) {
+ _outputELFType = llvm::ELF::ET_LOPROC;
+}
+
+StringRef ExampleLinkingContext::entrySymbolName() const {
+ return "_start";
+}
+
+void ExampleLinkingContext::addPasses(PassManager &p) {
+ ELFLinkingContext::addPasses(p);
+}
Added: lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleLinkingContext.h?rev=230594&view=auto
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleLinkingContext.h (added)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleLinkingContext.h Wed Feb 25 18:48:10 2015
@@ -0,0 +1,31 @@
+//===- lib/ReaderWriter/ELF/X86_64/ExampleTarget/ExampleLinkingContext.h --===//
+//
+// The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLD_READER_WRITER_ELF_X86_64_EXAMPLE_TARGET_EXAMPLE_LINKING_CONTEXT
+#define LLD_READER_WRITER_ELF_X86_64_EXAMPLE_TARGET_EXAMPLE_LINKING_CONTEXT
+
+#include "../X86_64LinkingContext.h"
+#include "../X86_64TargetHandler.h"
+
+namespace lld {
+namespace elf {
+
+class ExampleLinkingContext final : public X86_64LinkingContext {
+public:
+ static std::unique_ptr<ELFLinkingContext> create(llvm::Triple);
+ ExampleLinkingContext(llvm::Triple triple);
+
+ StringRef entrySymbolName() const override;
+ void addPasses(PassManager &) override;
+};
+
+} // end namespace elf
+} // end namespace lld
+
+#endif
Added: lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleTargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleTargetHandler.cpp?rev=230594&view=auto
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleTargetHandler.cpp (added)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleTargetHandler.cpp Wed Feb 25 18:48:10 2015
@@ -0,0 +1,24 @@
+//===- lib/ReaderWriter/ELF/X86_64/ExampleTarget/ExampleTargetHandler.cpp -===//
+//
+// The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "ExampleTargetHandler.h"
+
+#include "ExampleLinkingContext.h"
+#include "../X86_64ExecutableWriter.h"
+
+using namespace lld;
+using namespace elf;
+
+ExampleTargetHandler::ExampleTargetHandler(ExampleLinkingContext &c)
+ : X86_64TargetHandler(c), _exampleContext(c) {}
+
+std::unique_ptr<Writer> ExampleTargetHandler::getWriter() {
+ return std::unique_ptr<Writer>(
+ new X86_64ExecutableWriter(_exampleContext, *_x86_64TargetLayout));
+}
Added: lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleTargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleTargetHandler.h?rev=230594&view=auto
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleTargetHandler.h (added)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleTargetHandler.h Wed Feb 25 18:48:10 2015
@@ -0,0 +1,31 @@
+//===- lib/ReaderWriter/ELF/X86_64/ExampleTarget/ExampleTargetHandler.h ---===//
+//
+// The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLD_READER_WRITER_ELF_X86_64_EXAMPLE_TARGET_EXAMPLE_TARGET_HANDLER_H
+#define LLD_READER_WRITER_ELF_X86_64_EXAMPLE_TARGET_EXAMPLE_TARGET_HANDLER_H
+
+#include "../X86_64TargetHandler.h"
+
+namespace lld {
+namespace elf {
+class ExampleLinkingContext;
+
+class ExampleTargetHandler final : public X86_64TargetHandler {
+public:
+ ExampleTargetHandler(ExampleLinkingContext &c);
+
+ std::unique_ptr<Writer> getWriter() override;
+
+private:
+ ExampleLinkingContext &_exampleContext;
+};
+} // end namespace elf
+} // end namespace lld
+
+#endif
Added: lld/trunk/test/elf/X86_64/ExampleTarget/triple.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/X86_64/ExampleTarget/triple.test?rev=230594&view=auto
==============================================================================
--- lld/trunk/test/elf/X86_64/ExampleTarget/triple.test (added)
+++ lld/trunk/test/elf/X86_64/ExampleTarget/triple.test Wed Feb 25 18:48:10 2015
@@ -0,0 +1,32 @@
+# Check that the Example Target is actually used.
+
+# RUN: yaml2obj -format=elf %s -o %t.o
+# RUN: lld -flavor gnu -target x86_64-example-freebsd9 %t.o -o %t.exe
+# RUN: llvm-readobj -file-headers %t.exe | FileCheck %s
+#
+# CHECK: Type: 0xFF00
+
+# object
+
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ OSABI: ELFOSABI_GNU
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000010
+ Content: 554889E5B864000000C745FC000000005DC366666666662E0F1F840000000000554889E531C05DC3
+Symbols:
+ Local:
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+ Global:
+ - Name: _start
+ Type: STT_FUNC
+ Section: .text
+ Size: 0x0000000000000000
More information about the llvm-commits
mailing list