Commit Graph

7306 Commits

Author SHA1 Message Date
Rui Ueyama 0ede7f281e Make log(), error() and fatal() thread-safe.
llvm-svn: 287794
2016-11-23 18:34:28 +00:00
Rui Ueyama ac95f6bfcc Limit default maximum number of errors to 20.
This is in the context of https://llvm.org/bugs/show_bug.cgi?id=31109.
When LLD prints out errors for relocations, it tends to print out
extremely large number of errors (like millions) because it would
print out one error per relocation.

This patch makes LLD bail out if it prints out more than 20 errors.
You can configure the limitation using -error-limit argument.
-error-limit=0 means no limit.

I chose the flag name because Clang has the same feature as -ferror-limit.
"f" doesn't make sense to us, so I omitted it.

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

llvm-svn: 287789
2016-11-23 18:15:37 +00:00
Rui Ueyama 28590b6118 Re-commit r287727: Use SHA1::hash and MD5::hash functions.
r287727 was not a change that broke buildbots; the other change
(r287726) that I made to LLVM broke them.

llvm-svn: 287788
2016-11-23 18:11:38 +00:00
Rui Ueyama 3fc0f7e54f Define toString() as a generic function to get a string for error message.
We have different functions to stringize objects to construct
error messages. For InputFile, we have getFilename, and for
InputSection, we have getName. You had to memorize them.

I think this is the case where the function overloading comes in handy.

This patch defines toString() functions that are overloaded for all these
types, so that you just call it in error().

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

llvm-svn: 287787
2016-11-23 18:07:33 +00:00
Ed Maste 8fd0196c6f lld: Default image base address to 0x200000 on x86-64
Align to the large page size (known as a superpage or huge page).
FreeBSD automatically promotes large, superpage-aligned allocations.

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

llvm-svn: 287782
2016-11-23 17:44:02 +00:00
Ed Maste 8d0381d61f Replace test instruction byte strings with {{.*}}
An upcoming change to the image base address for x86-64 (D27042) will
will change some addresses and hence the instruction encodings. We care
about the disassembled instructions, not their encodings.

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

llvm-svn: 287778
2016-11-23 17:09:38 +00:00
Eugene Leviant c3a44b2fbe [ELF] Refactor several error messages
Differential revision: https://reviews.llvm.org/D26970

llvm-svn: 287753
2016-11-23 10:07:46 +00:00
Eugene Leviant 3582ebf35e [ELF] Fixup buffer pointer when writing synthetic sections
Differential revision: https://reviews.llvm.org/D26980

llvm-svn: 287751
2016-11-23 09:47:38 +00:00
Eugene Leviant 531df4fcef [ELF] Print error location in .eh_frame parser
Differential revision: https://reviews.llvm.org/D26914

llvm-svn: 287750
2016-11-23 09:45:17 +00:00
Rui Ueyama 0cbf749397 Remove one of SymbolTable::addRegular function that forwards other addRegular.
So that we have less number of overloaded functions.

llvm-svn: 287745
2016-11-23 06:59:47 +00:00
Rui Ueyama 768c6f0ca6 Remove a forwarding constructor that is used only once.
llvm-svn: 287742
2016-11-23 06:31:23 +00:00
Rui Ueyama 35fa6c58ad Parse symbol versions in scanVersionScript() instead of insert().
There are two ways to set symbol versions. One way is to use symbol
definition file, and the other is to embed version names to symbol
names. In the latter way, symbol name is in the form of `foo@version1`
where `foo` is a real name and `version1` is a version.

We were parsing symbol names in insert(). That seems unnecessarily
too early. We can do it later after we resolve all symbols. Doing it
lazily is a good thing because it makes code easier to read
(because now we have a separate pass to parse symbol names). Also
it could slightly improve performance because if two identical symbols
have versions, we now parse them only once.

llvm-svn: 287741
2016-11-23 05:48:40 +00:00
Simon Atanasyan 399ac5c3fb [ELF][MIPS] Turn Config->Threads off for MIPS targets
For now MipsGotSection class is not ready for concurrent access from
multiple threads. The problem is in the getPageEntryOffset method. It
changes state of MipsGotSection object and might be called from
different threads at the same time. So turn Threads off for this target.

