summaryrefslogtreecommitdiffstats
path: root/lld/ELF/CMakeLists.txt
Commit message (Collapse)AuthorAgeFilesLines
* [ThinLTO] Pass CodeGenOpts like UnrollLoops/VectorizeLoop/VectorizeSLPWei Mi2020-01-091-0/+1
| | | | | | | | | | | | | down to pass builder in ltobackend. Currently CodeGenOpts like UnrollLoops/VectorizeLoop/VectorizeSLP in clang are not passed down to pass builder in ltobackend when new pass manager is used. This is inconsistent with the behavior when new pass manager is used and thinlto is not used. Such inconsistency causes slp vectorization pass not being enabled in ltobackend for O3 + thinlto right now. This patch fixes that. Differential Revision: https://reviews.llvm.org/D72386
* [ELF] Suggest extern "C" when an undefined reference is mangled while the ↵Fangrui Song2019-11-081-0/+1
| | | | | | | | | | | | definition is not When missing an extern "C" declaration, an undefined reference may be mangled while the definition is not. Suggest the missing extern "C" and the base name. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D69592
* [ELF][ARM] Implement --fix-cortex-a8 to fix erratum 657417Peter Smith2019-09-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The --fix-cortex-a8 option implements a linker workaround for the coretex-a8 erratum 657417. A summary of the erratum conditions is: - A 32-bit Thumb-2 branch instruction B.w, Bcc.w, BL, BLX spans two 4KiB regions. - The destination of the branch is to the first 4KiB region. - The instruction before the branch is a 32-bit Thumb-2 non-branch instruction. The linker fix is to redirect the branch to a patch not in the first 4KiB region. The patch forwards the branch on to its target. The cortex-a8, is an old CPU, with the first implementation of this workaround in ld.bfd appearing in 2009. The cortex-a8 has been used in early Android Phones and there are some critical applications that still need to run on a cortex-a8 that have the erratum. The patch is applied roughly 10 times on LLD and 20 on Clang when they are built with --fix-cortex-a8 on an Arm system. The formal erratum description is avaliable in the ARM Core Cortex-A8 (AT400/AT401) Errata Notice document. This is available from Arm on request but it seems to be findable via a web search. Differential Revision: https://reviews.llvm.org/D67284 llvm-svn: 371965
* Fail early if an output file is not writableRui Ueyama2019-03-111-1/+0
| | | | | | | | Fixes https://bugs.llvm.org/show_bug.cgi?id=36478 Differential Revision: https://reviews.llvm.org/D43664 llvm-svn: 355834
* [LLD][ELF] - Support MSP430.George Rimar2019-01-101-0/+1
| | | | | | | | | | | Patch by Michael Skvortsov! This change adds a basic support for linking static MSP430 ELF code. Implemented relocation types are intended to correspond to the BFD. Differential revision: https://reviews.llvm.org/D56535 llvm-svn: 350819
* Rename GdbIndex.{cpp,h} -> DWARF.{cpp,h}.Rui Ueyama2018-09-141-1/+1
| | | | | | | | These files used to contain classes and functions for .gdb_index, but they are moved to SyntheticSections.{cpp,h}, so the name is now irrelevant. llvm-svn: 342299
* Support RISC-VRui Ueyama2018-08-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by PkmX. This patch makes lld recognize RISC-V target and implements basic relocation for RV32/RV64 (and RVC). This should be necessary for static linking ELF applications. The ABI documentation for RISC-V can be found at: https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md. Note that the documentation is far from complete so we had to figure out some details from bfd. The patch should be pretty straightforward. Some highlights: - A new relocation Expr R_RISCV_PC_INDIRECT is added. This is needed as the low part of a PC-relative relocation is linked to the corresponding high part (auipc), see: https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md#pc-relative-symbol-addresses - LLVM's MC support for RISC-V is very incomplete (we are working on this), so tests are given in objectyaml format with the original assembly included in the comments. Once we have complete support for RISC-V in MC, we can switch to llvm-as/llvm-objdump. - We don't support linker relaxation for now as it requires greater changes to lld that is beyond the scope of this patch. Once this is accepted we can start to work on adding relaxation to lld. Differential Revision: https://reviews.llvm.org/D39322 llvm-svn: 339364
* Add Hexagon SupportSid Manning2018-06-131-0/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D47791 llvm-svn: 334637
* [CMake] Fix BUILD_SHARED_LIBS regression due to r331405David Zarzycki2018-05-031-0/+1
| | | | llvm-svn: 331444
* [ELF] Add profile guided section layoutMichael J. Spencer2018-04-171-0/+1
| | | | | | | | | | | | | | | | | This adds profile guided layout using the Call-Chain Clustering (C³) heuristic from https://research.fb.com/wp-content/uploads/2017/01/cgo2017-hfsort-final1.pdf . RFC: [llvm-dev] [RFC] Profile guided section layout http://lists.llvm.org/pipermail/llvm-dev/2017-June/114178.html Pass `--call-graph-ordering-file <file>` to read a call graph profile where each line has the format: <from symbol> <to symbol> <call count> Differential Revision: https://reviews.llvm.org/D36351 llvm-svn: 330234
* Merge {COFF,ELF}/Strings.cpp to Common/Strings.cpp.Rui Ueyama2018-02-281-1/+0
| | | | | | | | | This should resolve the issue that lld build fails in some hosts that uses case-insensitive file system. Differential Revision: https://reviews.llvm.org/D43788 llvm-svn: 326339
* [ELF] Implement scanner for Cortex-A53 Erratum 843419Peter Smith2017-12-051-0/+1
| | | | | | | | | | | | | | Add a new file AArch64ErrataFix.cpp that implements the logic to scan for the Cortex-A53 Erratum 843419. This involves finding all the executable code, disassembling the instructions that might trigger the erratum and reporting a message if the sequence is detected. At this stage we do not attempt to fix the erratum, this functionality will be added in a later patch. See D36749 for proposal. Differential Revision: https://reviews.llvm.org/D36742 llvm-svn: 319780
* Fix shared library builds of lld, broken in SVN r319138Martin Storsjo2017-11-281-1/+0
| | | | llvm-svn: 319152
* [lld] unified COFF and ELF error handling on new Common/ErrorHandlerBob Haarman2017-10-251-1/+0
| | | | | | | | | | | | | | | | | | | Summary: The COFF linker and the ELF linker have long had similar but separate Error.h and Error.cpp files to implement error handling. This change introduces new error handling code in Common/ErrorHandler.h, changes the COFF and ELF linkers to use it, and removes the old, separate implementations. Reviewers: ruiu Reviewed By: ruiu Subscribers: smeenai, jyknight, emaste, sdardis, nemanjai, nhaehnle, mgorny, javed.absar, kbarton, fedor.sergeev, llvm-commits Differential Revision: https://reviews.llvm.org/D39259 llvm-svn: 316624
* [lld] Move Threads to CommonBob Haarman2017-10-131-1/+0
| | | | | | | | | | | | | | | | Summary: This will allow using the functionality from other linkers. It is also a prerequisite for sharing the error logging code. Reviewers: ruiu Reviewed By: ruiu Subscribers: emaste, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D38822 llvm-svn: 315725
* lld: Prune unused libdeps.NAKAMURA Takumi2017-10-121-10/+0
| | | | llvm-svn: 315537
* lld: Reorder libdeps.NAKAMURA Takumi2017-10-111-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D38828 llvm-svn: 315529
* Wait for all threads to terminate before exitting.Rui Ueyama2017-10-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | I think it is not defined what would happen to detached threads when the main thread tries to exit. That means it was not guaranteed that unlinkAsync correctly removes a temporary file. It was also reported that this unlinkAsync caused a crash on Windows. This patch adds a few new functions so that the main thread always waits for non-main threads before exitting. I don't actually like the new two functions, runBackground and waitForBackgroundThreads, because it looks like it is a bit overdesigned. After all, what we are doing with these functions is to just remove a file. An alternative would be to do fork(2) and make the child process remove a file asynchronously. However, it has its own problems. Correctly forking and reclaiming a resource using waitpid(2) is not doable unless we know our process-wide settings (such as signal mask), but we can't make any assumption on it when lld is embedded to other process. So I chose to stick with threads instead of multi-processes. Differential Revision: https://reviews.llvm.org/D38571 llvm-svn: 315033
* Build fix: don't try to link in lldConfigHans Wennborg2017-10-021-1/+0
| | | | | | Config was removed in r314719. llvm-svn: 314736
* Move new lld's code to Common subdirectory.Rui Ueyama2017-10-021-0/+1
| | | | | | | | | | New lld's files are spread under lib subdirectory, and it isn't easy to find which files are actually maintained. This patch moves maintained files to Common subdirectory. Differential Revision: https://reviews.llvm.org/D37645 llvm-svn: 314719
* Add basic 64-bit SPARC supportRui Ueyama2017-06-281-0/+1
| | | | | | | | | | | | | | | Add support for the most common SPARC relocations. Make DT_PLTGOT point to the PLT on SPARC. Mark the PLT as executable on SPARC. This adds a basic test that creates a SPARV9 executable that invokes the exit system call on OpenBSD. Patch by Mark Kettenis. Differential Revision: https://reviews.llvm.org/D34618 llvm-svn: 306565
* LLD: Move ELF/Mips.cpp to ELF/Arch/MipsArchTree.cppKonstantin Zhuravlyov2017-06-191-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D34358 llvm-svn: 305742
* Split Target.cpp into small files.Rui Ueyama2017-06-161-0/+9
| | | | | | | | | | | | Target.cpp contains code for all the targets that LLD supports. It was simple and easy, but as the number of supported targets increased, it got messy. This patch splits the file into per-target files under ELF/arch directory. Differential Revision: https://reviews.llvm.org/D34222 llvm-svn: 305565
* Add BinaryFormat to lld librariesSam Clegg2017-06-071-0/+1
| | | | | | | | | | | | Without this, when building with shared BUILD_SHARED_LIBS=ON I get errors such as: lib/Core/Reader.cpp:40: error: undefined reference to 'llvm::identify_magic(llvm::StringRef)' Differential Revision: https://reviews.llvm.org/D34004 llvm-svn: 304932
* Move the parser for the linker script to a separate file.Rui Ueyama2017-04-051-0/+1
| | | | | | | | LinkerScript.cpp contains both the linker script processor and the linker script parser. I put both into a single file, but the file grown too large, so it's time to put them into two different files. llvm-svn: 299515
* Move a few functions to a new file Filesystem.{cpp,h}.Rui Ueyama2017-03-241-0/+1
| | | | llvm-svn: 298667
* Rename ScriptParser.{cpp,h} -> ScriptLexer.{cpp,h}.Rui Ueyama2017-02-141-1/+1
| | | | | | | These files contain a lexer, so the new names are better. The parser is in LinkerScript.{cpp,h}. llvm-svn: 295022
* [CMake] Fix pthread handling for out-of-tree buildsEric Fiselier2017-02-101-1/+1
| | | | | | | | | | | | | | | LLVM defines `PTHREAD_LIB` which is used by AddLLVM.cmake and various projects to correctly link the threading library when needed. Unfortunately `PTHREAD_LIB` is defined by LLVM's `config-ix.cmake` file which isn't installed and therefore can't be used when configuring out-of-tree builds. This causes such builds to fail since `pthread` isn't being correctly linked. This patch attempts to fix that problem by renaming and exporting `LLVM_PTHREAD_LIB` as part of`LLVMConfig.cmake`. I renamed `PTHREAD_LIB` because It seemed likely to cause collisions with downstream users of `LLVMConfig.cmake`. llvm-svn: 294690
* Implement -Map.Rafael Espindola2017-01-131-0/+1
| | | | | | | The format is not exactly the same as the one in bfd since bfd always follows a linker script and prints it along. llvm-svn: 291958
* Remove lld/Support/Memory.h.Rui Ueyama2016-12-181-1/+0
| | | | | | | | | | | | I thought for a while about how to remove it, but it looks like we can just copy the file for now. Of course I'm not happy about that, but it's just less than 50 lines of code, and we already have duplicate code in Error.h and some other places. I want to solve them all at once later. Differential Revision: https://reviews.llvm.org/D27819 llvm-svn: 290062
* build: add support for standalone lld buildSaleem Abdulrasool2016-12-121-1/+5
| | | | | | | | | | Enable building lld as a standalone project. This is motivated by the desire to package lld for inclusion in a linux distribution. This allows building lld against an existing paired llvm installation. Now that lld is usable on x86_64, it makes sense to revive this configuration to allow distributions to package it. llvm-svn: 289421
* Move Memory.{h,cpp} to lld/Support so that we can use them from COFF.Rui Ueyama2016-12-081-1/+1
| | | | llvm-svn: 289084
* Remove a file that is too short to be an independent file.Rui Ueyama2016-11-191-1/+0
| | | | | | | We have a .cpp and a .h for parseDynamicList(). This patch moves the function to DriverUtil.cpp. llvm-svn: 287468
* [CMake] NFC. Updating CMake dependency specificationsChris Bieneman2016-11-171-2/+4
| | | | | | This patch updates a couple places where add_dependencies was being explicitly called to add dependencies on intrinsics_gen to instead use the DEPENDS named parameter. This cleanup is needed for a patch I'm working on to add a dependency debugging mode to the build system. llvm-svn: 287205
* Create SyntheticSections.cpp.Rui Ueyama2016-11-011-0/+1
| | | | | | | | We are going to have many more classes for linker-synthesized input sections, so it's worth to be added to a separate file than to the file for regular input sections. llvm-svn: 285740
* Consolidate BumpPtrAllocators.Rui Ueyama2016-10-281-0/+1
| | | | | | | | | | | Previously, we have a lot of BumpPtrAllocators, but all these allocators virtually have the same lifetime because they are not freed until the linker finishes its job. This patch aggregates them into a single allocator. Differential revision: https://reviews.llvm.org/D26042 llvm-svn: 285452
* Don't create a dummy ELF to process a binary file.Rafael Espindola2016-10-271-1/+0
| | | | | | | Now that it is easy to create input section and symbols, this is simple. llvm-svn: 285322
* [ELF] Add DebugInfoDWARF dependencyGeorge Rimar2016-10-211-0/+1
| | | | | | | | | | | | | | | | rL284708 introduces a link error when building with BUILD_SHARED_LIBS: undefined reference to `llvm::DWARFContext::parseCompileUnits()' undefined reference to `llvm::DWARFContextInMemory::DWARFContextInMemory( llvm::object::ObjectFile const&, llvm::LoadedObjectInfo const*)' The functions are available in libDebugInfoDWARF, from llvm. Patch by Visoiu Mistrih Francis Differential revision: https://reviews.llvm.org/D25843 llvm-svn: 284810
* [ELF] - Partial support of --gdb-index command line option (Part 1).George Rimar2016-10-201-0/+1
| | | | | | | | | | | | | | | In this patch partial gdb_index section is created. For costructing the .gdb_index section 6 steps should be performed (details are in SplitDebugInfo.cpp file header), this patch do first 3: Creates proper section header. Fills list of compilation units. Types CU list area is not supposed to be supported, so it is ignored and therefore can be treated as implemented either. Differential revision: https://reviews.llvm.org/D24706 llvm-svn: 284708
* [ELF] Add support for -b binaryMichael J. Spencer2016-09-091-0/+1
| | | | | | | | | | Implemented by building an ELF file in memory. elf, default, and binary match gold behavior. Differential Revision: https://reviews.llvm.org/D24060 llvm-svn: 281108
* Fix shared library build.Rafael Espindola2016-09-061-0/+1
| | | | llvm-svn: 280753
* Refactor getMipsEFlags.Rui Ueyama2016-08-081-0/+1
| | | | | | | | | | | | | | | | | Previously, we incrementally updated the reuslting flag as we check file flags, so it was not very clear who is updating what flags. This patch makes them pure functions -- that has no side effect and don't update arguments to improve readability. Now each function construct a patial result, and all resutls are then bitwise-OR'ed to construct the final result. This patch also creates a new file, Mips.cpp, to move all these MIPS functions to a separate file. Differential Revision: https://reviews.llvm.org/D23249 llvm-svn: 278042
* COFF: Implement /linkrepro flag.Peter Collingbourne2016-07-261-0/+1
| | | | | | | | | | | | | | | | This flag is implemented similarly to --reproduce in the ELF linker. This patch implements /linkrepro by moving the cpio writer and associated utility functions to lldCore, and using that implementation in both linkers. One COFF-specific detail is that we store the object file from which the resource files were created in our reproducer, rather than the resource files themselves. This allows the reproducer to be used on non-Windows systems for example. Differential Revision: https://reviews.llvm.org/D22418 llvm-svn: 276719
* Recommit R274836 Add Thunk support framework for ARM and MipsPeter Smith2016-07-081-0/+1
| | | | | | | | | | | The TinyPtrVector of const Thunk<ELFT>* in InputSections.h can cause build failures on certain compiler/library combinations when Thunk<ELFT> is not a complete type or is an abstract class. Fixed by making Thunk<ELFT> non Abstract. type or is an abstract class llvm-svn: 274863
* Revert R274836 Add Thunk support framework for ARM and MipsPeter Smith2016-07-081-1/+0
| | | | | | | This seems to be causing a buildbot failure on lld-x86_64-freebsd. Will reproduce locally and fix. llvm-svn: 274841
* Add Thunk support framework for ARM and MipsPeter Smith2016-07-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | Generalise the Mips LA25 Thunk code and implement ARM and Thumb interworking Thunks. - Introduce a new module Thunks.cpp to store the Target Specific Thunk implementations. - DefinedRegular and Shared have a ThunkData field to record Thunk. - A Target can have more than one type of Thunk. - Support PC-relative calls to Thunks. - Support Thunks to PLT entries. - Existing Mips LA25 Thunk code integrated. - Support for ARMv7A interworking Thunks. Limitations: - Only one Thunk per SymbolBody, this is sufficient for all currently implemented Thunks. - ARM thunks assume presence of V6T2 MOVT and MOVW instructions. Differential revision: http://reviews.llvm.org/D21891 llvm-svn: 274836
* Create Strings.cpp and move string manipulation functions to that file.Rui Ueyama2016-06-291-0/+1
| | | | llvm-svn: 274109
* [LTO] Include ASM undefs in llvm.compiler_used.Davide Italiano2016-06-221-0/+1
| | | | | | | | | This fixes PR28218. Thanks to Rafael for spotting a failure in the SHARED_LIBS build! Differential Revision: http://reviews.llvm.org/D21577 llvm-svn: 273451
* Create Relocations.cpp and move scanRelocs there.Rui Ueyama2016-05-241-0/+1
| | | | | | | | | | scanReloc and the functions on which scanReloc depends is in total more than 600 lines of code. Since scanReloc does not depend on Writer, it is better to move it into a separate file. Differential Revision: http://reviews.llvm.org/D20554 llvm-svn: 270606
* Create a new file EhFrame.cpp and move code to read .eh_frame there.Rui Ueyama2016-05-241-0/+1
| | | | llvm-svn: 270526
OpenPOWER on IntegriCloud