Commit Graph

8087 Commits

Author SHA1 Message Date
Rui Ueyama fd06b73466 Define Config::isLE and Config::wordsize.
isLE() return true if the target is little-endian.
wordsize() returns 8 for 64-bit and 4 for 32-bit.

llvm-svn: 298167
2017-03-17 23:28:41 +00:00
Peter Collingbourne 5758b2e488 ELF: Change check(Expected<T>, const Twine &) to call toString instead of converting to an error code.
llvm-svn: 298155
2017-03-17 22:06:36 +00:00
Evgeniy Stepanov 4b78036ba8 [ELF] Restore GC handling of LINK_ORDER, C-named sections.
__start_xxx symbol keeps section xxx alive only if it is not
SHF_LINK_ORDER. Such sections can be used for user metadata, when
__start_xxx is used to iterate over section contents at runtime, and
the liveness is determined solely by the linked (associated) section.

This was earlier implemented in r294592, and broken in r296723.

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

llvm-svn: 298154
2017-03-17 22:04:52 +00:00
Bob Haarman f790f788b6 recommend using llvm-ar when finding undefined references and empty archives
Summary:
When we perform LTO builds with a version of ar that does not
understand LLVM bitcode objects, we end up with undefined references,
because our archive files do not list the bitcode symbols in their
indices. The error messages do not make it clear what the real problem
is. This change adds a note that points out the likely problem and
solution. It is similar in spirit to r282633, but aims to avoid false
positives by only triggering when we see both undefined references and
archives without symbols in their indices.

Fixes PR32281.

Reviewers: davide, ruiu, tejohnson

Subscribers: llvm-commits

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

llvm-svn: 298124
2017-03-17 21:32:49 +00:00
George Rimar a918957b05 [ELF] - Move template instantiations to the end of file. NFC.
To be consistent with other code, addresses post 
commit review comments.

llvm-svn: 298102
2017-03-17 16:50:07 +00:00
Rafael Espindola 7ba5f47eb8 Handle & and | of non abs values.
Handling & in particular is probably important because of its use in
aligning addresses.

llvm-svn: 298096
2017-03-17 14:55:36 +00:00
Rafael Espindola 5f08a1dca8 Refuse to add two non absolute symbols.
Since there is no way to produce the correct answer at runtime, it is
probably better to just err.

llvm-svn: 298094
2017-03-17 14:51:07 +00:00
Simon Atanasyan 462f84a736 [ELF][MIPS] Always collect .reginfo, .MIPS.options, and .MIPS.abiflags input sections
Do not take in account the `Live` flag while collecting .reginfo, .MIPS.options,
and .MIPS.abiflags input sections to produce corresponding output sections.
These sections have information purpose and should be always produced per
ABI requirements.

llvm-svn: 298093
2017-03-17 14:27:55 +00:00
George Rimar 4afe42e5c4 [ELF] - Detemplate SymbolBody::getGotOffset(). NFC.
llvm-svn: 298091
2017-03-17 14:12:51 +00:00
Rafael Espindola f2115f04c8 Support non abs values in the rhs of +.
llvm-svn: 298088
2017-03-17 13:45:36 +00:00
George Rimar 8fe7aea527 [ELF] - Detemplate findSection() global static method. NFC.
llvm-svn: 298087
2017-03-17 13:43:24 +00:00
George Rimar 176d606020 [ELF] - Recommit r298078 "[ELF] - Simplify logic of creating "COMMON" section."
With fix of next warning:
Writer.cpp:361:3: warning: suggest parentheses around assignment used as truth value [-Wparentheses]

Original commit message:

Patch reuses BssSection section to simplify creation of 
COMMON section.

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

llvm-svn: 298086
2017-03-17 13:31:07 +00:00
George Rimar 4ddd9c9bd6 [ELF] - Revert r298078 and 298082
It segfaults.

llvm-svn: 298084
2017-03-17 13:21:22 +00:00
Rafael Espindola 5d5a267830 Add a test that now passes.
llvm-svn: 298083
2017-03-17 13:19:15 +00:00
George Rimar 69739e6d1d [ELF] - Fix warning.
Writer.cpp:361:3: warning: suggest parentheses around assignment used as truth value [-Wparentheses]

llvm-svn: 298082
2017-03-17 13:15:35 +00:00
Rafael Espindola 72dc195d78 Change our linker script expr representation.
This fixes pr32031 by representing the expressions results as a
SectionBase and offset. This allows us to use an input section
directly instead of getting lost trying to compute an offset in an
outputsection when not all the information is available yet.

This also creates a struct to represent the *value* of and expression,
allowing the expression itself to be a simple typedef. I think this is
easier to read and will make it easier to extend the expression
computation to handle more complicated cases.

