Commit Graph

404 Commits

Author SHA1 Message Date
Rafael Espindola 895aea6d15 Reduce template usage. NFC.
llvm-svn: 302832
2017-05-11 22:02:41 +00:00
Rafael Espindola 0f6cc65fe9 Remember OffsetInArchive in LazyObjectFile.
LazyObjectFile might turn out to be a BitcodeFile, so we need
OffsetInArchive.

llvm-svn: 302242
2017-05-05 15:17:07 +00:00
Rafael Espindola 80ae8ae186 Remember archive name when creating LazyObjectFile.
It is needed for creating an unique identifier for ThinLTO.

This fixes pr32931.

llvm-svn: 302235
2017-05-05 13:55:51 +00:00
Rafael Espindola 808f2d3c62 Reduce code duplication. NFC.
llvm-svn: 302155
2017-05-04 14:54:48 +00:00
Rui Ueyama fd7deda57a Accept archive files with no symbol table instad of warning on them.
It seems virtually everyone who tries to do LTO build with Clang and
LLD was hit by a mistake to forget using llvm-ar command to create
archive files. I wasn't an exception. Since this is an annoying common
issue, it is probably better to handle that gracefully rather than
reporting an error and tell the user to redo build with different
configuration.

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

llvm-svn: 302083
2017-05-03 21:03:08 +00:00
Rui Ueyama c344313803 Fix typo.
llvm-svn: 301975
2017-05-02 21:16:06 +00:00
Rui Ueyama dfb1e2a1a1 Update commetns.
llvm-svn: 301896
2017-05-02 02:58:04 +00:00
Rui Ueyama 92a8d798b8 Add comments about how we handle mergeable sections with relocations.
Also factored out code.

llvm-svn: 301833
2017-05-01 20:49:09 +00:00
Davide Italiano d765638ad1 [ELF] When a rel points to a SHF_MERGE section, don't merge the sec.
Fixes PR32785. Thanks to Piotr Padlewski for the report and
Rafael for the fix.

llvm-svn: 301729
2017-04-29 01:24:34 +00:00
Rui Ueyama e2f11690fe Eliminate .debug_gnu_pub{names,types} if -gdb-index is given.
This patch is to ignore .debug_gnu_pub{names,types} sections if the
-gdb-index option was given.

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

llvm-svn: 301710
2017-04-28 22:46:55 +00:00
Rui Ueyama 8a3ef95fc9 Use toString(Inputfile*) to format a file object.
llvm-svn: 301674
2017-04-28 20:00:09 +00:00
Rui Ueyama c9d82b9e16 Simplify BinaryFile::parse and add comments.
llvm-svn: 301514
2017-04-27 04:01:36 +00:00
Rui Ueyama 63d48e5956 Remove needless type conversions.
llvm-svn: 301513
2017-04-27 04:01:14 +00:00
Rui Ueyama e5ad2986fc Remove unnecessary instantiation of StringRef.
SoName's type has changed from StringRef to std::string, so this
code does not make sense anymore.

llvm-svn: 301490
2017-04-26 23:00:32 +00:00
Rui Ueyama 330e52b018 Removes createELFFile which takes a template class as a template parameter.
This patch is to reduce amount of template uses. The new code is less
exciting and boring than before, but I think it is easier to read.

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

llvm-svn: 301488
2017-04-26 22:51:51 +00:00
Rafael Espindola 3460cdd440 Remove DefaultSoName.
We can just use the existing SoName member variable. It now initially
contains what was in DefaultSoName and is modified if the .so has an
actual soname.

llvm-svn: 301259
2017-04-24 21:44:20 +00:00
Peter Collingbourne 8446f1fe6a Object, LTO: Add target triple to irsymtab and LTO API.
Start using it in LLD to avoid needing to read bitcode again just to get the
target triple, and in llvm-lto2 to avoid printing symbol table information
that is inappropriate for the target.

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

llvm-svn: 300300
2017-04-14 02:55:06 +00:00
Peter Collingbourne c0987938ea ELF: Remove some dead code.
llvm-svn: 300297
2017-04-14 02:34:32 +00:00
Rui Ueyama 3233d3eb46 Do not initialize this->SoName with this->DefaultSoName.
This patch uses DefaultSoName in getSoName instead of in parseSoName.
I think this is more readable. This patch also add comments.

