Commit Graph

3789 Commits

Author SHA1 Message Date
Peter Collingbourne 402fbecc1a Core: Start using llvm/Support/thread.h to work around MSVC <thread> issues.
llvm-svn: 246219
2015-08-27 21:52:36 +00:00
Tom Stellard 8251f978d3 ELF/AMDGPU: Add more misssing: using namespace lld;
Hopefully, this will resolve the remaining windows bot errors.

llvm-svn: 246181
2015-08-27 18:43:12 +00:00
Tom Stellard 39b3d71177 ELF/AMDGPU: Add missing: using namespace lld; to try to fix windows bot
llvm-svn: 246179
2015-08-27 18:27:52 +00:00
Tom Stellard fbbbc01caa ELF/AMDGPU: Remove another unused private member variable
llvm-svn: 246164
2015-08-27 17:11:10 +00:00
Tom Stellard 36c6f6b874 ELF/AMDGPU: Remove unused private member variable
This should fix the one of the failing bots.

llvm-svn: 246160
2015-08-27 16:52:58 +00:00
Tom Stellard ff8dfbd965 ELF/AMDGPU: Attempt to fix windows bots
Broken by r246155.

llvm-svn: 246159
2015-08-27 16:48:46 +00:00
Tom Stellard 15d1fa1bcc ELF: Add AMDGPU ReaderWriter
This is a basic implementation that allows lld to emit binaries
consumable by the HSA runtime.

Differential Revision: http://reviews.llvm.org/D11267

llvm-svn: 246155
2015-08-27 15:55:44 +00:00
Davide Italiano 21e1cd79d0 [LinkerScript] Enforce uniqueness of output object files...
... in order to avoid conflicts when tests are run in parallel.
This is an attempt to fix PR24591.

llvm-svn: 246153
2015-08-27 15:18:43 +00:00
Rafael Espindola 0e0c1901c9 Start adding support for absolute symbols.
llvm-svn: 246147
2015-08-27 12:40:06 +00:00
Martell Malone 2a9098e529 lld-link: revert r246139 from OUTPUT to POST_BUILD
llvm-svn: 246140
2015-08-27 05:37:08 +00:00
Martell Malone 895f9a7422 lld-link: Unify symlink code with llvm-lib
llvm-svn: 246139
2015-08-27 05:18:36 +00:00
Rafael Espindola e11c6d2d6f Set the symbol size in the symbol table.
llvm-svn: 246086
2015-08-26 21:46:24 +00:00
Rafael Espindola 034e2e7a8e Define types close to use. NFC.
llvm-svn: 246085
2015-08-26 21:42:36 +00:00
Rafael Espindola b85b4079f1 git-clang-format the constructor to reduce the diff in a merge.
llvm-svn: 246076
2015-08-26 20:46:55 +00:00
Rui Ueyama c0c74e1b8a COFF: Print out module-definition files if /verbose is given.
This is useful for testing.

llvm-svn: 246032
2015-08-26 12:37:54 +00:00
Rui Ueyama 2caf407107 COFF: Show real command line options if /verbose is given.
llvm-svn: 246023
2015-08-26 07:12:08 +00:00
Rui Ueyama d020c65d24 COFF: Attempt to unbreak buildbots.
This is an attempt to unbreak http://reviews.llvm.org/P122.

llvm-svn: 246000
2015-08-26 02:52:05 +00:00
Rafael Espindola f3837074cc Set the symbol value in the symbol table.
llvm-svn: 245943
2015-08-25 15:53:17 +00:00
Peter Collingbourne 0bb50d92b6 COFF: Update for LTO API change.
llvm-svn: 245892
2015-08-24 22:22:58 +00:00
Rafael Espindola 5cd113df01 Diagnose symbols with invalid section indexes.
llvm-svn: 245884
2015-08-24 22:00:25 +00:00
Rafael Espindola 2034822981 Add support for reading files with more than 0xff00 sections.
llvm-svn: 245880
2015-08-24 21:43:25 +00:00
Rafael Espindola 832b93f219 Start recording the section of symbols in the symbol table.
Support for more than 64 K sections to follow shortly.

