Vendor import of lld release_40 branch r293443:

https://llvm.org/svn/llvm-project/lld/branches/release_40@293443
This commit is contained in:
Dimitry Andric 2017-01-29 20:59:10 +00:00
parent abe21bdf8e
commit b025d011dd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/lld/dist/; revision=312964
svn path=/vendor/lld/lld-release_40-r293443/; revision=312965; tag=vendor/lld/lld-release_40-r293443
6 changed files with 164 additions and 19 deletions

View File

@ -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)

View File

@ -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

View File

@ -372,6 +372,8 @@ class SymbolTableSection final : public SyntheticSection<ELFT> {
ArrayRef<SymbolTableEntry> getSymbols() const { return Symbols; }
static const OutputSectionBase *getOutputSection(SymbolBody *Sym);
unsigned NumLocals = 0;
StringTableSection<ELFT> &StrTabSec;
@ -379,8 +381,6 @@ class SymbolTableSection final : public SyntheticSection<ELFT> {
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;
};

View File

@ -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)

View File

@ -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.
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.
* The file format for the -reproduce option has changed from cpio to
tar.
* 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.
MachO 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.

View File

@ -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)