aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2015-07-23Merging r242885:release_37Hans Wennborg
------------------------------------------------------------------------ r242885 | atanasyan | 2015-07-22 03:32:19 -0700 (Wed, 22 Jul 2015) | 4 lines [ELF] Protect write access to the ELFLinkingContext::_cidentSections by a mutex The _cidentSections container is filled during files parsing so we need to serialize a concurrent access to it. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/lld/branches/release_37@243022 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14Creating release_37 branch off revision 242221Hans Wennborg
git-svn-id: https://llvm.org/svn/llvm-project/lld/branches/release_37@242233 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14Update for llvm api change.Rafael Espindola
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242216 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14Use getChildOffset instead of getBuffer for identifying a member.Rafael Espindola
I am adding support for thin archives. On those, getting the buffer involves reading another file. Since we only need an id in here, use the member offset in the archive. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242205 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14[ELF/AArch64] Fix export TLS dynamic symbolAdhemerval Zanella
This patch fixes the TLS dynamic variable exportation from .got.plt segments, created by General-dynamic relocations (TLSDESC). Current code only export symbols in dynamic table from .got sections. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242142 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14Revert ELF port. Posting to mailing list.Michael J. Spencer
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242118 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14Revert "Make COFF linker work when it's built by clang again."Rui Ueyama
This reverts commit r242006. The original issue in Clang was fixed in r242009, so we can now safely use std::atomic_flag. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242112 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14COFF: Fix entry name inference for x86.Rui Ueyama
Entry name selection rule is already complicated on x64, but it's more complicated on x86 because of the underscore name mangling scheme. If one of _main, _main@<number> (a C function) or ?main@@... (a C++ function) is defined, entry name is _mainCRTStartup. If _wmain, _wmain@<number or ?wmain@@... is defined, entry name is _wmainCRTStartup. And so on. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242110 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14Fix warnings.Michael J. Spencer
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242098 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14[LinkerScript] Don't create unnecessarily large segmentsRafael Auler
When using a linker script expression to change the address of a section, even if the new address is more than a page of distance from the old address, lld may put everything in the same segment, forcing it to be unnecessarily large. This patch changes the logic in Segment::assignVirtualAddress() and Segment::assignFileOffsets() to allow the segment to be sliced into two or more if it detects a linker script expression that changes a section address. Differential Revision: http://reviews.llvm.org/D10952 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242096 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14Put explicit template instantiations in the correct namespace.Michael J. Spencer
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242093 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14Remove commented out code.Michael J. Spencer
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242092 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-13[LinkerScript] Fix bug in Segment::assignVirtualAddress()Rafael Auler
When calculating the start address and size of a segment, lld mistakenly attributed the start address of the last segment slice to the whole segment when it should consider the start address of the first slice. In this case, in a multi-slice segment, Segment::assignVirtualAddress() will return a wrong segment start address to TargetLayout::assignVirtualAddress(). The effect of this miscalculation is to allocate some program headers in unnecessarily far away addresses. This commit fixes this. Differential Revision: http://reviews.llvm.org/D10951 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242089 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-13Initial ELF port.Michael J. Spencer
This is a direct port of the new PE/COFF linker to ELF. It can take a single object file and generate a valid executable that executes at the first byte in the text section. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242088 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-13COFF: Fix x86 delay-load helper function name.Rui Ueyama
If /delayload option is given, we have to resolve __delayLoadHelper2 since the function is the dynamic loader to delay-load DLLs. The function name is mangled in x86 as ___delayLoadHelper2@8. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242078 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-13COFF: Inline Defined::getRVA because it's very hot.Rui Ueyama
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242075 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-13COFF: Split createSymbolAndSymbolTable to small functions. NFC.Rui Ueyama
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242066 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-13[Mips] Support MIPS big-endian 32/64-bits targetsSimon Atanasyan
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242014 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-13Make COFF linker work when it's built by clang again.Nico Weber
clang-cl doesn't compile std::atomic_flag correctly (PR24101). Since the COFF linker doesn't use threads yet, just revert r241420 and r241481 for now to work around this clang-cl bug. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242006 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-13Fix lld tests with LLVM_ENABLE_THREADS disabled.Nico Weber
With LLVM_ENABLE_THREADS disabled, all the llvm code assumes that it runs on a single thread and doesn't use any mutexes. lld still spawned lots of threads in that case and called into llvm, assuming that llvm is thread-safe. As fix, let lld use only a single thread if LLVM_ENABLE_THREADS is disabled. I left in all the mutexes in lld. That means lld is a bit slower than necessary in single-thread mode, but that's probably worth the simpler code. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@242004 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-12elf: Make error output from AtomSection<ELFT>::write() deterministic.Nico Weber
The function uses parallel_for() and then writes error messages from the parallel loop's body. This produces nondetermistic error messages. Instead, copy error messages to a vector and sort it by the atom's file offsets before printing all error messages after the parallel_for(). This results in a few string copies, but only in the error case. (And passing tests seem more important than performance.) This makes tests elf/AArch64/rel-prel16-overflow.test and elf/AArch64/rel-prel32-overflow.test pass on Windows: Both tests check that atom error messages are emitted in a certain order, and on Windows they happened to be emitted in a different order before this patch. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241988 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-10COFF: Fix locally-imported symbol's base relocations.Rui Ueyama
Base relocations are RVA and not VA, so we shouldn't add ImageBase. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241883 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09COFF: Find C++ mangled name for symbols starting with underscore.Rui Ueyama
Symbol foo is mangled as _foo in C and ?foo@@... in C++ on x86. findMangle has to remove prefix underscore before mangle a given name as a C++ symbol. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241874 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09COFF: Fix dllexported symbol names on x86.Rui Ueyama
Symbol names are usually mangled by appending "_" prefix on x86. But the mangled name is not used in DLL export table. The export table contains unmangled names. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241872 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09COFF: Fix locally-imported symbol's size for x86.Rui Ueyama
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241860 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09COFF: Implement base relocations for x86.Rui Ueyama
With this patch, LLD is now able to self-link an .exe file for x86 that runs correctly, although I don't think some headers (particularly SEH) are not correct. DLL support is coming soon. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241857 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09COFF: Fix import symbol name mangling.Rui Ueyama
For IMPORT_NAME_NOPREFIX symbols, we should remove only one prefix character. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241854 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09COFF: Fix command line options for external commands.Rui Ueyama
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241853 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09COFF: Infer machine type earlier than before.Rui Ueyama
Previously, we infer machine type at the very end of linking after all symbols are resolved. That's actually too late because machine type affects how we mangle symbols (whether or not we need to add "_"). For example, /entry:foo adds "_foo" to the symbol table if x86 but "foo" if x64. This patch moves the code to infer machine type, so that machine type is inferred based on input files given via the command line (but not based on .directives files). git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241843 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09COFF: Make /machine:{i386,amd64} aliases to {x86,x64}.Rui Ueyama
MSVC linker accepts these aliases. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241840 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09COFF: Fill in the type and storage class in the symbol tableDavid Majnemer
We can use the type and storage class from the symbol's original object file to fill in the linked executable's symbol table. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241828 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09COFF: Remove Writer::Is64 and use Config::is64 instead. NFC.Rui Ueyama
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241819 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09COFF: Fix import thunks and name mangling for x86.Rui Ueyama
With this patch, LLD is now able to correctly link a "hello world" program written in assembly for 32-bit x86. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241771 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09COFF: Support 32-bit x86 DLL import table.Rui Ueyama
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241767 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08Update for upcoming llvm change.Rafael Espindola
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241746 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08COFF: Remove dead code.Rui Ueyama
r241647 made Driver to infer machine type, so this code is not actually in use. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241720 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08COFF: Implement dllimported symbol name mangling.Rui Ueyama
Symbols exported by DLLs are listed in import library files. Exported names may be mangled by "Import Name Type" field as described in PE/COFF spec 7.3. This patch implements that mangling scheme. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241719 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08COFF: Set parent name for bitcode files.Peter Collingbourne
Differential Revision: http://reviews.llvm.org/D10983 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241713 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08COFF: Handle /machine option in a similar manner for other options. NFC.Rui Ueyama
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241701 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08Create lld-link2 symlink/copy for new COFF linker.Peter Collingbourne
This situation will only be temporary; I imagine we will eventually want to have the new linker take the lld-link alias after we remove the old one. However, I would like to port the CFI test suite in the compiler-rt repository to Windows using the new COFF linker's LTO support; these tests currently use gcc-style command lines and invoke the linker via the compiler driver. We can select the linker using the -fuse-ld flag, which Clang supports on Windows, but it takes an executable name, rather than a list of arguments (so "-fuse-ld=lld -flavor link2" wouldn't work), and it doesn't seem worth the effort to extend the Clang driver to support arguments. Differential Revision: http://reviews.llvm.org/D11031 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241696 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08COFF: Emit a symbol table if /debug is specifiedDavid Majnemer
Providing a symbol table in the executable is quite useful when debugging a fully-linked executable without having to reconstruct one from DWARF. Differential Revision: http://reviews.llvm.org/D11023 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241689 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08The LLD tests require 'llvm-lib', ensure that this is built.Simon Atanasyan
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241676 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08COFF: Fix AMD64_SECTION relocation.Rui Ueyama
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241658 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08COFF: Support x86 file header and relocations.Rui Ueyama
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241657 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07COFF: Check for incompatible machine types.Rui Ueyama
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241647 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07COFF: Split writeTo in preparation for supporting 32-bit x86.Rui Ueyama
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241638 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07COFF: Improve undefined symbol diagnostics.Peter Collingbourne
We now report the names of any files containing undefined symbol references. Differential Revision: http://reviews.llvm.org/D10982 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241612 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07COFF: Fix bug involving archives defining a symbol multiple times.Peter Collingbourne
Previously we were unnecessarily loading lazy symbols if they appeared in an archive multiple times, as can happen with comdat symbols. This change fixes the bug by only loading symbols from archives at load time if the original symbol was undefined. Differential Revision: http://reviews.llvm.org/D10980 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241538 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07Fix undefined behaviour exposed by the new -Wshift-negative-value warning.Davide Italiano
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241530 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-06Update for llvm change.Rafael Espindola
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@241489 91177308-0d34-0410-b5e6-96231b3b80d8