Commit Graph

10201 Commits

Author SHA1 Message Date
Jonas Devlieghere b9ad175935 [Support] Replace HashString with djbHash.
This removes the HashString function from StringExtraces and replaces
its uses with calls to djbHash from DJB.h

This is *almost* NFC. While the algorithm is identical, the djbHash
implementation in StringExtras used 0 as its seed while the
implementation in DJB uses 5381. The latter has been shown to result in
less collisions and improved avalanching.

https://reviews.llvm.org/D43615
(cherry picked from commit 77f7f965bc9499a9ae768a296ca5a1f7347d1d2c)

llvm-svn: 326081
2018-02-26 11:30:13 +00:00
Rui Ueyama afb87d8336 [WebAssembly] Remove dead code.
llvm-svn: 326018
2018-02-24 02:43:31 +00:00
Rui Ueyama 1973cc5358 [WebAssembly] Remove dead code.
llvm-svn: 326017
2018-02-24 02:34:03 +00:00
Rui Ueyama c9f0b65f54 [WebAssebmly] Minor simplification. NFC.
llvm-svn: 326013
2018-02-24 01:58:38 +00:00
Rui Ueyama 20571c39a1 Do not use `auto` for type that is not obvious in a local context.
llvm-svn: 326012
2018-02-24 01:39:25 +00:00
Fangrui Song ffac3ed341 [ELF] Fix IsPreemptible comment and typo. NFC
llvm-svn: 325963
2018-02-23 21:57:49 +00:00
Rui Ueyama a6a0616508 Remove dead code.
llvm-svn: 325955
2018-02-23 20:33:43 +00:00
Rui Ueyama 97f66af615 Inline printHelp.
Differential Revision: https://reviews.llvm.org/D43526

llvm-svn: 325953
2018-02-23 20:24:40 +00:00
Rui Ueyama eecdaaac27 Handle --version before handling --mllvm.
Because it's a waste of time to handle --mllvm before --version.

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

llvm-svn: 325952
2018-02-23 20:24:28 +00:00
Rui Ueyama 39049c05a9 Inline a trivial ctor.
Differential Revision: https://reviews.llvm.org/D43525

llvm-svn: 325948
2018-02-23 20:13:38 +00:00
Simon Atanasyan a4cde9d2e2 [ELF][MIPS] Set EI_ABIVERSION flag accordingly to MIPS ABIs requirement
MIPS ABIs require that if an executable file uses non-PIC model, the
EI_ABIVERSION entry in the ELF header should be incremented from 0 to 1.
That allows obsoleted / limited dynamic linkers refuse to link them.

llvm-svn: 325890
2018-02-23 11:28:57 +00:00
George Rimar db1a062447 [ELF] - Do not remove empty output sections that are explicitly assigned to phdr in script.
This continues direction started in D43069.

We can keep sections that are explicitly assigned to segment in script.
It helps to simplify code.

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

llvm-svn: 325887
2018-02-23 10:53:04 +00:00
George Rimar 2d53967b48 Recommit "[ELF] - Do not crash with --emit-relocs and --icf=all together."
Latest patch version now.

Original commit message:

[ELF] - Do not crash with --emit-relocs and --icf=all together.

Previously we would crash because did not mark .rel[a] sections
as dead and they tried to access parent which was not live
after ICF and therefore was null.

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

llvm-svn: 325879
2018-02-23 10:37:33 +00:00
George Rimar aa359f87e8 [ELF] - Revert r325877 "[ELF] - Do not crash with --emit-relocs and --icf=all together."
Not latest version of patch was committed by mistake.

llvm-svn: 325878
2018-02-23 10:30:31 +00:00
George Rimar cde84d1cd0 [ELF] - Do not crash with --emit-relocs and --icf=all together.
Previously we would crash because did not mark .rel[a] sections
as dead and they tried to access parent which was not live
after ICF and therefore was null.

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

llvm-svn: 325877
2018-02-23 10:27:13 +00:00
George Rimar 3cdf0d969a [ELF] - Report error if removed empty output section declaration used undefined symbols.
This is for fixing PR36297.

Issue itself is that if we have SECTIONS { .bar (a+b) : { *(.stub) } };
script and no section .stub, when LLD will remove .bar, but
produce output with undefined symbols a and b.

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

llvm-svn: 325875
2018-02-23 10:15:54 +00:00
George Rimar 1fdb280bec [ELF] - Added testcase for testing visibility of weak_odr symbols.
This is relative to "Bug 36166 - tools/gold/X86/comdat.ll is failing only on Debian Unstable" (PR36166).
Something changed in newer versions of gold and now together with gold-plugin
there is an issue shown in PR, symbol may get wrong visibility.

