summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-29 20:59:10 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-29 20:59:10 +0000
commitb025d011dd270230aeb50d7174a2a05616fe81eb (patch)
tree71544f8945a1266763fc1dfac6ac6b17433cfb39
parentabe21bdf8e3c7be93c9236c3eec47756e14582bb (diff)
downloadsrc-test2-b025d011dd270230aeb50d7174a2a05616fe81eb.tar.gz
src-test2-b025d011dd270230aeb50d7174a2a05616fe81eb.zip
Vendor import of lld release_40 branch r293443:vendor/lld/lld-release_40-r293443
Notes
Notes: svn path=/vendor/lld/dist/; revision=312964 svn path=/vendor/lld/lld-release_40-r293443/; revision=312965; tag=vendor/lld/lld-release_40-r293443
-rw-r--r--CMakeLists.txt1
-rw-r--r--ELF/LinkerScript.cpp7
-rw-r--r--ELF/SyntheticSections.h4
-rw-r--r--cmake/modules/AddLLD.cmake34
-rw-r--r--docs/ReleaseNotes.rst89
-rw-r--r--test/ELF/linkerscript/common-assign.s48
6 files changed, 164 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 48ac5e038cdb..be424efbbd87 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,6 +42,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
include_directories("${LLVM_BINARY_DIR}/include" ${LLVM_INCLUDE_DIRS})
link_directories(${LLVM_LIBRARY_DIRS})
+ set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH)
diff --git a/ELF/LinkerScript.cpp b/ELF/LinkerScript.cpp
index 887ca12537ad..3cc235386b88 100644
--- a/ELF/LinkerScript.cpp
+++ b/ELF/LinkerScript.cpp
@@ -918,12 +918,7 @@ const OutputSectionBase *LinkerScript<ELFT>::getSymbolSection(StringRef S) {
return CurOutSec ? CurOutSec : (*OutputSections)[0];
}
- if (auto *DR = dyn_cast_or_null<DefinedRegular<ELFT>>(Sym))
- return DR->Section ? DR->Section->OutSec : nullptr;
- if (auto *DS = dyn_cast_or_null<DefinedSynthetic>(Sym))
- return DS->Section;
-
- return nullptr;
+ return SymbolTableSection<ELFT>::getOutputSection(Sym);
}
// Returns indices of ELF headers containing specific section, identified
diff --git a/ELF/SyntheticSections.h b/ELF/SyntheticSections.h
index dfefb3821e75..f7e891ec3a66 100644
--- a/ELF/SyntheticSections.h
+++ b/ELF/SyntheticSections.h
@@ -372,6 +372,8 @@ public:
ArrayRef<SymbolTableEntry> getSymbols() const { return Symbols; }
+ static const OutputSectionBase *getOutputSection(SymbolBody *Sym);
+
unsigned NumLocals = 0;
StringTableSection<ELFT> &StrTabSec;
@@ -379,8 +381,6 @@ private:
void writeLocalSymbols(uint8_t *&Buf);
void writeGlobalSymbols(uint8_t *Buf);
- const OutputSectionBase *getOutputSection(SymbolBody *Sym);
-
// A vector of symbols and their string table offsets.
std::vector<SymbolTableEntry> Symbols;
};
diff --git a/cmake/modules/AddLLD.cmake b/cmake/modules/AddLLD.cmake
index 906b2952a943..fd1d44199ca6 100644
--- a/cmake/modules/AddLLD.cmake
+++ b/cmake/modules/AddLLD.cmake
@@ -1,6 +1,38 @@
macro(add_lld_library name)
- llvm_add_library(${name} ${ARGN})
+ cmake_parse_arguments(ARG
+ "SHARED"
+ ""
+ ""
+ ${ARGN})
+ if(ARG_SHARED)
+ set(ARG_ENABLE_SHARED SHARED)
+ endif()
+ llvm_add_library(${name} ${ARG_ENABLE_SHARED} ${ARG_UNPARSED_ARGUMENTS})
set_target_properties(${name} PROPERTIES FOLDER "lld libraries")
+
+ if (LLD_BUILD_TOOLS)
+ if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
+ NOT LLVM_DISTRIBUTION_COMPONENTS)
+ set(export_to_lldtargets EXPORT lldTargets)
+ set_property(GLOBAL PROPERTY LLD_HAS_EXPORTS True)
+ endif()
+
+ install(TARGETS ${name}
+ COMPONENT ${name}
+ ${export_to_lldtargets}
+ LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+ ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+ RUNTIME DESTINATION bin)
+
+ if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
+ add_custom_target(install-${name}
+ DEPENDS ${name}
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=${name}
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+ endif()
+ set_property(GLOBAL APPEND PROPERTY LLD_EXPORTS ${name})
+ endif()
endmacro(add_lld_library)
macro(add_lld_executable name)
diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst
index 8bd73db363d7..6eb857070690 100644
--- a/docs/ReleaseNotes.rst
+++ b/docs/ReleaseNotes.rst
@@ -11,25 +11,94 @@ LLD 4.0.0 Release Notes
Introduction
============
-This document contains the release notes for the LLD linker, release 4.0.0.
+LLD is a linker which supports ELF (Unix), COFF (Windows) and Mach-O
+(macOS). It is generally faster than the GNU BFD/gold linkers or the
+MSVC linker.
+
+LLD is designed to be a drop-in replacmenet for the system linkers, so
+that users don't need to change their build systems other than swapping
+the linker command.
+
+This document contains the release notes for LLD 4.0.0.
Here we describe the status of LLD, including major improvements
from the previous release. All LLD releases may be downloaded
from the `LLVM releases web site <http://llvm.org/releases/>`_.
-Non-comprehensive list of changes in this release
-=================================================
+
+What's New in LLD 4.0?
+======================
ELF Improvements
----------------
-* Initial support for LTO.
+LLD provides much better compatibility with the GNU linker than before.
+Now it is able to link the entire FreeBSD base system including the kernel
+out of the box. We are working closely with the FreeBSD project to
+make it usable as the system linker in a future release of the operating
+system.
-COFF Improvements
------------------
+Multi-threading performance has been improved, and multi-threading
+is now enabled by default. Combined with other optimizations, LLD 4.0
+is about 1.5 times faster than LLD 3.9 when linking large programs
+in our test environment.
+
+Other notable changes are listed below:
+
+* Error messages contain more information than before. If debug info
+ is available, the linker prints out not only the object file name
+ but the source location of unresolved symbols.
+
+* Error messages are printed in red just like Clang by default. You
+ can disable it by passing -no-color-diagnostics.
+
+* LLD's version string is now embedded in a .comment section in the
+ result output file. You can dump it with this command: ``objdump -j -s
+ .comment <file>``.
+
+* The -Map option is supported. With that, you can print out section
+ and symbol information to a specified file. This feature is useful
+ for analyzing link results.
-* Item 1.
+* The file format for the -reproduce option has changed from cpio to
+ tar.
-MachO Improvements
-------------------
+* When creating a copy relocation for a symbol, LLD now scans the
+ DSO's header to see if the symbol is in a read-only segment. If so,
+ space for the copy relocation is reserved in .bss.rel.ro instead of
+ .bss. This fixes a security issue that read-only data in a DSO
+ becomes writable if it is copied by a copy relocation. This issue
+ was disclosed originally on the binutils mailing list at
+ `<https://sourceware.org/ml/libc-alpha/2016-12/msg00914.html>`.
+
+* Compressed input sections are supported.
+
+* ``--oformat binary``, ``--section-start``, ``-Tbss``, ``-Tdata``,
+ ``-Ttext``, ``-b binary``, ``-build-id=uuid``, ``-no-rosegment``,
+ ``-nopie``, ``-nostdlib``, ``-omagic``, ``-retain-symbols-file``,
+ ``-sort-section``, ``-z max-page-size`` and ``-z wxneeded`` are
+ suppoorted.
+
+* A lot of linker script directives have been added.
+
+* Default image base address for x86-64 has changed from 0x10000 to
+ 0x200000 to make it huge-page friendly.
+
+* ARM port now supports GNU ifunc, the ARM C++ exceptions ABI, TLS
+ relocations and static linking. Problems with dlopen() on systems
+ using eglibc fixed.
+
+* MIPS port now supports input files in new R6 revision of MIPS ABIs
+ or N32 ABI. Generated file now contains .MIPS.abiflags section and
+ complete set of ELF headers flags.
+
+* Relocations produced by the ``-mxgot`` compiler's flag is supported
+ for MIPS. Now it is possible to generate "large" GOT exceeds 64K
+ limit.
+
+COFF Improvements
+-----------------
-* Item 1.
+* Performance on Windows has been improved by parallelizing parts of the
+ linker and optimizing file system operations. As a result of these
+ improvements, LLD 4.0 has been measured to be about 2.5 times faster
+ than LLD 3.9 when linking a large Chromium DLL.
diff --git a/test/ELF/linkerscript/common-assign.s b/test/ELF/linkerscript/common-assign.s
new file mode 100644
index 000000000000..4244ae321110
--- /dev/null
+++ b/test/ELF/linkerscript/common-assign.s
@@ -0,0 +1,48 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; pfoo = foo; pbar = bar; }" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: llvm-readobj -symbols %t1 | FileCheck %s
+
+# CHECK: Symbol {
+# CHECK: Name: bar
+# CHECK-NEXT: Value: 0x134
+# CHECK-NEXT: Size: 4
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type: Object
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: .bss
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: foo
+# CHECK-NEXT: Value: 0x138
+# CHECK-NEXT: Size: 4
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type: Object
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: .bss
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: pfoo
+# CHECK-NEXT: Value: 0x138
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type: None
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: .bss
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: pbar
+# CHECK-NEXT: Value: 0x134
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type: None
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: .bss
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+
+.comm foo,4,4
+.comm bar,4,4
+movl $1, foo(%rip)
+movl $2, bar(%rip)