llvm-svn: 245868
2015-08-24 20:06:32 +00:00
Rafael Espindola c5c82916e4 Read the alignment only when used.
The rest of the header was already read lazily, no point in having align be
special.

llvm-svn: 245863
2015-08-24 19:28:31 +00:00
Rafael Espindola e6f52102a3 Remove a duplicated member variable. NFC.
This just makes it clear that, for now, there is only one symbol table.

llvm-svn: 245844
2015-08-24 14:48:18 +00:00
Rui Ueyama 473aa4088d COFF: Add a test for ICF and circular references.
ICF is a feature to merge sections not by name (which is the regular
COMDAT merging) but by contents. If two or more sections have the
identical contents and relocations, ICF merges them to save space.
Accessors or templated functions tend to have the same contents, and
ICF can hold them.

If we consider sections as vertices and relocations as edges, the
problem is to find as many isomorphic graphs as possile from input
graphs. MSVC linker is smart enough to identify isomorphic graphs
even if they contain circles (GNU gold cannot handle circles
according to http://research.google.com/pubs/pub36912.html, so this
is impressive).

Circular references are not uncommon in COFF object files.
One example is .pdata. .pdata sections contain exception handler info
for functions, so they naturally have relocations for the functions.
The functions in turn have references to the .pdata sections so that
the functions and their .pdata are linked together. As a result, they
form circles.

This is a test case for circular graphs. LLD is not able to handle
this test case yet. I'll add code soon.

llvm-svn: 245827
2015-08-24 08:11:53 +00:00
Rui Ueyama 28103266c6 COFF: Update a test for ICF.
The old test files were just compiler outputs, so it was hard to
debug if something goes wrong. The new test file is carefully
hand-crafted to trigger ICF to avoid that.

llvm-svn: 245826
2015-08-24 07:52:08 +00:00
Davide Italiano b3c7fb7f24 [LinkerScript] Fix a crash when matching wildcards.
Submitted by:	  zan jyu via llvm-dev

llvm-svn: 245792
2015-08-22 20:36:19 +00:00
Rui Ueyama 6a883b086e COFF: Improve debug helper function.
SectionChunk::getDebugName crashed if the symbol was a nullptr.

llvm-svn: 245677
2015-08-21 07:01:10 +00:00
Rui Ueyama d2d2360222 COFF: Fix /lldmap option.
isLive returns false if it's not COMDAT, so check for that condition.

llvm-svn: 245676
2015-08-21 07:01:08 +00:00
Simon Atanasyan 814b705984 [Mips] Use 'or' for move instead of [d]addu in PLT entries
Patch by Simon Dardis.

Differential Revision: http://reviews.llvm.org/D12103

llvm-svn: 245491
2015-08-19 20:20:10 +00:00
Rui Ueyama 04ec69aa9e COFF: Use ErrorOr::operator* instead of ErrorOr::get.
This patch is to make COFF coding style consistent with ELF. NFC.

llvm-svn: 245282
2015-08-18 09:18:15 +00:00
Rui Ueyama 570752c7ac Do not use unique pointers. NFC.
These unique pointers have the exact same lifetime as automatic
variables, so use automatic variables instead.

llvm-svn: 245281
2015-08-18 09:13:25 +00:00
Rui Ueyama 95b781d863 COFF: Do not handle __NULL_IMPORT_DESCRIPTOR differently than the other symbols.
__NULL_IMPORT_DESCRIPTOR is a symbol used by MSVC liner to construct
the import descriptor table. We do not use the symbol. Previously,
we had code to skip that symbol. That code does not actually do
anything meaningful because no one is referencing the symbol, the
symbol would naturally be ignored. This patch stops recognizing
the symbol.

