Commit Graph

177 Commits

Author SHA1 Message Date
Davide Italiano 9f8efffe29 [LTO] Create Undefined Bitcode symbol when we drop a comdat member.
Differential Revision:  http://reviews.llvm.org/D19389

llvm-svn: 267181
2016-04-22 18:26:33 +00:00
Rafael Espindola 197d6a882f This reverts commit r267154 and r267161.
It turns out that this will read data from the section to properly
handle Elf_Rel implicit addends.

Sorry for the noise.

Original messages:

Try to fix Windows lld build.

Move getRelocTarget to ObjectFile.
It doesn't use anything from the InputSection.

llvm-svn: 267163
2016-04-22 16:39:59 +00:00
Rafael Espindola ea4d177977 Move getRelocTarget to ObjectFile.
It doesn't use anything from the InputSection.

llvm-svn: 267154
2016-04-22 14:17:14 +00:00
Rafael Espindola 4d480ed545 Internalize linkonce_odr more often.
Since there is a copy in every translation unit that uses them, they can
be omitted from the symbol table if the address is not significant.

This still doesn't catch as many cases as the gold plugin. The
difference is that we check canBeOmittedFromSymbolTable in each file and
use lazy loading which limits what it can do. Gold checks it in the merged file.

I think the correct way of getting the same results as gold is just to
cache in the IR the result of canBeOmittedFromSymbolTable.

llvm-svn: 267063
2016-04-21 21:44:25 +00:00
Peter Collingbourne 7cf73ec4c7 ELF: Implement basic support for module asm in bitcode files.
Differential Revision: http://reviews.llvm.org/D18872

llvm-svn: 265956
2016-04-11 16:39:43 +00:00
Rui Ueyama 029d89ee57 Fix another crash bug in --start-lib.
The previous fix didn't work for bitcode files. This patch fixes
the remaining issue.

llvm-svn: 265854
2016-04-08 21:38:22 +00:00
Rui Ueyama 1f492893ac Fix a crash bug in --start-lib.
Previously, Lazy symbols were created for undefined symbols even though
such symbols cannot be resolved by loading object files. This patch
fixes that bug.

llvm-svn: 265847
2016-04-08 20:49:31 +00:00
Rui Ueyama 57bbdaf937 Simplify createELFFile. NFC.
llvm-svn: 265758
2016-04-08 00:18:25 +00:00
Rui Ueyama 4655ea3ff8 Define a helper function to simplify. NFC.
llvm-svn: 265757
2016-04-08 00:14:55 +00:00
Rui Ueyama fc6a4b045f ELF: Add --strip-debug option.
If --strip-debug option is given, then all sections whose names start
with ".debug" are removed from output.

llvm-svn: 265722
2016-04-07 21:04:51 +00:00
Rui Ueyama f8baa66056 ELF: Implement --start-lib and --end-lib
start-lib and end-lib are options to link object files in the same
semantics as archive files. If an object is in start-lib and end-lib,
the object is linked only when the file is needed to resolve
undefined symbols. That means, if an object is in start-lib and end-lib,
it behaves as if it were in an archive file.

In this patch, I introduced a new notion, LazyObjectFile. That is
analogous to Archive file type, but that works for a single object
file instead of for an archive file.

http://reviews.llvm.org/D18814

llvm-svn: 265710
2016-04-07 19:24:51 +00:00
Rafael Espindola f47657301b Change the type hierarchy for undefined symbols.
We have to differentiate undefined symbols from bitcode and undefined
symbols from other sources.

Undefined symbols from bitcode should not inhibit the symbol being
internalized. Undefined symbols from other sources should.

llvm-svn: 265536
2016-04-06 13:22:41 +00:00
Rui Ueyama ec6aee0927 Do not allocate MipsReginfo using BumpPtrAllocator.
So that MipsReginfo's destructor will be called.

llvm-svn: 265512
2016-04-06 02:52:47 +00:00
Ivan Krasin bfc9131454 Fix a memory leak found by check-lld asan tests.
Summary:
This bug was introduced by http://reviews.llvm.org/rL265059,
where InputSectionBase got Thunks field, which can do memory allocations.
Since InputSectionBase destructors were never called (I count it as another bug),
that caused a memory leak when 2 or more thunks are added to a section.

The fix to is properly call InputSectionBase destructors from ~ObjectFile.

Reviewers: atanasyan, ruiu, rafael

Subscribers: rafael, krasin, pcc

Differential Revision: http://reviews.llvm.org/D18809

llvm-svn: 265497
2016-04-06 01:11:10 +00:00
Rui Ueyama 376ab7cc7b Fix formatting.
llvm-svn: 265424
2016-04-05 17:47:29 +00:00
Rafael Espindola 0f7ccc3d92 Update for llvm change.
llvm-svn: 265404
2016-04-05 14:47:28 +00:00
Rafael Espindola d9a1717efc Remove redundant argument. NFC.
llvm-svn: 265386
2016-04-05 11:47:46 +00:00
Rafael Espindola c64119a9bf Regenerate test file.
It had been created with a lld version that was producing an invalid
sh_info.