llvm-svn: 300147
2017-04-13 00:23:32 +00:00
Evgeniy Stepanov a76349bffe [lld] Keep full library path in DT_NEEDED.
Fixes PR32572.

When
    (a) a library has no soname
and (b) library is given on the command line with path (and not through -L/-l flags)
DT_NEEDED entry for such library keeps the path as given.

This behavior is consistent with gold and bfd, and is used in compiler-rt test suite.

This is a second attempt after r300007 got reverted. This time relro-omagic test is
changed in a way to avoid hardcoding the path to the test directory in the objdump'd
binary.

llvm-svn: 300011
2017-04-12 00:13:48 +00:00
Evgeniy Stepanov d512afe3da Revert "[lld] Keep full library path in DT_NEEDED."
This reverts commit r300007. Reason: breaks all the bots.

llvm-svn: 300008
2017-04-12 00:01:21 +00:00
Evgeniy Stepanov 2c2dcae13c [lld] Keep full library path in DT_NEEDED.
Fixes PR32572.

When
    (a) a library has no soname
and (b) library is given on the command line with path (and not through -L/-l flags)
DT_NEEDED entry for such library keeps the path as given.

This behavior is consistent with gold and bfd, and is used in compiler-rt test suite.

llvm-svn: 300007
2017-04-11 23:46:58 +00:00
Rui Ueyama 4e4e8662bc Remove InputFiles::LogName.
LogName member was added to construct input file names for logging
only once. This patch does this in a different way. Now toString
caches its results.

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

llvm-svn: 299375
2017-04-03 19:11:23 +00:00
Peter Collingbourne 7b30f16c9f Re-apply r299168 and r299169 now that the libdeps are fixed.
llvm-svn: 299184
2017-03-31 04:47:07 +00:00
Peter Collingbourne f10698b940 Revert r299168 and r299169 due to library dependency issues.
http://bb.pgr.jp/builders/i686-mingw32-RA-on-linux/builds/25073/steps/build_llvmclang/logs/stdio

llvm-svn: 299171
2017-03-31 02:44:50 +00:00
Peter Collingbourne d9717aa0e4 LTO: Reduce memory consumption by creating an in-memory symbol table for InputFiles. NFCI.
Introduce symbol table data structures that can be potentially written to
disk, have the LTO library build those data structures using temporarily
constructed modules and redirect the LTO library implementation to go through
those data structures. This allows us to remove the LLVMContext and Modules
owned by InputFile.

With this change I measured a peak memory consumption decrease from 5.4GB to
2.8GB in a no-op incremental ThinLTO link of Chromium on Linux. The impact on
memory consumption is larger in COFF linkers where we are currently forced
to materialize all metadata in order to read linker options. Peak memory
consumption linking a large piece of Chromium for Windows with full LTO and
debug info decreases from >64GB (OOM) to 15GB.

Part of PR27551.

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

llvm-svn: 299168
2017-03-31 02:28:30 +00:00
Rui Ueyama 37e60a52f3 Include filenames in error messages to report broken files.
llvm-svn: 299115
2017-03-30 21:13:00 +00:00
Rui Ueyama b87602032a Change the error message format for undefined symbols.
Previously, undefined symbol errors are one line like this
and wasn't easy to read.

  /ssd/clang/bin/ld.lld: error: /ssd/llvm-project/lld/ELF/Writer.cpp:207: undefined symbol 'lld:🧝:EhFrameSection<llvm::object::ELFType<(llvm::support::endianness)0, true> >::addSection(lld:🧝:InputSectionBase*)'

This patch make it more structured like this.

  bin/ld.lld: error: undefined symbol: lld:🧝:EhFrameSection<llvm::object::ELFType<(llvm::support::endianness)0, true>
  >>> Referenced by Writer.cpp:207 (/ssd/llvm-project/lld/ELF/Writer.cpp:207)
  >>>               Writer.cpp.o in archive lib/liblldELF.a

Discussion thread:
http://lists.llvm.org/pipermail/llvm-dev/2017-March/111459.html

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

llvm-svn: 299097
2017-03-30 19:13:47 +00:00
Peter Collingbourne 0d56b959ad LTO: Replace InputFile::Symbol::getFlags() with predicate accessors. NFC.
This makes the predicates independent of the flag representation
and makes the code a little easier to read.