It's a temporary solution. The patch fixes MipsGotSection::getPageEntryOffset
is almost ready.

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

llvm-svn: 287740
2016-11-23 05:25:02 +00:00
Rui Ueyama d14743e17f Better formatting.
If a line is too long, its error message becomes hard to read.

llvm-svn: 287739
2016-11-23 05:14:01 +00:00
Simon Atanasyan 97deade619 [ELF][MIPS] clang-format the code
llvm-svn: 287738
2016-11-23 05:09:36 +00:00
Rui Ueyama c72ba3a4d7 Allow calling getName() on local symbols.
Previously, we stored offsets in string tables to symbols, so
you needed to pass a string table to get a symbol name. This patch
stores const char pointers instead to eliminate the need to pass
a string table.

llvm-svn: 287737
2016-11-23 04:57:25 +00:00
Rui Ueyama fd265a1f30 Revert r287727: Use SHA1::hash and MD5::hash functions.
It broke buildbots.

llvm-svn: 287730
2016-11-23 01:19:13 +00:00
Rui Ueyama be6c2f1a36 Use SHA1::hash and MD5::hash functions.
llvm-svn: 287727
2016-11-23 00:52:28 +00:00
Rui Ueyama 24625fd9b2 Dump not only type records but symbol records.
llvm-svn: 287723
2016-11-22 23:51:34 +00:00
Rui Ueyama 3cc93d7a53 Fix memory leak detected by asan.
llvm-svn: 287714
2016-11-22 23:13:08 +00:00
Rui Ueyama 838ff4d5c5 Accept -script=<file> in addition to -script <file>.
Fixes PR31126.

llvm-svn: 287711
2016-11-22 22:54:03 +00:00
Rafael Espindola 4e1a698be0 Fix test to not depend on the path size.
llvm-svn: 287704
2016-11-22 21:37:38 +00:00
Rafael Espindola 3c97dc7055 move VerDef finalization before DynStrTab
llvm-svn: 287701
2016-11-22 21:12:20 +00:00
Davide Italiano f4de3b68bb [LTO] Remove a check on datalayout.
Now that lld switched to lib/LTO, which always calls setDataLayout(),
we don't need this check anymore.
Thanks to Peter for pointing out!

llvm-svn: 287699
2016-11-22 20:37:37 +00:00
Rui Ueyama 8a44c94b8a Remove '.' from a help message.
llvm-svn: 287692
2016-11-22 20:15:35 +00:00
Rui Ueyama bdfa155fa2 Fix build breakage.
We cannot have MipsRldMap class and In<ELFT>::MipsRldMap.
Renamed the class.

llvm-svn: 287683
2016-11-22 19:24:52 +00:00
Meador Inge b2d99d6a0f [ELF] Allow `ASSERT` in output section descriptions
GNU LD allows `ASSERT` commands to be in output section descriptions.
Note that LD also mandates that `ASSERT` commands in this context must
end with a semicolon.

llvm-svn: 287677
2016-11-22 18:01:50 +00:00
Eugene Leviant 17b7a57533 [ELF] Convert .rld_map to input section
Differential revision: https://reviews.llvm.org/D26958

llvm-svn: 287675
2016-11-22 17:49:14 +00:00
Rui Ueyama 81a4b26b48 Inline small function. NFC.
llvm-svn: 287620
2016-11-22 04:33:01 +00:00
Rui Ueyama 1d75de00e8 Do not save unused pointers to In<ELFT>.
llvm-svn: 287617
2016-11-22 04:28:39 +00:00
Rui Ueyama 8b493f1ac6 Remove default definition no one uses.
llvm-svn: 287616
2016-11-22 04:17:12 +00:00
Rui Ueyama 9cfac8a849 Convert MipsOptionsSection to SyntheticSection.
llvm-svn: 287615
2016-11-22 04:13:09 +00:00
Rui Ueyama b71cae90de Convert MipsReginfoSection to SyntheticSection.
llvm-svn: 287614
2016-11-22 03:57:08 +00:00
Rui Ueyama 12f2da870e Convert MipsAbiFlagsSection to SyntheticSection.
llvm-svn: 287613
2016-11-22 03:57:06 +00:00
Rui Ueyama bb536fee32 Remove redundant assignment.
llvm-svn: 287607
2016-11-22 01:36:19 +00:00
Rui Ueyama 2d98fead25 Convert BuildId a derived class of SyntheticSection.
Some synthetic sections are not derived calsses of SyntehticSection.
They are derived directly from InputSection. For consistencly, we should
use SyntheticSection.