llvm-svn: 265305
2016-04-04 16:02:39 +00:00
Rafael Espindola ccfe3cb3d6 Don't store an Elf_Sym for most symbols.
Our symbol representation was redundant, and some times would get out of
sync. It had an Elf_Sym, but some fields were copied to SymbolBody.

Different parts of the code were checking the bits in SymbolBody and
others were checking Elf_Sym.

There are two general approaches to fix this:
* Copy the required information and don't store and Elf_Sym.
* Don't copy the information and always use the Elf_Smy.

The second way sounds tempting, but has a big problem: we would have to
template SymbolBody. I started doing it, but it requires templeting
*everything* and creates a bit chicken and egg problem at the driver
where we have to find ELFT before we can create an ArchiveFile for
example.

As much as possible I compared the test differences with what gold and
bfd produce to make sure they are still valid. In most cases we are just
adding hidden visibility to a local symbol, which is harmless.

In most tests this is a small speedup. The only slowdown was scylla
(1.006X). The largest speedup was clang with no --build-id, -O3 or
--gc-sections (i.e.: focus on the relocations): 1.019X.

llvm-svn: 265293
2016-04-04 14:04:16 +00:00
Rafael Espindola 0d2ad420df Revert "[ELF] SHF_MERGE section with 0 entsize is not fatal"
This reverts commit r263664.

The reason we were getting broken files was lld -r, and that has been
fixed.

llvm-svn: 263944
2016-03-21 14:57:20 +00:00
Ed Maste b321050a93 [ELF] SHF_MERGE section with 0 entsize is not fatal
For now just treat such sections as non-mergeable.

Resubmit r263660 with test fix.

Differential Revision:     http://reviews.llvm.org/D18225

llvm-svn: 263664
2016-03-16 21:12:53 +00:00
Ed Maste b30ce583df Revert r263660 as one of the tests is broken.
llvm-svn: 263661
2016-03-16 20:42:27 +00:00
Ed Maste 2e97115a61 [ELF] SHF_MERGE section with 0 entsize is not fatal
For now just treat such sections as non-mergeable.

Differential Revision:	http://reviews.llvm.org/D18222

llvm-svn: 263660
2016-03-16 20:32:32 +00:00
Rui Ueyama 9328b2cdde Use ELFT instead of ELFFile<ELFT>.
llvm-svn: 263510
2016-03-14 23:16:09 +00:00
Rui Ueyama 64bd8df458 Error messages should start with lowercase letters.
llvm-svn: 263496
2016-03-14 21:31:07 +00:00
Rui Ueyama 368e1eaa51 Remove uint32_X type.
This type is equivalent to Elf_Word type.

llvm-svn: 263397
2016-03-13 22:02:04 +00:00
Rui Ueyama e270c0a19a ELF: Split initializeSections and add comments.
llvm-svn: 263395
2016-03-13 21:52:57 +00:00
George Rimar 777f96304e Recommit of r263252, [ELF] - Change all messages to lowercase to be consistent.
which was reverted because included
unrelative changes by mistake.

Original commit message:

[ELF] - Change all messages to lowercase to be consistent.

That is directly opposite to http://reviews.llvm.org/D18045,
which was reverted.

This patch changes all messages to start from lowercase letter if
they were not before.

That is done to be consistent with clang.

Differential revision: http://reviews.llvm.org/D18085

llvm-svn: 263337
2016-03-12 08:31:34 +00:00
Rui Ueyama f714955402 Revert r263252: "[ELF] - Change all messages to lowercase to be consistent."
This reverts commit r263252 because the change contained unrelated changes.

llvm-svn: 263272
2016-03-11 18:46:51 +00:00
George Rimar 96bcdae1a5 [ELF] - Change all messages to lowercase to be consistent.
That is directly opposite to http://reviews.llvm.org/D18045,
which was reverted.

This patch changes all messages to start from lowercase letter if
they were not before.

That is done to be consistent with clang.

Differential revision: http://reviews.llvm.org/D18085

llvm-svn: 263252
2016-03-11 16:40:55 +00:00
Rafael Espindola 9b3acf9098 Avoid calling getNamedValue.
In lld we usually avoid hash lookups. In addition to that, IR names are
not fully mangled, so it is best to avoid using them whenever possible.

llvm-svn: 263248
2016-03-11 16:11:47 +00:00
George Rimar 5761042db7 This reverts the r263125
It was discussed to make all messages be 
lowercase to be consistent with clang.
(also reverts the r263128 which fixed 
build bot fail after r263125)

Original commit message:
[ELF] - Consistent spelling for error/warning messages

Previously error and warnings were not consistent in lld.
Some of them started from lowercase letter, others from
uppercase. Also there was one or two which had a dot at the end.
This patch changes all messages to start from uppercase letter if
they were not before.