llvm-svn: 298951
2017-03-28 22:31:35 +00:00
George Rimar f56cadd3b3 [ELF] - Fix one more access to Sections member.
That finally should linux BB after r298345.

llvm-svn: 298349
2017-03-21 08:57:13 +00:00
George Rimar 3f7c3df6a4 [ELF] Follow-up to r298345 "[ELF] - Detemplate GdbIndexSection."
Fix for linux build bot:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/8144/steps/build/logs/stdio

llvm-svn: 298348
2017-03-21 08:44:25 +00:00
Rafael Espindola b57e496dfa Move OffsetInArchive to BitcodeFile.
It is the only file type that needs it.

llvm-svn: 298323
2017-03-20 23:47:06 +00:00
Rui Ueyama d57e74b7d3 Compute Config member function return values only once.
We had a few Config member functions that returns configuration values.
For example, we had is64() which returns true if the target is 64-bit.
The return values of these functions are constant and never change.

This patch is to compute them only once to make it clear that they'll
never change.

llvm-svn: 298168
2017-03-17 23:29:01 +00:00
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
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
Rafael Espindola 35ae65ee2b Rename one of the getOffset methods.
It is sufficiently different in that it returns an offset in the input
file, not the output section.

llvm-svn: 297290
2017-03-08 15:57:17 +00:00
Rafael Espindola bdd2e3e36c Remove redundant member of InputSectionBase. NFC.
With this InputSectionBase is now 144 bytes.

llvm-svn: 297278
2017-03-08 14:12:52 +00:00
Rafael Espindola 5c02b741eb Detemplate EhInputSection. NFC.
llvm-svn: 297077
2017-03-06 21:17:18 +00:00
Rafael Espindola 6119b865ec Detemplate merge (input and synthetic) sections. NFC.
llvm-svn: 297061
2017-03-06 20:23:56 +00:00
Rui Ueyama 175e81cf3a Use make<> instead of new (BAlloc). NFC.
We converted them before, but there were a few remaining occurrences.

llvm-svn: 296510
2017-02-28 19:36:30 +00:00
Rui Ueyama 80474a26b9 De-template DefinedRegular.
Differential Revision: https://reviews.llvm.org/D30348

llvm-svn: 296508
2017-02-28 19:29:55 +00:00
Sean Silva 1d96185f57 Add Triple::thumb to getBitcodeMachineKind
We really need to find a way to get this info from a single point of
truth in the LLVM backend, but it seems that the EM_* constants are
buried deep inside the constructors of the MCAsmBackend's.

For now, just fill in entries as we run into cases. AFAIK these mappings
are largely immutable, so we get a 75% discount on the technical debt
(code is duplicated, but little chance of divergence).

llvm-svn: 296429
2017-02-28 03:00:48 +00:00
Rui Ueyama 9cc84384ad Use uint64_t instead of uintX_t where the larger type just works.
llvm-svn: 296162
2017-02-24 19:52:52 +00:00
Rafael Espindola 774ea7d0a9 Make InputSection a class. NFC.
With the current design an InputSection is basically anything that
goes directly in a OutputSection. That includes plain input section
but also synthetic sections, so this should probably not be a
template.

llvm-svn: 295993
2017-02-23 16:49:07 +00:00
Rui Ueyama b7f39b08f4 Slightly improve an error message.
llvm-svn: 295942
2017-02-23 07:35:30 +00:00
Rui Ueyama c1a0ac2c4a Add a comment about .note.GNU-split-stack.
llvm-svn: 295941
2017-02-23 07:35:11 +00:00
Rui Ueyama 65efe35632 Update comment: .note.GNU-stack is added by default today.
llvm-svn: 295939
2017-02-23 07:15:46 +00:00
Rui Ueyama 0633273d05 Update a comment about .note.GNU-stack.
llvm-svn: 295938
2017-02-23 07:06:43 +00:00
Rui Ueyama 6e0142d78c Use isa<MergeInputSection> to check if a section is a merge section.
We have InputSection, MergeInputSection and EhInputSection, so
isa<MergeInputSection> is equivalent to !isa<InputSection> && !isa<
EhInputSection>.

llvm-svn: 295937
2017-02-23 06:47:18 +00:00
Rafael Espindola b4c9b81aad Convert InputSectionBase to a class.
Removing this template is not a big win by itself, but opens the way
for removing more templates.

llvm-svn: 295923
2017-02-23 02:28:28 +00:00