LLD works fine, but we have no testcase for the same use case, patch adds it.

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

llvm-svn: 325874
2018-02-23 10:08:15 +00:00
George Rimar 4e6f52c9a4 [ELF] - Add testcase documenting flags assigned when empty synthetic section is removed.
This responds to PR36475,

r325763 led to unexprected layout change, though
new behavior seems to be more correct.

Previously we could have following script:

.foo : { *(.foo) } 
.bar : { *(.synthetic_empty) BYTE(0x11) }}
where synthetic_empty is a synthetic section which is empty and
hence removed by linker.

Before r325763 .bar would receive section flags from .synthetic_empty,
but after this revision it receives flags the same as .foo section has.

It is the same as if there would not be any synthetic_empty section in a script,
so looks reasonable and consistent behavior:
.foo : { *(.foo) } 
.bar : { BYTE(0x11) }}

Patch adds testcase to document it.

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

llvm-svn: 325873
2018-02-23 09:57:17 +00:00
Hans Wennborg ff52eb5927 ReleaseNotes: user lower-case for lld in the text
llvm-svn: 325869
2018-02-23 08:27:38 +00:00
Sam Clegg 9310297438 [WebAssembly] Add explicit symbol table
This change modified lld to in response the llvm change which
moved to a more explicit symbol table in the object format.

Based on patches by Nicholas Wilson:
 1. https://reviews.llvm.org/D41955
 2. https://reviews.llvm.org/D42585

The primary difference that we see in the test output is that
for relocatable (-r) output we now have symbol table which
replaces exports/imports and globals.

See: https://github.com/WebAssembly/tool-conventions/issues/38
Differential Revision: https://reviews.llvm.org/D43264

llvm-svn: 325861
2018-02-23 05:08:53 +00:00
Sam Clegg 6c4dbfeec1 [WebAssembly] Move lambda declaration output of loop. NFC.
Differential Revision: https://reviews.llvm.org/D43534

llvm-svn: 325857
2018-02-23 04:59:57 +00:00
Fangrui Song 9cd5df0e15 [ELF] Add comment for preemptible and fix typo. NFC
Subscribers: emaste, arichardson, llvm-commits

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

llvm-svn: 325855
2018-02-23 02:05:48 +00:00
Rui Ueyama c30927411c Make undefined symbol in DSO to pull out object files from archive files.
We have an internal program that does't link without this patch. I don't
know of any open-source program that needs this, but there might be.
Since this patch improves compatibility with GNU linkers with a few lines
of code, I think it's worth to be committed.

The problem is about undefined symbols in DSOs. Some programs depend on
the GNU linkers' behavior that they pull out object files from archive
files to resolve undefined symbols in DSOs. We already allow that kind of
"reverse" dependency (from DSOs to the main executable) for regular
symbols, in particular, for "__progname" symbol (which is usually in
crt0.o), but that doesn't work if the symbol is in an archive file.
This patch is to make it work.

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

llvm-svn: 325849
2018-02-23 01:16:57 +00:00
Zachary Turner 401b2a463c Update lld documentation to mention PDB support.
Differential Revision: https://reviews.llvm.org/D43636

llvm-svn: 325821
2018-02-22 19:12:57 +00:00
George Rimar 925529b821 [ELF] - Rewrote outdated comment. NFC.
llvm-svn: 325809
2018-02-22 17:52:43 +00:00
George Rimar 563e4f2f58 [ELF] - Introduce getInputSections() helper.
We sometimes need to iterate over input sections for a given
output section. It is not very convinent because we have to iterate
over section descriptions.
Patch introduces getInputSections helper, it simplifies things.

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

llvm-svn: 325763
2018-02-22 09:55:28 +00:00
Rui Ueyama 9060b57e70 Revert r325679: [ELF] Add -nopie alias for -no-pie (PR36423)
This reverts commit r325679 that was committed without discussion.
Actually, in the discussion thread, most people opposed to have this
option in lld. Reverting that change doesn't mean that this is a
final decision, but that needs to be discussed first.

llvm-svn: 325714
2018-02-21 20:08:14 +00:00
Simon Dardis f5e0b40095 [mips][lld] Address post commit review nit.
Address @ruiu's post commit review comment about a value which is intended
to be a unsigned 32 bit integer as using uint32_t rather than unsigned.

llvm-svn: 325713
2018-02-21 20:01:43 +00:00
Sam Clegg 011dce2d14 [WebAssembly] Use make<> rather then make_unique<>. NFC.
lld uses an arena allocator to one of allocations
like these can just use make<>.

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

