Commit Graph

5016 Commits

Author SHA1 Message Date
Fangrui Song 95851515d7 Add a CIE with length 0 unconditionally.
Summary: This is not technically required, but glibc unwind-dw2-fde.c classify_object_over_fdes expects there is a CIE record length 0 as a terminator.

Reviewers: ruiu, espindola

Subscribers: emaste, arichardson, llvm-commits

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

llvm-svn: 331708
2018-05-08 01:19:16 +00:00
Rui Ueyama cdf8d06426 Rename a local variable whose scope is very narrow. NFC.
llvm-svn: 331703
2018-05-07 23:43:48 +00:00
Rui Ueyama ac403ef7f0 Improve error message for --plugin-opt=thinlto-prefix-replace.
llvm-svn: 331700
2018-05-07 23:24:25 +00:00
Rui Ueyama d432f216d1 Rename Config::ThinLTOIndexOnlyObjectFiles -> Config::ThinLTOIndexOnlyArg.
llvm-svn: 331699
2018-05-07 23:24:16 +00:00
Rui Ueyama 397dffd81b Split BitcodeCompiler::init() into two functions. NFC.
Previously, code to initialize Backend and code to initialize Conf are
intermingled in init(), though they don't depend on each other.

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

llvm-svn: 331698
2018-05-07 23:24:07 +00:00
Rumeet Dhindsa 4fb5119215 Add support for thinlto option ( thinlto-emit-imports-files) to emit import files for thinlink.
Differential Revision: https://reviews.llvm.org/D46400

llvm-svn: 331696
2018-05-07 23:14:12 +00:00
Rui Ueyama 554adb2e97 Do not call exit() directly from lld.
Our promise is that as long as there's no fatal error (i.e. broken
file is given to the linker), our main function returns to the caller.
So we can't use exit() in the regular code path.

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

llvm-svn: 331690
2018-05-07 22:11:34 +00:00
Rui Ueyama d54f1c2fed Refactor ThinLTO-related code in BitcodeCompiler.cpp. NFC.
Summary: Refactor ThinLTO-related code in BitcodeCompiler.cpp. NFC.

Reviewers: rdhindsa, espindola

Subscribers: emaste, inglorion, arichardson, llvm-commits, eraman

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

llvm-svn: 331689
2018-05-07 22:11:24 +00:00
Rui Ueyama f64f345e1b Do not pass Config members to simplify function signature. NFC.
llvm-svn: 331658
2018-05-07 17:59:52 +00:00
Rui Ueyama 4454b3d1eb Parse --thinlto-prefix-replace early so that we don't need to parse it later. NFC.
llvm-svn: 331657
2018-05-07 17:59:43 +00:00
Rui Ueyama e4ba06eda6 Use StringRef instead of `const std::string &`. NFC.
llvm-svn: 331656
2018-05-07 17:59:34 +00:00
Rui Ueyama 66a9f257b6 Refactor BitcodeCompiler::createLTO. NFC.
llvm-svn: 331655
2018-05-07 17:46:28 +00:00
Roman Lebedev 7cb6896732 ELF Thunks: fix build error: missing 'overrides'
llvm-svn: 331608
2018-05-06 19:50:04 +00:00
Sean Fertile d2e887d2f6 [PPC64] Emit plt call stubs to the text section rather then the plt section.
On PowerPC calls to functions through the plt must be done through a call stub
that is responsible for:
1) Saving the toc pointer to the stack.
2) Loading the target functions address from the plt into both r12 and the
   count register.
3) Indirectly branching to the target function.

Previously we have been emitting these call stubs to the .plt section, however
the .plt section should be reserved for the lazy symbol resolution stubs. This
patch moves the call stubs to the text section by moving the implementation from
writePlt to the thunk framework.

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

