Commit Graph

10160 Commits

Author SHA1 Message Date
Teresa Johnson 2c2ed3cf03 [lld/LTO] Remove unused Path parameter to AddBufferFn
Summary:
With D43396, no clients use the Path parameter anymore.
This is the lld side fix with D43400.

Depends on D43396 and D43400.

Reviewers: pcc

Subscribers: emaste, inglorion, arichardson, llvm-commits

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

llvm-svn: 325620
2018-02-20 20:21:59 +00:00
Sam Clegg f60b0d5c62 feedback
llvm-svn: 325614
2018-02-20 18:55:07 +00:00
Sam Clegg 93e559b138 [WebAssembly] Split addDefined into two different methods. NFC.
Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish, llvm-commits

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

llvm-svn: 325613
2018-02-20 18:55:06 +00:00
Sam Clegg b92b6b532f [WebAssembly] Remove unused header
This header used to be needed here for the `OutRelocation` struct
but that no longer exists.

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

llvm-svn: 325608
2018-02-20 18:40:05 +00:00
Sam Clegg 4f61714fd6 [WebAssembly] Remove InputChunk from Symbol baseclass
Instead include InputFuction and InputSegment directly
in the subclasses that use them (DefinedFunction and
DefinedGlobal).

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

llvm-svn: 325603
2018-02-20 17:45:38 +00:00
Sam Clegg c7e885b52a [WebAssembly] Check signatures of weakly defined funtions too
Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish, llvm-commits

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

llvm-svn: 325598
2018-02-20 17:20:44 +00:00
Rui Ueyama bf450d905d Do not create a temporary data structure for relocations.
This patch removes `OutRelocations` vector from the InputChunk and
directly consume `Relocations` vector instead. This should make the linker
faster because we don't create a temporary data structure, and it matches
the lld's design principle that we don't create temporary data structures
for object files but instead directly consume mmap'ed data whenever possible.

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

llvm-svn: 325549
2018-02-20 04:26:26 +00:00
Rui Ueyama c1e5c218e6 Merge two small functions and add comments.
Differential Revision: https://reviews.llvm.org/D43406

llvm-svn: 325538
2018-02-19 22:44:18 +00:00
Rui Ueyama c06d94aa31 Removed a variable that is used only once.
llvm-svn: 325537
2018-02-19 22:39:52 +00:00
Rui Ueyama 34133b23e4 [WebAssembly] Expand a lambda that is used only once.
Differential Revision: https://reviews.llvm.org/D43435

llvm-svn: 325536
2018-02-19 22:34:47 +00:00
Rui Ueyama 81bee04bf9 [WebAssembly] Define toString(wasm::InputChunk *) and use that in MarkLive.cpp.
Define toString(wasm::InputChunk *) and use that in MarkLive.cpp.

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

llvm-svn: 325535
2018-02-19 22:29:48 +00:00
Alexander Richardson 048e2508ad Rename DynamicReloc::getAddend() to computeAddend(). NFC
Summary:
Before the name of the function sounded like it was just a getter for the
private class member Addend. However, it actually calculates the final
value for the r_addend field in Elf_Rela that is used when writing the
.rela.dyn section. I also added a comment to the UseSymVA member to
explain how it interacts with computeAddend().

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

llvm-svn: 325485
2018-02-19 11:00:15 +00:00
Rui Ueyama c6c66225a3 Simplify.
llvm-svn: 325453
2018-02-17 23:37:26 +00:00
Rui Ueyama b3107476a4 Remove an unused accessor and simplify the logic a bit. NFC.
llvm-svn: 325445
2018-02-17 20:41:38 +00:00
Rui Ueyama 03c7f3a2d0 Factor out common code from applySecRel functions.
Differential Revision: https://reviews.llvm.org/D43412

llvm-svn: 325444
2018-02-17 20:28:15 +00:00
Sam Clegg caca8d5db3 [WebAssembly] Remove unneeded classifer methods from Symbol class. NFC.
We already have isa<> for this, and these methods were simply
duplicating those redundantly.

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

llvm-svn: 325418
2018-02-17 00:44:21 +00:00
Rui Ueyama ff59a899d6 Use toString to print out garbage-collected sections.
Currently, archive file name is missing in this message. In general,
we should avoid constructing strings in an ad-hoc manner and instead
use toString() to get consistent output strings.

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

llvm-svn: 325416
2018-02-17 00:09:49 +00:00
Sam Clegg 3f8db98807 [WebAssembly] Simplify FunctionSymbol::get/set/hasFunctionType. NFC.
Differential Revision: https://reviews.llvm.org/D43416

llvm-svn: 325415
2018-02-16 23:50:23 +00:00
Sam Clegg 6d83fb4c07 [WebAssembly] Remove unneeded Chunk::getFileName() method. NFC.
Differential Revision: https://reviews.llvm.org/D43405