llvm-svn: 325706
2018-02-21 18:37:44 +00:00
Sam Clegg 9f93422651 [WebAssembly] Rename member DefinedFunctions -> InputFunctions. NFC.
This avoids confusion with the `DefinedFunction` symbol
type.

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

llvm-svn: 325705
2018-02-21 18:29:23 +00:00
George Rimar 5bd90e2db1 [ELF] - Simplify. NFC.
llvm-svn: 325681
2018-02-21 14:21:23 +00:00
Hans Wennborg 82fca76868 [ELF] Add -nopie alias for -no-pie (PR36423)
In r324043, --nopie was renamed to --no-pie to presumably fix a typo.

As it turns out, "nopie" wasn't a typo but the spelling used by
OpenBSD's binutils ld. Gold on the other hand spells the flag "no-pie".
(Vanilla binutils doesn't have a flag like this at all.)

Since they do the same thing, let's support both spellings.

llvm-svn: 325679
2018-02-21 13:54:26 +00:00
George Rimar db7c630b01 [ELF] - Simplify testcase. NFC.
This removes script input file and inlines script into
testcase body. That is consistent with othet LS tests
and makes testcase easier to read.

llvm-svn: 325673
2018-02-21 11:56:55 +00:00
Sam Clegg 29b8feb615 [WebAssembly] Use stable sort when sorting ctore functions
Patch by Nicholas Wilson!

llvm-svn: 325656
2018-02-21 00:34:34 +00:00
Aaron Smith 39bb8c5003 [lit] Fix a problem with spaces in the python path by adding quotes around it
Summary:
This fixes two failing tests on Windows with an installed version of python that has spaces in the path.

* elf/lto/cache.ll
* mach-o/dependency_info.yaml

Reviewers: zturner, llvm-commits, stella.stamenova

Subscribers: emaste, arichardson

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

llvm-svn: 325650
2018-02-21 00:03:41 +00:00
Simon Dardis cd8758233e [mips][lld] Spectre variant two mitigation for MIPSR2
This patch provides migitation for CVE-2017-5715, Spectre variant two,
which affects the P5600 and P6600. It implements the LLD part of
-z hazardplt. Like the Clang part of this patch, I have opted for that
specific option name in case alternative migitation methods are required
in the future.

The mitigation strategy suggested by MIPS for these processors is to use
hazard barrier instructions. 'jalr.hb' and 'jr.hb' are hazard
barrier variants of the 'jalr' and 'jr' instructions respectively.

These instructions impede the execution of instruction stream until
architecturally defined hazards (changes to the instruction stream,
privileged registers which may affect execution) are cleared. These
instructions in MIPS' designs are not speculated past.

These instructions are defined by the MIPS32R2 ISA, so this mitigation
method is not compatible with processors which implement an earlier
revision of the MIPS ISA.

For LLD, this changes PLT stubs to use 'jalr.hb' and 'jr.hb'.

Reviewers: atanasyan, ruiu

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

llvm-svn: 325647
2018-02-20 23:49:17 +00:00
Sam Clegg 00245539b6 [WebAssembly] Rename GlobalSymbol types. NFC.
Purely a rename in preparation for adding new global symbol type.

We want to use GlobalSymbol to represent real wasm globals and
DataSymbol for pointers to things in linear memory (what ELF would
call STT_OBJECT).

This reduces the size the patch to add the explicit symbol table
which is coming soon!

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

llvm-svn: 325645
2018-02-20 23:38:27 +00:00
Sam Clegg f187c4d2e5 Consistent use of header file for ICF and MarkLive
Previously wasm used a separate header to declare markLive
and ELF used to declare ICF.  This change makes each backend
consistently declare these in their own headers.

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

llvm-svn: 325631
2018-02-20 22:09:59 +00:00
Sam Clegg 3141ddc58d Consistent (non) use of empty lines in include blocks
The profailing style in lld seem to be to not include such empty lines.
Clang-tidy/clang-format seem to handle this just fine.

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

llvm-svn: 325629
2018-02-20 21:53:18 +00:00
Rui Ueyama c03c9040aa Use more early returns in SymbolTable.cpp.
I think if statements that end with return is easier to read than
cascaded if-else-if-else-if statements because it makes clear that
execution of a function terminates there. This patch also adds more
blank lines to separate code blocks to meaningful pieces.

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

llvm-svn: 325625
2018-02-20 21:08:47 +00:00
Sam Clegg 78f766a9aa [WebAssembly] Remove unused header
llvm-svn: 325624
2018-02-20 21:08:28 +00:00
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