Commit Graph

9867 Commits

Author SHA1 Message Date
Benjamin Kramer 61085ca999 Update lld tests after r321526.
llvm-svn: 321529
2017-12-28 17:20:41 +00:00
Rui Ueyama a63eed0f80 Do not parse the same /export string more than once.
Differential Revision: https://reviews.llvm.org/D41607

llvm-svn: 321513
2017-12-28 07:41:19 +00:00
Bob Haarman e90ac016e7 [COFF] support /ignore:4217
Summary:
lld-link accepts link.exe's /ignore option, but used to ignore
it. This can lead to semantic differences when warnings are treated as
fatal errors. One such case is when we resolve an __imp_ symbol to a
local definition. We emit a warning in that case, which /wx turns into
a fatal. This change makes lld-link accept /ignore:4217 to suppress
that warning, so that code that links with link.exe /wx /ignore:4217
links with lld-link, too.

Fixes PR35762.

Reviewers: rnk, ruiu

Reviewed By: ruiu

Subscribers: llvm-commits

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

llvm-svn: 321512
2017-12-28 07:02:13 +00:00
Rafael Espindola 465e7c94ed Allow copy relocation with -z notext.
This makes adjustExpr a bit simpler too IMHO.

It seems that some of the complication around relocation processing
is that we are trying to create copy relocations too early. It seems
we could handle a few simple cases first and continue.

llvm-svn: 321507
2017-12-28 00:23:49 +00:00
Rafael Espindola e2e070c6c4 Don't try to preempt protected symbols with -z notext.
I will send a followup patch removing the FIXME this patch adds.

llvm-svn: 321499
2017-12-27 20:53:13 +00:00
George Rimar a0ab8d7a58 [ELF] - Allow relocation to a weak undefined symbol when -z notext is given.
Previously we failed to resolve them when produced executables:
"relocation R_X86_64_32 cannot be used against shared object; recompile with -fPIC"

Patch fixes it so that we resolve them to 0 for executables. 
And for -shared case we still should produce the relocation.

This finishes fixing PR35720.

DIfferential revision: https://reviews.llvm.org/D41551

llvm-svn: 321473
2017-12-27 07:29:55 +00:00
Rui Ueyama 17a3077f59 Make it clear where is a placeholder for later binary patching.
This is an aesthetic change to represent a placeholder for later
binary patching as "0, 0, 0, 0" instead of "0x00, 0x00, 0x00, 0x00".
The former is how we represent it in COFF, and I found it easier to
read than the latter.

llvm-svn: 321471
2017-12-27 06:54:18 +00:00
Rui Ueyama 130eb04689 [COFF] Do not parse args twice if no rsp files exists
Patch by Takuto Ikuta.

This patch reduces link time of chromium's blink_core.dll in component
build. Total size of input argument in .directives become nearly 300MB
in the build and no rsp file is used. Speedup link by skipping duplicate
parsing.

On my desktop machine, 4 times stats are like below. Improved around 15%.

This patch
TotalSeconds : 18.408538
TotalSeconds : 17.2996744
TotalSeconds : 17.1053862
TotalSeconds : 17.809777
avg: 17.6558439

master
TotalSeconds : 20.9290504
TotalSeconds : 19.9158213
TotalSeconds : 21.0643515
TotalSeconds : 20.8775831
avg: 20.696701575

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

llvm-svn: 321470
2017-12-27 06:08:10 +00:00
Rafael Espindola 63a4a98e4c Add a comment about subtracting two non abs symbols. NFC.
llvm-svn: 321458
2017-12-26 18:11:14 +00:00
Rui Ueyama c67d6b2da0 Simplify script lexer.
Differential Revision: https://reviews.llvm.org/D41577

llvm-svn: 321453
2017-12-26 10:13:10 +00:00
Rafael Espindola a9c490b71d Allow relocations in rw sections to create plt entries.
If a relocation cannot be implemented by the dynamic linker and the
section is rw, allow creating a plt entry to use as the function
address as if the section was ro.

This matches bfd and gold. It also matches our behavior with -z
notext.

llvm-svn: 321430
2017-12-24 19:02:10 +00:00
Rafael Espindola 6a97f80755 Fix output section offset and contents when linker script uses memory region and data commands.
Advance the memory region offset when handling a linker script data
command such as BYTE or LONG.  Failure to advance the offset results
in corrupted output with overlapping sections.