llvm-svn: 325414
2018-02-16 23:46:51 +00:00
Rui Ueyama 7c9ad29304 Remove "--full-shutdown" and instead use an environment variable LLD_IN_TEST.
We are running lld tests with "--full-shutdown" option because we don't
want to call _exit() in lld if it is running tests. Regular shutdown
is needed for leak sanitizer.

This patch changes the way how we tell lld that it is running tests.
Now "--full-shutdown" is removed, and LLD_IN_TEST environment variable
is used instead.

This patch enables full shutdown on all ports, e.g. ELF, COFF and wasm.
Previously, we enabled it only for ELF.

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

llvm-svn: 325413
2018-02-16 23:41:48 +00:00
Rui Ueyama 4aab7b1d91 Do not print out "no input files" twice.
Differential Revision: https://reviews.llvm.org/D43408

llvm-svn: 325406
2018-02-16 22:58:19 +00:00
Rui Ueyama f05124e60c Use wasm-ld instead of "lld -flavor wasm".
Invoking lld as ld.lld, ld.ld64, lld-link or wasm-ld is preferred
than invoking lld as lld and pass an -flavor option. We have "lld"
file mostly for historical reasons.

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

llvm-svn: 325405
2018-02-16 22:58:02 +00:00
Konstantin Zhuravlyov 82a6199140 AMDGPU/LLD: Remove the use of binary file from one of the AMDGPU tests
Differential Revision: https://reviews.llvm.org/D43413

llvm-svn: 325404
2018-02-16 22:55:36 +00:00
Konstantin Zhuravlyov b3ec7396ed AMDGPU: Update elf flags in amdgpu-elf-flags.s
This is required after r325399:
  - EF_AMDGPU_ARCH_GCN got removed
  - In the test, EF_AMDGPU_ARCH_GCN is replaced with EF_AMDGPU_MACH_AMDGCN_GFX803

llvm-svn: 325400
2018-02-16 22:35:36 +00:00
Martin Storsjo ef4f78bbf2 [COFF] Add support for ARM64 secrel relocations for add/load instructions
Differential Revision: https://reviews.llvm.org/D43287

llvm-svn: 325396
2018-02-16 22:02:38 +00:00
Rui Ueyama 4f2b1189d5 Revert an accidental change to where "-flavor GNU" was used by intention.
llvm-svn: 325392
2018-02-16 21:24:01 +00:00
Rui Ueyama 5c33bbed58 Replace -flavor {gnu,darwin} with ld64.lld or ld.lld.
llvm-svn: 325390
2018-02-16 21:16:57 +00:00
Rui Ueyama 61dc84a4db Remove `else` after `break`.
llvm-svn: 325387
2018-02-16 20:53:53 +00:00
Rui Ueyama e351c3a438 Use write32le instead of write32<little>.
llvm-svn: 325384
2018-02-16 20:38:15 +00:00
Rui Ueyama 1184253891 Refactor wasm/WriterUtil.{cpp,h}.
Summary:
 - Makes code more in line with LLVM style (e.g. const char * -> StringRef)
 - Do not use formatv since we can construct message just by `+`
 - Replace some odd types such as `const StringRef` with more common type
 - Do not use default arguments if they are not necessary

Reviewers: sbc100

Subscribers: jfb, aheejin, llvm-commits, sunfish

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

llvm-svn: 325383
2018-02-16 20:38:00 +00:00
Sam Clegg b2f6e1c2f2 [WebAssebmly] Remove unneeded cast. NFC.
llvm-svn: 325382
2018-02-16 20:26:15 +00:00
Peter Collingbourne 09e04af42f ELF: Stop collecting a list of symbols in ArchiveFile.
There seems to be no reason to collect this list of symbols.

Also fix a bug where --exclude-libs would apply to all symbols that
appear in an archive's symbol table, even if the relevant archive
member was not added to the link.

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

llvm-svn: 325380
2018-02-16 20:23:54 +00:00
Rafael Espindola f931c179ca Don't depend on "call foo" producing a X86_64_PC32.
Newer versions of the gnu assembler produce a X86_64_PLT32 for
calls. There is a change under review in llvm to do the same, so update
the tests to not depend on it.

We can still produce a R_X86_64_PC32 with ".long foo - .".

llvm-svn: 325379
2018-02-16 20:05:58 +00:00
Rui Ueyama 7b9ed65666 Style fix. NFC.
llvm-svn: 325377
2018-02-16 19:53:29 +00:00
Sam Clegg fe78ccf1a1 [WebAssembly] Fix bug is function signature checking
This bug effected undefined symbols that were resolved by
existing defined symbols.  We were skipping the signature
check in this case.

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

