Commit Graph

10957 Commits

Author SHA1 Message Date
Igor Kudrin 4f48b3ef90 [ELF] Update addends in non-allocatable sections for REL targets when creating a relocatable output.
This fixes PR37735.

Differential Revision: https://reviews.llvm.org/D48929

llvm-svn: 336799
2018-07-11 12:52:04 +00:00
George Rimar fd6af6dc98 [ELF] - Report proper error message about mixing bitcode files.
If we have 2 bitcode inputs for different targets, LLD would
print "<internal>" instead of the name of one of the files.

The patch adds a test and fixes this issue.

llvm-svn: 336794
2018-07-11 12:32:00 +00:00
Rui Ueyama eca0e633d1 Remove dead code.
llvm-svn: 336791
2018-07-11 11:52:13 +00:00
Rui Ueyama d29c039119 Parallelize GdbIndexSection's symbol table creation.
Since .gdb_index sections contain all known symbols, they can be very large.
One of my executables has a .gdb_index section of 1350 GiB. Uniquifying
symbols by name takes 3.77 seconds on my machine. This patch parallelize it.

  Time to call createSymbols() with 8.4 million unique symbols:

  Without this patch: 3773 ms
  Parallelism = 1:    4374 ms
  Parallelism = 2:    2628 ms
  Parallelism = 16:    837 ms

As you can see above, this algorithm is a bit more inefficient
than the non-parallelized version, but even with dual-core, it is
faster than that, so I think it is overall a win.

Differential Revision: https://reviews.llvm.org/D49164

llvm-svn: 336790
2018-07-11 11:37:10 +00:00
Rui Ueyama f51c853cf1 Remove a workaround for an old GCC bug.
This workaround is for GCC 5.4.1. Without this workaround, lld will
produce larger .gdb_index sections for object files compiled with the
buggy version of the compiler.

Since it is not for correctness, and it affects only debug builds (since
you are generating .gdb_index sections), perhaps the hack shouldn't have been
added in the first place. At least, I think it is time to remove this hack.

Differential Revision: https://reviews.llvm.org/D49149

llvm-svn: 336788
2018-07-11 10:52:00 +00:00
Rui Ueyama f3731d4e9c Refactor GdbIndexSection. NFC.
This patch merges createGdbIndex function and GdbIndexSection's
constructor into a single static member function of the class.

This patch also change how we keep CU vectors. Previously, CuVector
and GdbSymbols were parallel arrays, but there's no reason to choose that
design. Now, CuVector is a member of GdbSymbol class.

A lot of members are removed from GdbIndexSection. Previously, it has
members that need to be kept in sync over several phases. I belive the new
design is less error-prone, and the new code is much easier to read
than before.

llvm-svn: 336743
2018-07-10 23:48:27 +00:00
Simon Atanasyan 64fb2901e5 [ELF][MIPS] Add mote tests on MipsArchTree routines, fix typos in error messages
This fix add more test cases for routines check MIPS ELF header flags and
flags from .MIPS.abiflags sections. The tests use yaml2obj for object
files generation because not all combinations of flags can be produced
by LLVM tools.

llvm-svn: 336704
2018-07-10 16:51:17 +00:00
Rui Ueyama 2b9b85f2bf Initialize a variable properly to fix buildbots.
llvm-svn: 336700
2018-07-10 16:26:15 +00:00
Rui Ueyama 09b373845a Make a struct type declaration private. NFC.
llvm-svn: 336690
2018-07-10 15:57:25 +00:00
Rui Ueyama bee192f6b0 Simplify. NFC.
llvm-svn: 336686
2018-07-10 15:15:56 +00:00
Rui Ueyama 3467fac091 Rename a variable for consistency. NFC.
llvm-svn: 336674
2018-07-10 14:03:39 +00:00
Rui Ueyama 7f112ea26d Reduce memory usage when creating .gdb_index. NFC.
.gdb_index sections can be very large. When you are compiling
multi-gibibyte executables, they can be larger than 1 GiB. The previous
implementation of .gdb_index seems to consume too much memory.

This patch reduces memory consumption by eliminating temporary objects.
In one experiment, memory consumption of GdbIndexSection class is
reduced from 962 MiB to 228 MiB when creating a .gdb_index of 1350 GiB.

Differential Revision: https://reviews.llvm.org/D49094

llvm-svn: 336672
2018-07-10 13:49:13 +00:00
George Rimar 92108de572 [ELF] - Add a test for readCallGraph() code.
This is to test the following untested line:
https://github.com/llvm-mirror/lld/blob/master/ELF/Driver.cpp#L643