Update tests to check for this combination of both a) memory regions
and b) data commands.

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

Patch by Owen Shaw!

llvm-svn: 321418
2017-12-24 03:46:35 +00:00
Rafael Espindola 9a84f6b954 Detemplate reportDuplicate.
We normally avoid "switch (Config->EKind)", but in this case I think
it is worth it.

It is only executed when there is an error and it allows detemplating
a lot of code.

llvm-svn: 321404
2017-12-23 17:21:39 +00:00
George Rimar d70da0e55f [ELF] - Fix mistype in comment. NFC.
llvm-svn: 321403
2017-12-23 16:34:58 +00:00
George Rimar 3bdf6baa25 [ELF] - Allow using PLT relocations when "-z notext" is given.
This is part of PR35720.

Currently LLD allows dynamic relocations against text when -z notext is given.
Though for non-PIC relocations like R_X86_64_PC32 that does not work,
we produce "relocation R_X86_64_PC32 cannot be used against shared object;"
error because they may overflow in runtime.

Solution implemented is to use PLT for them.

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

llvm-svn: 321400
2017-12-23 09:00:37 +00:00
Rafael Espindola 9f37543cf8 Detemplate isCompatible(). NFC.
llvm-svn: 321393
2017-12-23 00:04:34 +00:00
Rafael Espindola 9cbb6dd1fc Result of subtracting two symbols should be absolute.
When two linker script symbols are subtracted, the result should be absolute.

This is the behavior of binutils' ld.

Patch by Erick Reyes!

llvm-svn: 321390
2017-12-22 21:55:28 +00:00
Sam Clegg 5cfffbc875 [WebAssembly] Increase test coverage for weak aliases
LLVM-side is now fixed

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

llvm-svn: 321385
2017-12-22 20:35:19 +00:00
Rafael Espindola bb2f9081dc Note that the test .tar.xz has been updated.
The difference is the avoidance of a few absolute paths. Thanks to
Galina Kistanova for the patch.

llvm-svn: 321381
2017-12-22 19:37:32 +00:00
Rafael Espindola b9a18fd0a2 Define isUndefWeak inline.
This small function was showing up in the profile. Defining it inline
gives about 0.3% speedup.

llvm-svn: 321317
2017-12-21 22:26:44 +00:00
Rafael Espindola a973cc2282 Call isStaticLinkTimeConstant only once per relocation.
It is a pretty expensive function. Some of the speedups:

clang: 1.92%
chrome: 1.15%
linux-kernel: 1.40%
llvm-svn: 321311
2017-12-21 21:45:35 +00:00
Sam Clegg 86109f63c8 [WebAssembly] Add extra test for weak global symbols
Summary:
Currently the test only checks behaviour for weak function symbols.

Should be good to merge straight away?

Reviewers: sbc100

Reviewed By: sbc100

Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish, llvm-commits

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

llvm-svn: 321308
2017-12-21 21:15:00 +00:00
Sam Clegg 1cf31bbca5 [WebAssmebly] Fix references to weak aliases
Corresponding LLVM change: https://reviews.llvm.org/D41472

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

llvm-svn: 321244
2017-12-21 02:43:39 +00:00
Sam Clegg c6e4d73f31 [WebAssembly] Improve weak alias tests cases
Based on: https://github.com/WebAssembly/tool-conventions/issues/34

Currently weak-alias-overide.ll exhibits incorrect
behaviour in that call_direct() calls the wrong function.

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

llvm-svn: 321241
2017-12-21 02:30:09 +00:00
Rafael Espindola ce3b52c186 Pass an InputFile to the InputSection constructor.
This simplifies toRegularSection and reduces the noise in a followup
patch.

llvm-svn: 321240
2017-12-21 02:11:51 +00:00
Rafael Espindola 604032729c Convert a few more InputFiles to references.
We use null files in sections to represent linker created sections,
so ObjFile<ELFT> is never null.

llvm-svn: 321238
2017-12-21 02:03:39 +00:00
Rafael Espindola 5c73c49c9f Detemplate createCommentSection.
It was only templated so it could create a dummy section header that
was immediately parsed back.

llvm-svn: 321235
2017-12-21 01:21:59 +00:00
Rafael Espindola bb3198949f Use dyn_cast instead of dyn_cast_or_null.
There should be no null sections in InputSections.