llvm-svn: 331607
2018-05-06 19:13:29 +00:00
Simon Atanasyan b6211d9084 [ELF][MIPS] Reorganize isMipsPIC routine. NFC
llvm-svn: 331555
2018-05-04 20:48:53 +00:00
Simon Atanasyan 86a1219d30 [ELF][MIPS] Add STO_MIPS_MICROMIPS flag to symbols point to microMIPS PLT records
llvm-svn: 331554
2018-05-04 20:48:47 +00:00
Zaara Syeda edc7a8c1e5 [PPC64] Remove support for ELF V1 ABI in LLD - buildbot fix
Fix buildbot error, failure to build with msvc due to error C2446
Use switch instead of ternary operator.

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

llvm-svn: 331534
2018-05-04 16:04:04 +00:00
Zaara Syeda f61b0733a8 [PPC64] Remove support for ELF V1 ABI in LLD
The current support for V1 ABI in LLD is incomplete.
This patch removes V1 ABI support and changes the default behavior to V2 ABI,
issuing an error when using the V1 ABI. It also updates the testcases to V2
and removes any V1 specific tests.

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

llvm-svn: 331529
2018-05-04 15:09:49 +00:00
Peter Smith 2689d9f4f0 [ELF][AArch64] Add aarch64_elf64_le_vec emulation
Android AOSP has started specifying -m aarch64_elf64_le_vec as supported
by gold and BFD. This is a simple change to add the emulation so that LLD
doesn't immediately error when used as a linker in an AOSP build.

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

llvm-svn: 331521
2018-05-04 14:28:29 +00:00
Peter Smith e72d3d32bb [ELF][AArch64] Implement the AArch64 TLSLD_LDST_LO12 family of relocs
Implement the following relocations for AArch64:
R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC
R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC
R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC
R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC
R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC

These are specified in ELF for the 64-bit Arm Architecture.

Fixes pr36727

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

llvm-svn: 331511
2018-05-04 08:53:34 +00:00
Simon Atanasyan bc4da23133 [ELF][MIPS] Check that a section has a valid reference to a file in the isMipsPIC routine
llvm-svn: 331470
2018-05-03 17:33:10 +00:00
Peter Smith 2e54353b86 [LLD][AArch64] Simplify relocations sharing same encoding [NFC]
The code to encode the result in relocateOne for the relocations:
R_AARCH64_LD64_GOT_LO12_NC
R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC
R_AARCH64_TLSDESC_LD64_LO12

is equivalent to that for R_AARCH64_LDST64_ABS_LO12_NC. This is described
in the ABI as "Set the LD/ST immediate field bits [11:3] of X. No overflow
check; check that X&7 =0.
    
Differential Revision: https://reviews.llvm.org/D46247

llvm-svn: 331452
2018-05-03 12:59:52 +00:00
David Zarzycki f161de4e7d [CMake] Fix BUILD_SHARED_LIBS regression due to r331405
llvm-svn: 331444
2018-05-03 10:03:45 +00:00
Rumeet Dhindsa b082a8790c Updated ThinLTO test to not include forward or backward slash for testing
Differential Revision: https://reviews.llvm.org/D46372

llvm-svn: 331419
2018-05-03 00:28:51 +00:00
Rumeet Dhindsa d366e36bbf Added support for ThinLTO plugin options : thinlto-index-only and thinlto-prefix-replace
Differential Revision: https://reviews.llvm.org/D46034

llvm-svn: 331405
2018-05-02 21:40:07 +00:00
Zaara Syeda 116c0424da Fix warning: result of 32-bit shift implicitly converted to 64 bits - NFC
Fix warning caused by rL331046.

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

llvm-svn: 331181
2018-04-30 14:37:28 +00:00
Rafael Espindola bd4d2acb11 Don't create a temporary DenseMap for each input .eh_frame.
These maps are small, but we are creating an destroying one for each
input .eh_frame.

This patch reduces the total memory allocation from 765.54MB to
749.19MB. The peak is still the same: 563.7MB.

llvm-svn: 331075
2018-04-27 20:19:28 +00:00
Rafael Espindola f1652d4c60 Split .eh_frame sections in parellel.
We can now split them in the same spot we split merge sections.