llvm-svn: 325376
2018-02-16 19:45:41 +00:00
Sam Clegg 3d1f4b954d [WebAssembly] Fix typos in comment. NFC.
Patch by Nicholas Wilson!

llvm-svn: 325370
2018-02-16 18:37:32 +00:00
Rafael Espindola b960325989 Simplify RelocationBaseSection::addReloc.
Now that we have R_ADDEND, UseSymVA was redundant. We only want to
write the symbol virtual address when using an expression other than
R_ADDEND.

llvm-svn: 325360
2018-02-16 16:53:04 +00:00
James Henderson 149343c374 [ELF] Extend symbol-order-warnings test case for ICF
Reviewed by: rafael

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

There is some discussion as to the exact behaviour of combining ICF and
--symbol-ordering-file, but it seems beneficial to warn when attempting
to order the removed symbol regardless of the preferred approach.

llvm-svn: 325333
2018-02-16 10:49:57 +00:00
George Rimar 97f4d158bd [ELF] - Fix comment. NFC.
Addresses forgotten comment for D43071.

llvm-svn: 325332
2018-02-16 10:46:50 +00:00
George Rimar 1c08e9f5ce [ELF] - Support COPY, INFO, OVERLAY output sections attributes.
This is PR36298.

(COPY), (INFO), (OVERLAY) all have the same effect:
section should be marked as non-allocatable.

(https://www.eecs.umich.edu/courses/eecs373/readings/Linker.pdf, 
3.6.8.1 Output Section Type)

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

llvm-svn: 325331
2018-02-16 10:42:58 +00:00
Alexander Richardson cfb6093379 Ensure that Elf_Rel addends are always written for dynamic relocations
Summary:
This follows up on r321889 where writing of Elf_Rel addends was partially
moved to RelocationBaseSection. This patch ensures that the addends are
always written to the output section when a input section uses RELA but the
output is REL.

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

llvm-svn: 325328
2018-02-16 10:01:17 +00:00
Rui Ueyama 6de1e858a1 Fix an issue that weak bit is dropped when there's a lazy object symbol.
Previously, we accidentally dropped STB_WEAK bit from an undefined symbol
if there is a lazy object symbol with the same name. That caused a
compatibility issue with GNU gold.

llvm-svn: 325316
2018-02-16 04:27:46 +00:00
Igor Kudrin 943f62d9d7 [ELF] Fix use after free in case of using --whole-archive.
Differential Revision: https://reviews.llvm.org/D34554

llvm-svn: 325313
2018-02-16 03:26:53 +00:00
Rui Ueyama 65b620be8a Relax relocation type checking in a non-ALLOC section.
Even though it doesn't make sense, there seems to be multiple programs
in the wild that create PC-relative relocations in non-ALLOC sections.
I believe this is caused by the negligence of GNU linkers to not report
any errors for such relocations.

Currently, lld emits warnings against such relocations and exits.
So, you cannot link any program that contains wrong relocations until
you fix an issue in a program that generates wrong ELF files. It's often
impractical to fix a program because it's not always easy.

This patch relaxes the error checking and emit a warning instead.

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

llvm-svn: 325307
2018-02-16 01:10:51 +00:00
Igor Kudrin 25f917341e [ELF] Simplify handling of AT section attribute.
This also makes the behavior close to GNU ld's.

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

llvm-svn: 325213
2018-02-15 06:13:52 +00:00
Rui Ueyama 44a8471227 Fix an issue that lld drops symbol versions for -r.
When we are emitting a relocatable output, we should keep the original
symbol name including "@" part. Previously, we drop that part unconditionally
which resulted in dropping versions from symbols.

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

llvm-svn: 325204
2018-02-15 02:40:58 +00:00
Sam Clegg c484ee0a9c [WebAssebmly] Remove use of Optional to fix assertion in gcc
This was causing GCC builds with fail with:
Symbols.h:240:3: error: static assertion failed: Symbol types must be
trivially destructible
  static_assert(std::is_trivially_destructible<T>(

The reason this is a gcc-only failure is that OptionalStorage has
as specialization for POD types that isn't built under GCC.

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

llvm-svn: 325185
2018-02-14 22:55:38 +00:00
Rui Ueyama 38781a59f6 Revert r325158: Convert an assert to a static_assert. NFC.
This reverts commit r325158 because it broke GCC builds.

llvm-svn: 325183
2018-02-14 22:43:43 +00:00
Rui Ueyama de8140066a Remove a failing static_assert.
This static_assert is legitimate, but it is failing on some build environments.
I'm removing it until it's fixed to unbreak the bots.

llvm-svn: 325181
2018-02-14 22:26:23 +00:00
Sam Clegg ab31b7759d Convert an assert to a static_assert. NFC.
Differential Revision: https://reviews.llvm.org/D43305

llvm-svn: 325158
2018-02-14 19:28:46 +00:00