llvm-svn: 298079
2017-03-17 13:05:04 +00:00
George Rimar f6c300e86d [ELF] - Simplify logic of creating "COMMON" section.
Patch reuses BssSection section to simplify creation of 
COMMON section.

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

llvm-svn: 298078
2017-03-17 13:04:06 +00:00
Rafael Espindola 490fccb170 Remove unnecessary (). NFC.
llvm-svn: 298076
2017-03-17 13:00:45 +00:00
George Rimar 97def8c2ff [ELF] - Detemplate DynamicReloc class. NFC.
llvm-svn: 298072
2017-03-17 12:07:44 +00:00
George Rimar f64618a621 [ELF] - Detemplate SymbolBody::getVA and SymbolBody::getPltVA. NFC.
llvm-svn: 298071
2017-03-17 11:56:54 +00:00
George Rimar 5a5c54f78e [ELF] - Fix linux build bot.
Error was:
Relocations.cpp:792:38: error: expected primary-expression before ‘>’ token
         In<ELFT>::Iplt->addEntry<ELFT>(Body);

llvm-svn: 298070
2017-03-17 11:41:56 +00:00
George Rimar dfc020e9f9 [ELF] - Detemplate PltSection. NFC.
Alternative approach can be remove templated method
either, like D31028 do.

llvm-svn: 298065
2017-03-17 11:01:57 +00:00
George Rimar fe93282a1b [ELF] - Fixed cache.ll testcase.
It failed for me under windows,
touch reported invalid date format.

Seems related to 12h/24h format, though
I don't understant why 197001010200 does not work, 
but 197001010300 works, I see no logic here.

Changed to 197001011200.

llvm-svn: 298064
2017-03-17 10:32:10 +00:00
George Rimar 1ab9cf49d0 [ELF] - Recommit "[ELF] - Make Bss and BssRelRo sections to be synthetic (#3)."
Was fixed, details on review page.

Original commit message:

That removes CopyRelSection class completely, making
Bss/BssRelRo to be just regular synthetics.

This is splitted from D30541 and polished.
Difference from D30541 that all logic of SharedSymbol
converting to DefinedRegular was removed for now and
probably will be posted as separate patch.

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

llvm-svn: 298062
2017-03-17 10:14:53 +00:00
Andre Vieira d74f31bf13 [ARM] Change tests after fixing branch label for Thumb targets
Patch to fix lld tests after my llvm-objdump patch to fix branch labels for
Thumb targets.

Reviewed by: emaste

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

llvm-svn: 298055
2017-03-17 09:37:02 +00:00
Peter Collingbourne a3abce911a Fix the touch command to be Darwin-compatible.
llvm-svn: 298038
2017-03-17 02:44:23 +00:00
Peter Collingbourne ee59e43f92 ELF: Add cache pruning support.
This patch causes us to use pruneCache() to prune the ThinLTO cache after
completing LTO. A new flag --thinlto-cache-policy allows users to configure
the policy.

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

llvm-svn: 298036
2017-03-17 02:24:16 +00:00
Peter Collingbourne 8713bf69b6 COFF: Strip /lldsavetemps from MSVC command line during /msvclto.
llvm-svn: 298035
2017-03-17 02:11:09 +00:00
Peter Collingbourne db7447deed COFF: Do not create empty temporary archives for /msvclto.
The MSVC linker doesn't support them.

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

llvm-svn: 298034
2017-03-17 02:04:22 +00:00
Peter Collingbourne a6ffbdd922 COFF: Fix use-after-free in /msvclto implementation.
The Archive object owns the memory buffers of any thin archive members, so we
need to make sure the object is still in scope when we access archive members.

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

llvm-svn: 298033
2017-03-17 02:03:20 +00:00
Peter Collingbourne 128423f99b LTO: Fix a potential race condition in the caching API.
After the call to sys::fs::exists succeeds, indicating a cache hit, we call
AddFile and the client will open the file using the supplied path. If the
client is using cache pruning, there is a potential race between the pruner
and the client. To avoid this, change the caching API so that it provides
a MemoryBuffer to the client, and have clients use that MemoryBuffer where
possible.