Differential revision: http://reviews.llvm.org/D18045

llvm-svn: 263240
2016-03-11 14:43:02 +00:00
Rafael Espindola 1f5b70f64f Represent local symbols with DefinedRegular.
llvm-svn: 263237
2016-03-11 14:21:37 +00:00
Rafael Espindola ccb8b4d4fe Remember the input section of locals.
This is already a simplification, but will allow much more.

llvm-svn: 263224
2016-03-11 12:14:02 +00:00
Rafael Espindola 67d72c02bc Create a SymbolBody for locals.
pr26878 shows a case where locals have to be in the got.

llvm-svn: 263222
2016-03-11 12:06:30 +00:00
Sean Silva 905d349c47 Fix indentation.
Somehow this slipped by in r263197. Thanks to Rui for noticing.

llvm-svn: 263198
2016-03-11 05:48:04 +00:00
Sean Silva 4a0ff22d51 [lto] The previous testcase was not useful enough.
-shared was hiding the fact that the intrinsic wasn't being found.

llvm-svn: 263197
2016-03-11 05:42:34 +00:00
Sean Silva b1b5cc83f1 [lto] Make sure that ctors are added to the combined module.
Summary:
More generally, appending linkage is a special case that we don't want
to create a SymbolBody for.

Reviewers: rafael, ruiu

Subscribers: Bigcheese, llvm-commits, joker.eph

Differential Revision: http://reviews.llvm.org/D18012

llvm-svn: 263179
2016-03-11 00:50:05 +00:00
George Rimar e094388861 [ELF] - Consistent spelling for error/warning messages
Previously error and warnings were not consistent in lld.
Some of them started from lowercase letter, others from
uppercase. Also there was one or two which had a dot at the end.
This patch changes all messages to start from uppercase letter if
they were not before.

Differential revision: http://reviews.llvm.org/D18045

llvm-svn: 263125
2016-03-10 16:58:34 +00:00
George Rimar 599d77246d Fixed "not all control paths return a value" warning. NFC.
llvm-svn: 263040
2016-03-09 18:05:34 +00:00
George Rimar 3c45ed2f5e [ELF] - Issue an error if trying to link object that uses splitstacks.
Each object file compiled in split stack mode will have an empty
section with a special name: .note.GNU-split-stack

We don't support this in linker now, so patch just adds an error out for that.

Differential revision: http://reviews.llvm.org/D17918

llvm-svn: 263039
2016-03-09 18:01:45 +00:00
Rafael Espindola 972b236c30 Simplify: SHN_ABS is >= SHN_LORESERVE.
llvm-svn: 263012
2016-03-09 14:31:18 +00:00
Sean Silva 7255d0b068 [lto] Avoid duplicate symbol error for appending linkage.
Summary:
Is there any other code needed for correctly handling appending linkage?
Do we need to do something more with @llvm.global_ctors in
SymbolTable.cpp:addBitcodeFile; otherwise the combined bitcode module
won't have all the global ctors.

Reviewers: rafael

Subscribers: Bigcheese, llvm-commits, joker.eph

Differential Revision: http://reviews.llvm.org/D17975

llvm-svn: 262992
2016-03-09 03:42:39 +00:00
Sean Silva 3dbf9a31b5 Avoid unnecessary qualification.
Thanks to Rui for spotting this.

llvm-svn: 262983
2016-03-09 02:02:26 +00:00
Sean Silva 31a5ab9e3b [lto] Record whether a variable is TLS.
Summary:

Reviewers: rafael

Subscribers: Bigcheese, llvm-commits, joker.eph

Differential Revision: http://reviews.llvm.org/D17974

llvm-svn: 262975
2016-03-09 00:47:47 +00:00
Rafael Espindola 708453d99f Assume GV is not null for now.
It will come back when we add support for inline asm in .bc files.

llvm-svn: 262972
2016-03-09 00:31:06 +00:00
Sean Silva b284e71e03 [lto] Don't add variables with private linkage to the symbol table.
Summary:
This causes the issue in PR26872 to go away now that we aren't creating
symbols for the string literals, but that may just be concealing a
deeper problem, so best to keep that PR open.

Reviewers: rafael

Subscribers: Bigcheese, llvm-commits, joker.eph

Differential Revision: http://reviews.llvm.org/D17971

llvm-svn: 262968
2016-03-08 23:50:56 +00:00
Rafael Espindola 37bcaac179 Add support for common symbols.
llvm-svn: 262848
2016-03-07 19:15:57 +00:00
Rui Ueyama 68fae23475 Do not use "default" for a fully-covered switch.
llvm-svn: 262846
2016-03-07 19:06:14 +00:00
Rafael Espindola 4f29c1a337 lto: Record visibility in defined symbols.
llvm-svn: 262835
2016-03-07 17:14:36 +00:00