llvm-svn: 331064
2018-04-27 18:17:36 +00:00
Rafael Espindola 9bf1006278 Split merge sections early.
Now that getSectionPiece is fast (uses a hash) it is probably OK to
split merge sections early.

The reason I want to do this is to split eh_frame sections in the same
place.

This does mean that we have to decompress early. Given that the only
compressed sections are debug info, I don't think we are missing much.

It is a small improvement: 0.5% on the geometric mean.

llvm-svn: 331058
2018-04-27 16:29:57 +00:00
Zaara Syeda 82dd99e08e [PPC64] Add offset to local entry point when calling functions without plt
PPC64 V2 ABI describes two entry points to a function. The global entry point
sets up the TOC base pointer. When calling a local function, the call should
branch to the local entry point rather than the global entry point.
Section 3.4.1 describes using the 3 most significant bits of the st_other
field to find out how many instructions there are between the local and global
entry point. This patch adds the correct offset required to branch to the local
entry point of a function.

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

llvm-svn: 331046
2018-04-27 15:41:19 +00:00
Rui Ueyama 50bf643cfb Do not set RequiresNullTerminator. NFC.
When reading object files, we don't need '\0' at end of each file.

llvm-svn: 331045
2018-04-27 15:32:04 +00:00
Fangrui Song 1f3e2b2966 [ELF] Fix typo. NFC
llvm-svn: 331018
2018-04-27 05:50:40 +00:00
Shoaib Meenai 1b1f97ac60 [ELF] Clarify help wording for --symbol-ordering-file
The input file for this option should contain a list of symbols, not a
list of sections, so explicitly refer to ordering symbols (but keep the
reference to laying out sections, since that's how the option must
operate). Referring to the file itself as the "symbol ordering file" is
consistent with --warn-symbol-ordering and less ambiguous than "symbol
file" (albeit slightly redundant).

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

llvm-svn: 331000
2018-04-26 22:25:04 +00:00
Rafael Espindola 40f46bc3e6 Delete unused variable.
llvm-svn: 330978
2018-04-26 19:21:07 +00:00
Rafael Espindola ab44b923f5 Add a comment. NFC.
llvm-svn: 330967
2018-04-26 18:03:04 +00:00
Rafael Espindola ab0cce5f1f Replace SharedSymbols with Defined when creating copy relocations.
This is slightly simpler to read IMHO. Now if a symbol has a position
in the file, it is Defined.

The main motivation is that with this a SharedSymbol doesn't need a
section, which reduces the size of SymbolUnion.

With this the peak allocation when linking chromium goes from 568.1 to
564.2 MB.

llvm-svn: 330966
2018-04-26 17:58:58 +00:00
Rafael Espindola 06cb7c8773 Simplify processRelocAux.
It returns a different Expr only in the case of creating a function
symbol pointing to its plt entry. We can just add a call to
addPltEntry to avoid that and return void.

With this patch further simplifications of how we handle copy
relocations are possible.

llvm-svn: 330960
2018-04-26 17:22:44 +00:00
Rafael Espindola f4a9d56a9a Delete GotPltIndex.
It was always an offset of PltIndex.

This doesn't reduce the size of the structures, but makes it easier to
do so in a followup patch.

llvm-svn: 330953
2018-04-26 16:09:30 +00:00
Rui Ueyama b774c3c0e5 Simplify. NFC.
llvm-svn: 330892
2018-04-26 01:38:29 +00:00
Rui Ueyama 5fcebff485 Remove unused features from StringRefZ and move it to Symbols.h.
Differential Revision: https://reviews.llvm.org/D46087

llvm-svn: 330879
2018-04-25 22:34:21 +00:00
Rafael Espindola 1eeb26293d Pack symbols a bit more.
Before this patch:

Symbol 56
Defined 80
Undefined 56
SharedSymbol 88
LazyArchive 72
LazyObject 56