llvm-svn: 321219
2017-12-20 20:46:08 +00:00
Rafael Espindola 920d7d80e2 clang-format. NFC.
llvm-svn: 321216
2017-12-20 19:59:47 +00:00
Rafael Espindola efb483f63a Pass a InputFile reference to the Lazy constructor. NFC.
llvm-svn: 321199
2017-12-20 18:01:32 +00:00
Rafael Espindola 8276f1bda6 Use a reference to a file in the LazyArchive symbol.
It is never null.

llvm-svn: 321198
2017-12-20 17:59:43 +00:00
Rafael Espindola 2e5c71eadc LazyObject's file is never null, use a reference.
llvm-svn: 321196
2017-12-20 17:52:36 +00:00
Rafael Espindola 8cd6674f5b Use a reference in addLazyArchive. NFC.
llvm-svn: 321194
2017-12-20 17:48:28 +00:00
Rafael Espindola a32ddc4639 Use a reference for the shared symbol file.
Every shared symbol has a file, so we can use a reference.

llvm-svn: 321187
2017-12-20 16:28:19 +00:00
Rafael Espindola 7b5cc6c5dc Use a reference for a value that is never null. NFC.
llvm-svn: 321186
2017-12-20 16:19:48 +00:00
Rafael Espindola f1687125ba Use a reference for a value that is never null. NFC.
llvm-svn: 321185
2017-12-20 16:16:40 +00:00
Igor Kudrin 5966d15943 [ELF] Fix an assignment command at the end of an .ARM.exidx section.
The value of the symbol in the assignment should include the sentinel entry.

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

llvm-svn: 321154
2017-12-20 08:56:10 +00:00
Martin Storsjo 6528fb8691 [COFF] Don't set the thumb bit in address table entries for data symbols
The thumb bit should only be set for executable code.

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

llvm-svn: 321149
2017-12-20 06:50:45 +00:00
Sam Clegg ab2ac29066 [WebAssembly] Improve toString(OutputSection). NFC.
llvm-svn: 321146
2017-12-20 05:14:48 +00:00
Rafael Espindola 092ba58bee Replace a dyn_cast_or_null with dyn_cast.
The variable being casted was accessed in the previous line.

llvm-svn: 321140
2017-12-20 01:57:19 +00:00
Sam Clegg 7075d3fc1c [WebAssembly] Add test of indirect call to an otherwise unused type
In this case we are calling a function pointer which
a type that doesn't otherwise exist in the code.
Clearly this code can't would trap if it was ever
called (because there is not such function that
the pointer can resolve to).

But it should valid and compile and link and validation
time.

llvm-svn: 321134
2017-12-20 01:17:45 +00:00
Rafael Espindola 1037eef8e0 Use references instead of pointers. NFC.
These values are trivially never null. While at it, also use
InputSection instead of InputSectionBase when possible.

llvm-svn: 321126
2017-12-19 23:59:35 +00:00
Sam Clegg 5e8cba9e39 [WebAssembly] Apply data relocations in parallel. NFC.
Store data relocations with their respective segment.
This allows relocations to be applied as each segment
is written (and therefore in parallel).

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

llvm-svn: 321105
2017-12-19 20:45:15 +00:00
Sam Clegg d451da1bd1 [WebAssembly] Fix a couple of typos. NFC.
Also remove unneeded braces and old comment.

llvm-svn: 321103
2017-12-19 19:56:27 +00:00
Sam Clegg f738bccd76 [WebAssembly] Fix typo
Patch by Nicholas Wilson

llvm-svn: 321097
2017-12-19 18:36:31 +00:00
Sam Clegg 5b1216c41e [WebAssembly] Remove used member from SymbolTable
Patch by Nicholas Wilson

llvm-svn: 321096
2017-12-19 18:32:13 +00:00
Sam Clegg 0d0dd39159 [WebAssembly] Add support for writing out init functions in linking section
This change add support for init functions in the linking
section, but only in -r/--relocatable mode.

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

llvm-svn: 321088
2017-12-19 17:09:45 +00:00
Rafael Espindola fc29b8dd63 Remove unnecessary this->. NFC.
llvm-svn: 321081
2017-12-19 16:29:02 +00:00
Rafael Espindola 4e125de4a6 Use # instead of // for comments in a test.
The test was using both // and # before.

llvm-svn: 321049
2017-12-19 00:53:06 +00:00
Sam Clegg bd0416d0c0 [WebAssemlby] Fix typo in target triple used in tests
llvm-svn: 321044
2017-12-19 00:18:16 +00:00