This scheme won't work with the gold plugin because the plugin API expects a
file path. So we have the gold plugin use the buffer identifier as a path and
live with the race for now. (Note that the gold plugin isn't actually affected
by the problem at the moment because it doesn't support cache pruning.)

This effectively reverts r279883 modulo the change to use the existing path
in the gold plugin.

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

llvm-svn: 298020
2017-03-17 00:34:07 +00:00
Rui Ueyama 98e55de699 Revert r297850: [ELF] - Linkerscript: make Dot public and remove getDot(). NFC.
This reverts commit r297850 because this change was made
based on a miscommunication.

llvm-svn: 298001
2017-03-16 21:50:30 +00:00
Rui Ueyama e1bf1365d7 Do not pass archive files containing non-native object files.
The MSVC linker doesn't like archive files containing non-native object
files.

When we are doing an LTO build, we may create archive files containing
both LLVM bitcode files and native object files. For example, if a
project contains assembly files and C++ files, we create native object
files for the assembly files and LLVM bitcode files for the C++ files.

With the /msvclto option, LLD passes archive files to the MSVC linker.
Previously, we didn't pass archive files if they contain at least one
bitcode files. That wasn't correct because the native object files that
weren't passed to the MSVC linker may be needed to complete linking.

In this patch, we create new temporary archive files to strip bitcode
files.

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

llvm-svn: 297997
2017-03-16 21:19:36 +00:00
George Rimar 7385d4358a [ELF] - Rename Config->Is64Bit() to is64(). NFC.
Addresses post commit review comment.

llvm-svn: 297953
2017-03-16 13:41:29 +00:00
George Rimar 4670bb00b5 [ELF] - Detemplate SymbolBody::getGotPltVA and SymbolBody::getGotPltOffset(). NFC.
That opens road to detemplate PltSection<ELFT>,
what allows then to detemplate all methods of SymbolBody.

llvm-svn: 297950
2017-03-16 12:58:11 +00:00
George Rimar f00c183847 [ELF] Fix builbot.
Excessive typename keyword.

llvm-svn: 297949
2017-03-16 12:20:19 +00:00
George Rimar 5781338f0e [ELF] - Added test for versioned symbols involved in copy relocations.
This test would have been broken if we convert SharedSymbols
to DefinerRegular without saving the symbol version information when
creating .bss/.bss.rel.ro sections for copy relocations.

Relative to D30541, PR32167

llvm-svn: 297948
2017-03-16 12:17:49 +00:00
George Rimar a0b1e2c3d8 [ELF] - Don't use uintX_t in DynamicReloc<ELFT>. NFC.
That allows to detemplate getGotPltOffset/getGotPltVA
methods of SymbolBody and also will help to detemplate
DynamicReloc itself later.

llvm-svn: 297946
2017-03-16 11:42:16 +00:00
George Rimar 7702bc237e [ELF] - Removed unused templates #4. NFC.
llvm-svn: 297944
2017-03-16 11:20:02 +00:00
George Rimar 69268a8ab3 [ELF] - Detemplate SymbolBody::getOutputSection(). NFC.
llvm-svn: 297943
2017-03-16 11:06:13 +00:00
George Rimar a92dc2bbd3 [ELF] - Removed unused template #3. NFC.
llvm-svn: 297942
2017-03-16 10:55:45 +00:00
George Rimar d3ea775894 [ELF] - Removed unused template #2. NFC.
llvm-svn: 297941
2017-03-16 10:48:40 +00:00
George Rimar 7b8270424e [ELF] Detemplate ThunkSection and Thunk classes. NFC.
llvm-svn: 297939
2017-03-16 10:40:50 +00:00
George Rimar 49a47f2a6d [ELF] - Removed unused template #1. NFC
llvm-svn: 297938
2017-03-16 10:29:44 +00:00
George Rimar f98c5c126c [ELF] - Detemplate OutputSection::assignOffsets. NFC.
llvm-svn: 297937
2017-03-16 10:24:54 +00:00
George Rimar 47bed8c9f7 Revert r297813 "[ELF] - Make Bss and BssRelRo sections to be synthetic (#3)."
I suppose it is the reason of BB fail:
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/921

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

llvm-svn: 297933
2017-03-16 08:44:53 +00:00
Zachary Turner 337e884643 Fix lld pdb test.
It was assuming various things about the PDB like file size
which are going to be too high maintenance to maintain in
a test.

llvm-svn: 297908
2017-03-15 22:58:10 +00:00
Zachary Turner ea4e60754e [pdb] Write the module info and symbol record streams.
Previously we did not have support for writing detailed
module information for each module, as well as the symbol
records.  This patch adds support for this, and in doing
so enables the ability to construct minimal PDBs from
just a few lines of YAML.  A test is added to illustrate
this functionality.

llvm-svn: 297900
2017-03-15 22:18:53 +00:00
George Rimar 20055d4cd2 [ELF] - Linkerscript: make Dot public and remove getDot(). NFC.
Suggested by Rui Ueyama,
also groups member variables in a single place, while I am here.

llvm-svn: 297850
2017-03-15 16:07:02 +00:00
George Rimar 503206c567 [ELF] - Move LinkerScript::discard to LinkerScriptBase. NFC.
Became possible after r297844

llvm-svn: 297848
2017-03-15 15:42:44 +00:00