llvm-svn: 287606
2016-11-22 01:31:32 +00:00
Rui Ueyama ee18d95764 Remove a parameter from getOutputLoc and rename for readability. NFC.
llvm-svn: 287605
2016-11-22 01:10:34 +00:00
Rui Ueyama c4030a1937 Merge BuildId subclasses.
We had five different BuildId subclasses for five different types
of build-ids. They can simply be merged to a single class.

llvm-svn: 287603
2016-11-22 00:54:15 +00:00
Rui Ueyama d30cf96203 Remove useless newlines.
llvm-svn: 287595
2016-11-21 23:17:09 +00:00
Rafael Espindola 28d5f059ae Use the correct page size.
Config->MaxPageSize is what we use for the segment alignment, so that
is the one that we have to use for placing the header.

llvm-svn: 287569
2016-11-21 20:20:04 +00:00
Rafael Espindola 1c57007ec8 Fix address computation for headers.
If the linker script has SECTIONS, the address computation is now
always done in LinkerScript::assignAddresses, like for any other
section.

Before fixHeaders would do a tentative computation that
assignAddresses would sometimes override.

This patch also splits the cases where assignAddresses needs to add
the headers to the first PT_LOAD and the address computation. The net
effect is that we no longer create an empty page for no reason in the
included test case, which matches bfd behavior.

llvm-svn: 287565
2016-11-21 19:59:33 +00:00
Rui Ueyama b38ddb15dd Move a function definition to SyntheticSections.cpp.
This should have been moved along with r287554.

llvm-svn: 287564
2016-11-21 19:46:04 +00:00
Rui Ueyama be939b3ff6 Do plumbing work for CodeView debug info.
Previously, we discarded .debug$ sections. This patch adds them to
files so that PDB.cpp can access them.

This patch also adds a debug option, /dumppdb, to dump debug info
fed to createPDB so that we can verify that valid data has been passed.

llvm-svn: 287555
2016-11-21 17:22:35 +00:00
Eugene Leviant e9bab5d857 [ELF] Convert Version*** sections to input sections
Differential revision: https://reviews.llvm.org/D26918

llvm-svn: 287554
2016-11-21 16:59:33 +00:00
Eugene Leviant 952eb4d348 [ELF] Convert EhFrameHeader to input section
Differential revision: https://reviews.llvm.org/D26906

llvm-svn: 287549
2016-11-21 15:52:10 +00:00
Eugene Leviant 03ff016666 [ELF] Better error reporting for linker scripts
Differential revision: https://reviews.llvm.org/D26795

llvm-svn: 287547
2016-11-21 15:49:56 +00:00
Eugene Leviant 91972d7f9d [ELF] Attempt to fix Windows buidbot
llvm-svn: 287538
2016-11-21 13:57:50 +00:00
Rui Ueyama e8785ba4d7 Change the way how we print out line numbers.
LLD's error messages contain line numbers, function names or section names.
Currently they are formatter as follows.

  foo.c (32): symbol 'foo' not found
  foo.c (function bar): symbol 'foo' not found
  foo.c (.text+0x1234): symbol 'foo' not found

This patch changes them so that they are consistent with Clang's output.

  foo.c:32: symbol 'foo' not found
  foo.c:(function bar): symbol 'foo' not found
  foo.c:(.text+0x1234): symbol 'foo' not found

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

llvm-svn: 287537
2016-11-21 13:49:57 +00:00
Eugene Leviant 7d7ff80f4b [ELF] Better error reporting for broken archives
Differential revision: https://reviews.llvm.org/D26852

llvm-svn: 287527
2016-11-21 09:28:07 +00:00
Eugene Leviant a113a4194c [ELF] Convert GdbIndexSection to input section
Differential revision: https://reviews.llvm.org/D26854

llvm-svn: 287526
2016-11-21 09:24:43 +00:00