llvm-svn: 245280
2015-08-18 09:06:41 +00:00
Rui Ueyama 0081f91853 Create lld-link symlink on "make/ninja/whatever install".
llvm-svn: 245266
2015-08-18 04:24:46 +00:00
Rui Ueyama 7171c82194 COFF: Allow forward reference for weak externals
Previously, weak external symbols could reference only symbols that
appeared before them. Although that covers almost all use cases
of weak externals, there are object files out there which contains
weak externals that have forward references.

This patch supports such weak externals.

llvm-svn: 245258
2015-08-17 23:35:43 +00:00
Rui Ueyama 27716bb9d9 COFF: Fix a broken test.
This test couldn't be run more than once because lib.exe does not work
if the files already exist.

llvm-svn: 245214
2015-08-17 11:06:21 +00:00
Rui Ueyama d157088adb COFF: Fix the order of the DLL import entry.
There are some DLLs whose initializers depends on other DLLs'
initializers. The initialization order matters for them.

MSVC linker uses the order of the libraries from the command line.
LLD used ASCII-betical order. So they were incompatible.
This patch makes LLD compatible with MSVC.

llvm-svn: 245201
2015-08-17 08:30:31 +00:00
Rui Ueyama e73e418bb4 COFF: Simplify Writer::createImportTables.
A short import library has up to two symbols, so we don't have
to do a for-loop and type dispatch in createImportTables.

llvm-svn: 245200
2015-08-17 07:27:45 +00:00
Rafael Espindola 1bd885aba4 ELF: Also record the type of undefined symbols.
Tested with a weak undefined. Testing with a plain undefined will have to wait
for support for -shared.

llvm-svn: 245069
2015-08-14 16:46:28 +00:00
Rafael Espindola bd481b8f89 Fix the build with gcc.
llvm-svn: 245060
2015-08-14 15:20:34 +00:00
Rafael Espindola c44d17ad45 Add the type of the symbols to the symbol table.
For now only defined symbols are covered. I will add undefined ones in the
next patch.

llvm-svn: 245057
2015-08-14 15:10:49 +00:00
Rafael Espindola 457c940835 Delete dead code.
llvm-svn: 245056
2015-08-14 14:58:57 +00:00
Rafael Espindola 4c3aa0f228 Delete unused forward declarations.
llvm-svn: 245055
2015-08-14 14:51:11 +00:00
Rafael Espindola 3bf356ee9c Remove unused default values.
llvm-svn: 245053
2015-08-14 14:38:44 +00:00
Rafael Espindola beee25e484 Make these headers as being c++.
llvm-svn: 245050
2015-08-14 14:12:54 +00:00
Rafael Espindola 383c323d4d ELF: Set the correct symbol binding.
llvm-svn: 245049
2015-08-14 13:52:36 +00:00
Rafael Espindola 62b81b875a Start populating the symbol table.
With this patch only the name is set. I will set the other fields shortly.

For now the table doesn't include local symbols. This is equivalent to using
--discard-all with gnu ld. This is OK for now since the symbols are not
needed for execution and for testing symbol resolution we only need the
global symbols.

llvm-svn: 245044
2015-08-14 13:07:05 +00:00
Rui Ueyama 8050d32b13 ELF2: Rename a function to make it the same as the COFF's counterpart.
llvm-svn: 245030
2015-08-14 05:17:30 +00:00
Peter Collingbourne 526ff15546 COFF: Introduce flag /opt:lldlto=N for controlling LTO optimization level.
Differential Revision: http://reviews.llvm.org/D12024

llvm-svn: 245027
2015-08-14 04:47:07 +00:00
Rafael Espindola 5c546a1437 COFF: In chunks, store the offset from the start of the output section. NFC.
This is more convenient than the offset from the start of the file as we
don't have to worry about it changing when we move the output section.

This is a port of r245008 from ELF.

llvm-svn: 245018
2015-08-14 03:30:59 +00:00