llvm-svn: 336670
2018-07-10 13:42:21 +00:00
Martin Storsjo 474be005db [COFF] Store import symbol pointers as pointers to the base class
Future symbol insertions can potentially change the type of these
symbols - keep pointers to the base class to reflect this, and
use dynamic casts to inspect them before using as the subclass
type.

This fixes crashes that were possible before, by touching these
symbols that now are populated as e.g. a DefinedRegular, via
the old pointers with DefinedImportThunk type.

Differential Revision: https://reviews.llvm.org/D48953

llvm-svn: 336652
2018-07-10 10:40:11 +00:00
George Rimar bc6702a424 [ELF] - Improve call graph pasing error reporting.
This adds a file name to the error message,
adds a missing test case and refactors code a bit. 

llvm-svn: 336651
2018-07-10 10:28:55 +00:00
George Rimar 20b92c4d0d [ELF] - Report call graph profile file names in error messages.
We did not report file names for some reason.

llvm-svn: 336650
2018-07-10 10:16:48 +00:00
Rui Ueyama 2a3036fb1d Report an error for an extremely large .gdb_index section.
I believe the only way to test this functionality is to create extremely
large object files and attempt to create a .gdb_index that is greater
than 4 GiB. But I think that's too much for most environments and buildbots,
so I'm commiting this without a test that actually triggers the new
error condition.

llvm-svn: 336631
2018-07-10 01:22:25 +00:00
Rui Ueyama a9e169edff Fix a bug for packed relocations.
Previously, we didn't create multiple consecutive bitmaps.
Added a test to catch this bug too.

Differential Revision: https://reviews.llvm.org/D49107

llvm-svn: 336620
2018-07-09 23:54:24 +00:00
Rui Ueyama 703c872a4a Simplify RelrSection<ELFT>::updateAllocSize.
This patch also speeds it up by making some constants compile-time
constants. Other than that, NFC.

Differential Revision: https://reviews.llvm.org/D49101

llvm-svn: 336614
2018-07-09 22:29:57 +00:00
Rui Ueyama 3e730b8ae6 Fix direct calls to __wrap_sym when it is relocated.
Patch by Matthew Koontz!

Before, direct calls to __wrap_sym would not map to valid PLT entries,
so they would crash at runtime. This change maps such calls to the same
PLT entry as calls to sym that are then wrapped.

Differential Revision: https://reviews.llvm.org/D48502

llvm-svn: 336609
2018-07-09 22:03:05 +00:00
Rui Ueyama 45192b3746 Factor out code to parse -pack-dyn-relocs. NFC.
llvm-svn: 336599
2018-07-09 20:22:28 +00:00
Rui Ueyama 11479daf2f lld: add experimental support for SHT_RELR sections.
Patch by Rahul Chaudhry!

This change adds experimental support for SHT_RELR sections, proposed
here: https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg

Pass '--pack-dyn-relocs=relr' to enable generation of SHT_RELR section
and DT_RELR, DT_RELRSZ, and DT_RELRENT dynamic tags.

Definitions for the new ELF section type and dynamic array tags, as well
as the encoding used in the new section are all under discussion and are
subject to change. Use with caution!

Pass '--use-android-relr-tags' with '--pack-dyn-relocs=relr' to use
SHT_ANDROID_RELR section type instead of SHT_RELR, as well as
DT_ANDROID_RELR* dynamic tags instead of DT_RELR*. The generated
section contents are identical.

'--pack-dyn-relocs=android+relr --use-android-relr-tags' enables both
'--pack-dyn-relocs=android' and '--pack-dyn-relocs=relr': lld will
encode the relative relocations in a SHT_ANDROID_RELR section, and pack
the rest of the dynamic relocations in a SHT_ANDROID_REL(A) section.

Differential Revision: https://reviews.llvm.org/D48247

llvm-svn: 336594
2018-07-09 20:08:55 +00:00
Zaara Syeda 75c348a097 [PPC64] Add TLS local dynamic to local exec relaxation
This patch adds the target call back relaxTlsLdToLe to support TLS relaxation
from local dynamic to local exec model.

Differential Revision: https://reviews.llvm.org/D48293

llvm-svn: 336559
2018-07-09 16:35:51 +00:00
Zachary Turner 648bebdc67 [PDB] One more fix for hasing GSI records.
The reference implementation uses a case-insensitive string
comparison for strings of equal length.  This will cause the
string "tEo" to compare less than "VUo".  However we were using
a case sensitive comparison, which would generate the opposite
outcome.  Switch to a case insensitive comparison.  Also, when
one of the strings contains non-ascii characters, fallback to
a straight memcmp.

The only way to really test this is with a DIA test.  Before this
patch, the test will fail (but succeed if link.exe is used instead
of lld-link).  After the patch, it succeeds even with lld-link.

