Commit Graph

7323 Commits

Author SHA1 Message Date
Eugene Leviant c8c1b7bfae [ELF] EhOutputSection improvements
Differential revision: https://reviews.llvm.org/D27098

llvm-svn: 287914
2016-11-25 08:27:15 +00:00
George Rimar 11992c86d9 [ELF] - Add support for access to most of synthetic sections from linkerscript.
This is important for cases like:

  .sdata        : {
    *(.got.plt .got)
...
  }

That was not supported before as there was no way to get access to 
synthetic sections from script.

More details on review page.

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

llvm-svn: 287913
2016-11-25 08:05:41 +00:00
Rui Ueyama 26081caf48 Use toString() to report incompatible files.
llvm-svn: 287901
2016-11-24 20:59:44 +00:00
Rui Ueyama d4c94d1899 Include a hint how to see all errors if error is truncated.
This patch changes the error message from

  too many errors emitted, stopping now

to

  too many errors emitted, stopping now (use -error-limit=0 to see all errors)

Thanks for Sean for the suggestion!

llvm-svn: 287900
2016-11-24 20:31:43 +00:00
Rui Ueyama a3ac17372b Define toString(const SymbolBody &) and remove maybeDemangle instead.
Differential Revision: https://reviews.llvm.org/D27065

llvm-svn: 287899
2016-11-24 20:24:18 +00:00
Rafael Espindola 4862ae8cc5 Use a more explicit type for the sizeof.
llvm-svn: 287895
2016-11-24 16:38:35 +00:00
Peter Smith 719eb8efa5 [ELF] Add terminating sentinel .ARM.exidx table entry
The .ARM.exidx table has an entry for each function with the first entry
giving the start address of the function, the table is sorted in ascending
order of function address. Given a PC value, the unwinder will search the
table for the entry that contains the PC value.
    
If the table entry happens to be the last, the range of the addresses that
the final unwinding table describes will extend to the end of the address
space. To prevent an incorrect address outside the address range of the
program matching the last entry we follow ld.bfd's example and add a
sentinel EXIDX_CANTUNWIND entry at the end of the table. This gives the
final real table entry an upper bound.
    
In addition the llvm libunwind unwinder currently depends on the presence
of a sentinel entry (PR31091).

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

llvm-svn: 287869
2016-11-24 11:43:55 +00:00
George Rimar 066bf6e1b3 [ELF] - Removed unused method. NFC.
llvm-svn: 287860
2016-11-24 09:42:10 +00:00
Rui Ueyama 3aaacb282f Update comment.
llvm-svn: 287850
2016-11-24 01:44:21 +00:00
Rui Ueyama f373dd76ce Remove HasError and use ErrorCount instead.
HasError was always true if ErrorCount > 0, so we can use ErrorCount instead.

llvm-svn: 287849
2016-11-24 01:43:21 +00:00
Rui Ueyama bf9523f549 [COFF] Add DebugInfoCodeView dependency
rL287555 introduces a link error when building with BUILD_SHARED_LIBS:

  undefined reference to llvm::codeview::CVSymbolDumper::dump(),
  and more...

The functions are available in libDebugInfoCodeView, from LLVM.

Patch by Visoiu Mistrih Francis!

llvm-svn: 287837
2016-11-23 22:58:25 +00:00
Rui Ueyama 2eda6d1633 Set default entry point to .text if no entry point is found.
Previously, if a symbol specified by -e or ENTRY() is not found,
we didn't set entry point address. That is incompatible with GNU
because GNU linkers set the first address of .text to entry.
This patch implement that behavior.

llvm-svn: 287836
2016-11-23 22:41:00 +00:00
Simon Atanasyan 8469b8841c [ELF][MIPS] Fix handling of _gp/_gp_disp/__gnu_local_gp symbols
Offset between beginning of a .got section and _gp symbols used in MIPS
GOT relocations calculations. Usually the expression looks like
VA + Offset - GP, where VA is the .got section address, Offset - offset
of the GOT entry, GP - offset between .got and _gp. Also there two "magic"
symbols _gp_disp and __gnu_local_gp which hold the offset mentioned above.
These symbols might be referenced by MIPS relocations.

Now the linker always defines _gp symbol and uses hardcoded value for
its initialization. So offset between .got and _gp is 0x7ff0. The _gp_disp
and __gnu_local_gp defined if required and initialized by 0x7ff0.
In fact that is not correct because _gp symbol might be defined by a linker
script and holds arbitrary value. In that case we need to use this value
in relocation calculation and initialize _gp_disp and __gnu_local_gp
properly.

The patch fixes the problem and completes fixing the bug #30311.
https://llvm.org/bugs/show_bug.cgi?id=30311

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

llvm-svn: 287832
2016-11-23 22:22:16 +00:00
Rui Ueyama 835bd72322 Remove trailing whitespace.
llvm-svn: 287830
2016-11-23 22:10:46 +00:00
Rui Ueyama d3a06ffb1c Use llvm::utohexstr instead of Twine::utohexstr.
They are essentially the same in this context, so I prefer the one
that doesn't need `Twine::`.

llvm-svn: 287814
2016-11-23 21:24:26 +00:00
Rafael Espindola 20b6d3d0d3 Fix this on 32 bit hosts.
Looks like we have no 32 bit bot that builds with mips support.

llvm-svn: 287799
2016-11-23 19:16:20 +00:00
Rui Ueyama 1b591cf3d3 Fix uninitialized variable access.
llvm-svn: 287797
2016-11-23 19:03:35 +00:00
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