With this patch

Symbol 48
Defined 72
Undefined 48
SharedSymbol 80
LazyArchive 64
LazyObject 48

The result is that peak allocation when linking chromium (according to
heaptrack) goes from 578 to 568 MB.

llvm-svn: 330874
2018-04-25 21:44:37 +00:00
Rafael Espindola 047f857642 Also demote lazy symbols.
This is not a big simplification right now, but the special cases for
lazy symbols have been a common source of bugs in the past.

llvm-svn: 330869
2018-04-25 20:46:08 +00:00
George Rimar d30a78b3fe [ELF] - Eliminate the AssertCommand.
Currently, LLD supports ASSERT as a separate command.

We support two forms now.

Assign expression-form: . = ASSERT(0x100)
(old GNU ld required it and some scripts in the wild are still using
something like . = ASSERT((_end - _text <= (512 * 1024 * 1024)), "kernel image bigger than KERNEL_IMAGE_SIZE");

Nowadays above is not a mandatory form and command-like form is commonly used:
ASSERT(<expr>, "text);

The return value of the ASSERT is Dot. That was implemented in D30171.
It looks like (2) is just a short version of (1) then.

GNU ld does *not* list ASSERT as a SECTIONS command:
https://sourceware.org/binutils/docs/ld/SECTIONS.html#SECTIONS

Given above we probably can change ASSERT to be an assignment to Dot. 
That makes the rest of the code much simpler. Patch do that.

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

llvm-svn: 330814
2018-04-25 11:16:31 +00:00
Rafael Espindola 61376d9bed Bring r329960 back.
The fix is to copy Used when replacing the symbol.

Original message:

Do not keep shared symbols created from garbage-collected eliminated DSOs.

If all references to a DSO happen to be weak, and if the DSO is
specified with --as-needed, the DSO is not added to DT_NEEDED.
If that happens, we also need to eliminate shared symbols created
from the DSO. Otherwise, they become dangling references that point
to non-exsitent DSO.

Fixes https://bugs.llvm.org/show_bug.cgi?id=36991

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

llvm-svn: 330788
2018-04-25 00:29:13 +00:00
George Rimar de83cbf37e [ELF] - Never use std::sort.
It turns out we should not use the std::sort anymore.
r327219 added a new wrapper llvm::sort (D39245).
When EXPENSIVE_CHECKS is defined, it shuffles the
input container and that helps to find non-deterministic
ordering.

Patch changes code to use llvm::sort and std::stable_sort
instead of std::sort

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

llvm-svn: 330702
2018-04-24 09:55:39 +00:00
George Rimar 19f9b814dd [ELF] - Refactor lazy symbol duplicated code.
Our code for LazyObject and LazyArchive duplicates.

This patch extracts the common part to remove
the duplication.

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

llvm-svn: 330701
2018-04-24 09:41:56 +00:00
Rui Ueyama d134d2e509 Remove duplicate "error:" from an error message.
This patch also simplifies the code a bit which wasn't committed in
https://reviews.llvm.org/r330600.

llvm-svn: 330644
2018-04-23 20:34:35 +00:00
Zaara Syeda 25b488b0ea [PPC64] Fix toc restore nops offset for V2 ABI
The PPC64 V2 ABI restores the toc base by loading from an offset of 24 from r1.
This patch fixes the offset and updates the testcases from V1 to V2. It also
issues an error when a nop is missing after a call to an external function.

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

llvm-svn: 330600
2018-04-23 15:01:24 +00:00
George Rimar 97df22f110 [ELF] - Simplify. NFC.
llvm-svn: 330597
2018-04-23 14:41:49 +00:00
Fangrui Song c8ac0a6f97 [ELF] Swap argument names: use Old to refer to original symbol and New for incoming one
Reviewers: ruiu, espindola

Subscribers: emaste, arichardson, llvm-commits

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

llvm-svn: 330491
2018-04-20 22:50:15 +00:00