llvm-svn: 336464
2018-07-06 21:01:42 +00:00
George Rimar 475dc96901 [ELF] - Add test for empty version in a symbol name.
This covers the following line which was untested:
https://github.com/llvm-mirror/lld/blob/master/ELF/Symbols.cpp#L170

llvm-svn: 336443
2018-07-06 15:03:53 +00:00
George Rimar e5cd32b702 [ELF] - Remove dead code #2.
'Pos' is never can be 0 here.

llvm-svn: 336436
2018-07-06 13:30:50 +00:00
George Rimar 92bd49e874 [ELF] - Remove dead code. NFC.
'Pos' can never be 0.

llvm-svn: 336435
2018-07-06 13:23:49 +00:00
Hans Wennborg b09e004cde Relax filechecks in r336405 tests
They were failing in Chromium's packaging builds with:

  C:\b\rr\tmphqfaff\w\src\third_party\llvm\tools\lld\test\COFF\pdb-globals-dia-vfunc-collision2.test:24:8:
  error: expected string not found in input
  CHECK: func [0x00001060+ 0 - 0x0000106c-12 | sizeof= 12] (FPO) virtual int __cdecl A132()
         ^
  <stdin>:8:11: note: scanning from here
   struct S [sizeof = 8] {
            ^
  <stdin>:9:2: note: possible intended match here
   func [0x00001060+ 0 - 0x0000106c-12 | sizeof= 12] (FPO) virtual int __cdecl S::A132()
   ^

Maybe due to different DIA versions.

llvm-svn: 336424
2018-07-06 08:44:08 +00:00
Hans Wennborg bf7caf4232 dos2unix
llvm-svn: 336423
2018-07-06 08:44:04 +00:00
Simon Atanasyan 78c46bdf52 [ELF][MIPS] Simplify `checkFlags` routine and inline `rejectMicroMips64`. NFC
llvm-svn: 336414
2018-07-06 05:50:46 +00:00
Simon Atanasyan 0905b953da [ELF][MIPS] Remove support for linking microMIPS 64-bit code
Remove support for linking microMIPS 64-bit code because this kind of
ISA is rarely used and unsupported by LLVM.

Differential revision: https://reviews.llvm.org/D48949

llvm-svn: 336413
2018-07-06 05:50:41 +00:00
Zachary Turner 457cc34e48 [llvm-pdbutil] Dump more info about globals.
We add an option to dump the entire global / public symbol record
stream.  Previously we would dump globals or publics, but not both.
And when we did dump them, we would always dump them in the order
they were referenced by the corresponding hash streams, not in
the order they were serialized in.  This patch adds a lower level
mode that just dumps the whole stream in serialization order.

Additionally, when dumping global-extras, we now dump the hash
bitmap as well as the record offset instead of dumping all zeros
for the offsets.

llvm-svn: 336407
2018-07-06 02:59:25 +00:00
Zachary Turner 1f200adfa7 [PDB] Sort globals symbols by name in GSI hash buckets.
It seems like the debugger first computes a symbol's bucket,
and then does a binary search of entries in the bucket using the
symbol's name in order to find it.  If the bucket entries are not
in sorted order, this obviously won't work.  After this patch a
couple of simple test cases show that we generate an exactly
identical GSI hash stream, which is very nice.

llvm-svn: 336405
2018-07-06 02:33:58 +00:00
Rui Ueyama a8db71f06f Remove redundnat call of makeArrayRef(). NFC.
llvm-svn: 336378
2018-07-05 17:14:33 +00:00
Rui Ueyama 5ba7266761 Simplify PPC64::calcEFlags().
In this file we only have to handle the v2 ABI, so what we need to do
is to just make sure that all object files have v2 or unspecified version
number.

Differential Revision: https://reviews.llvm.org/D48112

llvm-svn: 336372
2018-07-05 16:58:42 +00:00
Rui Ueyama 53ec0a075d Make a test more robust.
Reported by Chris Jackson.

llvm-svn: 336366
2018-07-05 16:03:20 +00:00
George Rimar 061af9aafa [ELF] - Add test case for checking PT_INTERP behavior.
When PT_INTERP is specified in PHDRS command, it should be created.
(if other conditions met)

We had no test for the folowing line:
https://github.com/llvm-mirror/lld/blob/master/ELF/LinkerScript.cpp#L1108
And for this header itself.

Patch fixes that.

llvm-svn: 336359
2018-07-05 15:01:44 +00:00
George Rimar 732a1e52b9 [ELF] - Eliminate dead "if". NFC.
We call switchTo() from assignAddresses() for switching to Aether,
and from assignOffsets().

First calls assignOffsets() one by one for each output section.
(https://github.com/llvm-mirror/lld/blob/master/ELF/LinkerScript.cpp#L1045)

That I believe means the condition removed in this patch is dead.

llvm-svn: 336356
2018-07-05 14:27:36 +00:00
George Rimar ccf0db9974 [ELF] - Convert excessive dyn_cast -> cast. NFC.
Currently, there are only OutputSection and SymbolAssignment
commands possible at the first level under SECTIONS tag.

Hence, dyn_cast was excessive.

llvm-svn: 336354
2018-07-05 14:09:47 +00:00
George Rimar d87b1eed8e [ELF] - Test we are able to assign version to symbols that are not "_Z*"
This is to test the following line of the code:
https://github.com/llvm-mirror/lld/blob/master/ELF/SymbolTable.cpp#L681

If symbol does not start from _Z prefix and we have extern "C++",
we do not call demangler and use its name as is.

llvm-svn: 336353
2018-07-05 14:01:54 +00:00
George Rimar 8ac85d9a11 [ELF] - Check we do not assign version to undefined symbol when using extern C++.
This tests the following 'continue' line in getDemangledSyms():
https://github.com/llvm-mirror/lld/blob/master/ELF/SymbolTable.cpp#L677

llvm-svn: 336349
2018-07-05 13:39:39 +00:00
George Rimar 2d55b36aac [ELF] - Add test to check we don't crash when tracing reserved symbol.
This is to test the following line of code:
https://github.com/llvm-mirror/lld/blob/master/ELF/SymbolTable.cpp#L601

Without that line linker would crash.

llvm-svn: 336345
2018-07-05 12:48:29 +00:00
George Rimar 889a161b4f [ELF] - Test LLD creates empty .imports file.
This covers the following code line with a test:
https://github.com/llvm-mirror/lld/blob/master/ELF/LTO.cpp#L213

After that, coverage of LTO.cpp is 100%.

llvm-svn: 336342
2018-07-05 12:23:37 +00:00
George Rimar 72ceddab7b [ELF] - Add test to check we produce an error if unable to write an empty index file.
Test case ensures lld generates an error if unable to
write an empty index file for lazy object file that is not added to link.

This covers the following line with a test:
https://github.com/llvm-mirror/lld/blob/master/ELF/LTO.cpp#L206

llvm-svn: 336340
2018-07-05 12:12:30 +00:00
George Rimar 046fa610e0 [ELF] - Remove dead code. NFC.
I think code is dead, because the only way to see
Path as empty seems would be if replaceThinLTOSuffix()
replaced some prefix with empty prefix (making the result
Path empty).

But it is impossible to pass the empty prefix,
we would file in driver:
https://github.com/llvm-mirror/lld/blob/master/ELF/Driver.cpp#L669

llvm-svn: 336338
2018-07-05 11:58:04 +00:00
George Rimar 9b99abcf99 [ELF] - Advance position in a memory region when change the Dot.
This is https://bugs.llvm.org//show_bug.cgi?id=37836

Previously LLD could assign to Dot or set the address
for the section with address expression but did not advance
the position in a memory region.

Patch fixes the issue.

llvm-svn: 336335
2018-07-05 10:44:17 +00:00
George Rimar 6a7c7f3915 [ELF] - Simplify. NFC.
Currently, there are only OutputSection and SymbolAssignment
commands possible at the first level under SECTIONS tag.

So, shouldSkip() contained dead "return true".

Patch simplifies the code.

llvm-svn: 336282
2018-07-04 15:05:21 +00:00
George Rimar 0fc47bea90 [ELF] - Extend edata-etext.s test case.
We did not have a test that would test that
_etext address is equal to etext, _end == end and _edata == edata.

Because of that, the following line was never
executed when running our tests:
https://github.com/llvm-mirror/lld/blob/master/ELF/Writer.cpp#L928

Patch fixes that.

llvm-svn: 336280
2018-07-04 14:47:19 +00:00
George Rimar aef7413962 [ELF] - Cover handling of DW_AT_external with test.
The following check was uncovered with tests:
https://github.com/llvm-mirror/lld/blob/master/ELF/InputFiles.cpp#L159

Patch adds test to cover it.

llvm-svn: 336273
2018-07-04 14:04:59 +00:00
George Rimar 6906f4ec9c [ELF] - LTO: add test for createEmptyIndex.
We have a following comment for createEmptyIndex caller code:

// If LazyObjFile has not been added to link, emit empty index files.
// This is needed because this is what GNU gold plugin does and we have a
// distributed build system that depends on that behavior.
  
Though createEmptyIndex() itself
(https://github.com/llvm-mirror/lld/blob/master/ELF/LTO.cpp#L202)
is never called in our test cases. 

Patch adds a test.

llvm-svn: 336270
2018-07-04 13:36:45 +00:00