Commit Graph

2671 Commits

Author SHA1 Message Date
Rui Ueyama 6780cea628 Early return. NFC.
llvm-svn: 231403
2015-03-05 20:22:14 +00:00
Rui Ueyama e5bf769443 Resolver: Update preload map after File::beforeLink().
We maintain a map from symbols to archive files for the archive file
pre-loading. That map is created at the beginning of the resolve()
and is never updated. However, the input file list may be updated by
File::beforeLink(). This is a patch to update the map after beforeLink.

llvm-svn: 231395
2015-03-05 19:25:58 +00:00
Rui Ueyama 3ba3e7131e Remove dead code.
This hook is called from one of the hottest loops in LLD and does nothing.

llvm-svn: 231345
2015-03-05 02:58:13 +00:00
Rui Ueyama 97d8bec7ea Remove else if a last block ends with return.
llvm-svn: 231330
2015-03-05 01:02:20 +00:00
Rui Ueyama 4dfb0f0079 Remove redundant virtual destructor.
DefinedAtom, which is the base class of ELFCommonAtom, has a
virtual destructor, so this is redundant.

llvm-svn: 231329
2015-03-05 00:55:04 +00:00
Rui Ueyama 5d75b6346d Use range-based for loops to iterate over file nodes.
I converted them to non-range-based loops in r226883 and r226893
because at that moment File::parse() may have side effects and
may update the vector that the reference returned from
LinkingContext::nodes().

Now File::parse() is free from side effects. We can use range-based
loops again.

llvm-svn: 231321
2015-03-05 00:07:38 +00:00
Rui Ueyama 0eb0efbb63 PECOFF: Update comments on .drectve section encoding.
llvm-svn: 231316
2015-03-04 23:22:48 +00:00
Rui Ueyama 57c62e6ab9 PECOFF: Do not add layout-after edges.
The last use of layout-after edge for PE/COFF was removed in r231290.
Now layout-after edges do nothing. We can stop adding them to the graph.
No functionality change intended.

llvm-svn: 231301
2015-03-04 22:13:25 +00:00
Rui Ueyama 77a4da1991 Define DefinedAtom::sectionSize.
Merge::mergeByLargestSection is half-baked since it's defined
in terms of section size, there's no way to get the section size
of an atom.

Currently we work around the issue by traversing the layout edges
to both directions and calculate the sum of all atoms reachable.
I wrote that code but I knew it's hacky. It's even not guaranteed
to work. If you add layout edges before the core linking, it
miscalculates a size.

Also it's of course slow. It's basically a linked list traversal.

In this patch I added DefinedAtom::sectionSize so that we can use
that for mergeByLargestSection. I'm not very happy to add a new
field to DefinedAtom base class, but I think it's legitimate since
mergeByLargestSection is defined for section size, and the section
size is currently just missing.

http://reviews.llvm.org/D7966

llvm-svn: 231290
2015-03-04 21:40:46 +00:00
Rui Ueyama addf8ebd97 Remove "inline" from inlined functions.
llvm-svn: 231271
2015-03-04 18:51:19 +00:00
Rui Ueyama 394d10e34d Make File non-const in the resolver.
File objects are not really const in the resolver. We set ordinals to
them and call beforeLink hooks. Also, File's member functions marked
as const are not really const. ArchiveFile never returns the same
member file twice, so it remembers files returned before. find() has
side effects.

In order to deal with the inconsistencies, we sprinkled const_casts
and marked member varaibles as mutable.

This patch removes const from there to reflect the reality.

llvm-svn: 231212
2015-03-04 04:36:46 +00:00
Rui Ueyama cf8b003314 Revert "temporary"
This reverts accidental commit r231205.

llvm-svn: 231208
2015-03-04 02:12:55 +00:00
Rui Ueyama 5cc41029a2 Simplify FileArchive. NFC.
This patch moves local variable definitions so that their scope get narrower.
Also uses range-based loop. Both are for readability.

llvm-svn: 231206
2015-03-04 02:09:22 +00:00
Rui Ueyama f810b554ab temporary
llvm-svn: 231205
2015-03-04 02:09:21 +00:00
Rui Ueyama 302119effc Make a private function private.
llvm-svn: 231196
2015-03-04 01:26:32 +00:00
Rui Ueyama 791db5f0a3 Implement our own future and use that for FileArchive::preload().
std::promise and std::future in old version of libstdc++ are buggy.
I think that's the reason why LLD tests were flaky on Ubuntu 13
buildbots until we disabled file preloading.

In this patch, I implemented very simple future and used that in
FileArchive. Compared to std::promise and std::future, it lacks
many features, but should serve our purpose.

http://reviews.llvm.org/D8025

llvm-svn: 231153
2015-03-03 22:19:46 +00:00
Rui Ueyama 82ca5e72d2 Fix -Wcast-qual warning.
llvm-svn: 231139
2015-03-03 21:38:38 +00:00
Davide Italiano 7a89462158 [ELF] Implement R_X86_64_PC16 relocation.
Yet another chapter in the story. We're getting there, finally.
Note for the future: the tests for relocation have a lot of duplication
and probably can be unified in a single file. Let's reevaluate this once
the support will be complete (hopefully, soon).

llvm-svn: 231057
2015-03-03 07:38:20 +00:00
Rui Ueyama dbd7f2740c Make ArchiveLibraryFile::~ArchiveLibraryFile virtual.
"virtual" was present at a wrong place. FileArchive is a subclass of
ArchiveLibraryFile, and a FileArchive can be deleted through a
pointer of ArchiveLibraryFile. We want to make the destructor of the
base class virtual.

llvm-svn: 231033
2015-03-02 23:03:33 +00:00
Rui Ueyama 25b87a4b5b Remove include/lld/Core/Endian.h and use llvm/Support/Endian.h instead.
llvm-svn: 231005
2015-03-02 20:31:43 +00:00
Davide Italiano d333c36e8a Update the list of relocations that need to be implemented.
While at it, point the correct document where the missing TLS
relocation(s) are described.

llvm-svn: 230937
2015-03-02 06:17:38 +00:00
Benjamin Kramer 06a42af61e Add missing includes for make_unique, lld edition.
llvm-svn: 230925
2015-03-02 00:48:06 +00:00
Rui Ueyama 990bb16036 Revert "PECOFF: Don't parse files in .drectve asynchronously."
This reverts commit r228955. Previously files appear in a .drectve
section are parsed synchronously to avoid threading issues. I believe
it's now safe to do that asynchronously.

llvm-svn: 230905
2015-03-01 20:48:14 +00:00
Rui Ueyama 0c177051b7 Revert "PECOFF: Temporarily add a lock to un-break buildbot."
This reverts commit r230086. I added a lock to guard FileCOFF::doParse(),
which killed parallel file parsing. Now the buildbots got back to green,
I believe the threading issue was resolved, so it's time to remove the
guard to see if it works with the buildbots.

llvm-svn: 230886
2015-03-01 04:25:04 +00:00
Rui Ueyama b2e16973df Do s/_context/_ctx/ to Resolver.cpp.
llvm-svn: 230814
2015-02-27 23:40:00 +00:00
Rui Ueyama cb1c4d1a9a Remove a varaible that's used only once. NFC.
llvm-svn: 230813
2015-02-27 23:36:05 +00:00
Rui Ueyama c817fd2273 Call File::beforeLink hook even if the file is in an archive.
Previously we didn't call the hook on a file in an archive, which
let the PE/COFF port fail to link files in archives. It was a
simple mistake. Added a call to the hook and also added a test to
catch that error.

const_cast is an unfortunate hack. Files in the resolver are usually
const, but they are not actually const objects, since they are
mutated if either a file is taken from an archive (an archive file
does never return the same file twice) or the beforeLink hook is
called. Maybe we should just remove const from there -- because they
are not const.

llvm-svn: 230808
2015-02-27 23:15:11 +00:00
Rui Ueyama 400385c8be PECOFF: Move a call of WinLinkDriver::parse from FileCOFF::doParse to FileCOFF::beforeLink
In doParse, we shouldn't do anything that has side effects. That function may be
called speculatively and possibly in parallel.

We called WinLinkDriver::parse from doParse to parse a command line in a .drectve
section. The parse function updates a linking context object, so it has many side
effects. It was not safe to call that function from doParse. beforeLink is a
function for a File object to do something that has side effects. Moving a call
of WinLinkDriver::parse to there.

llvm-svn: 230791
2015-02-27 20:39:20 +00:00
Rui Ueyama 9f872a80c7 PECOFF: Use StringRef::find_first_of instead of a hand-written loop.
llvm-svn: 230770
2015-02-27 18:06:41 +00:00
Davide Italiano b65719ae78 [ELF] Set up initial live symbol(s) to avoid incorrect reclaim of atoms.
If no initial live symbols are set up, and deadStrip() == true,
the Resolver ends up reclaiming all the symbols that aren't absolute. This is wrong.
This patch fixes the issue by setting entrySymbolName() as live, and this allows
us to self-host lld when --gc-sections is enabled. There are still quite a few problems
with --gc-sections (test failures), so the option can't be enabled by default.

Differential Revision:	D7926
Reviewed by:	ruiu, shankarke

llvm-svn: 230737
2015-02-27 06:41:46 +00:00
Rui Ueyama 0bde1de3bd Temporarily disable FileArchive::preload().
It is observed that the function throws std::future_error on a few buildbots.
That cannot be easily reproducible on local machines. Kill the feature
temporarily to see if this is going to fix the buildbot issue.

llvm-svn: 230735
2015-02-27 05:26:05 +00:00
Rui Ueyama 6c39e77896 Partially revert "PECOFF: Do not add layout-after edges."
This reverts commit r230732.

sectionSize() in lib/Core/SymbolTable.cpp still depends on the layout-
after edges, so we couldn't remove them yet.

llvm-svn: 230734
2015-02-27 05:22:19 +00:00
Shankar Easwaran 93c7fa209c [ELF] Remove includes that are not used
This remove(s) include of the filename twice.

llvm-svn: 230733
2015-02-27 05:12:30 +00:00
Rui Ueyama 584abaee67 PECOFF: Do not add layout-after edges.
Previously we needed to create atoms as a doubly-linked link, but it's
no longer needed. Also we don't use layout-after edges in PE/COFF.
Creating such edges is just waste.

llvm-svn: 230732
2015-02-27 05:05:38 +00:00
Shankar Easwaran 60aa7985cc [CMake] Cleanup
llvm-svn: 230731
2015-02-27 04:39:16 +00:00
Rui Ueyama 41c8b56a2a Twine should be used within a statement.
llvm-svn: 230730
2015-02-27 04:23:23 +00:00
Rui Ueyama 5b3d935fce Update comments, fix typos.
llvm-svn: 230729
2015-02-27 04:23:21 +00:00
Rui Ueyama e088a0f989 Use read{le,be}{16,32}. NFC.
llvm-svn: 230728
2015-02-27 04:21:40 +00:00
Rui Ueyama 4a528dd5be Remove unused #includes.
llvm-svn: 230726
2015-02-27 03:23:52 +00:00
Rui Ueyama 7cea026a63 Add {read,write}{16,32,64}{le,be} functions.
Nothing wrong with reinterpret_cast<llvm::support::ulittle32_t *>(loc),
but that's redundant and not great from readability point of view.
The new functions are wrappers for that kind of reinterpet_casts.

Surprisingly or unsurprisingly, there was no use of big endian read
and write. {read,write}{16,32,64}be have no user. But I think they
still worth to be there in the header for completeness.

http://reviews.llvm.org/D7927

llvm-svn: 230725
2015-02-27 03:18:46 +00:00
Rui Ueyama 53a93c6c39 PECOFF: allow more than one /alternatename for the same symbol.
Previously we have a string -> string map to keep the weak alias
symbol mapping. Naturally we can't define more than one weak alias
with that data structure.

This patch is to allow multiple aliases for the same symbol by
changing the map type to string -> set of string map.

llvm-svn: 230702
2015-02-26 23:43:04 +00:00
Reid Kleckner 48e04e492f Give enum an unsigned type to silence -Wmicrosoft clang-cl warning
llvm-svn: 230687
2015-02-26 21:10:01 +00:00
Simon Atanasyan 82ae48eeb5 [Driver] Use paths explicitly provided by the -L option before default paths
User should be able to override default search paths using the -L
option.

http://reviews.llvm.org/D7902

llvm-svn: 230679
2015-02-26 20:09:50 +00:00
Simon Atanasyan 27967c843b [ELF] Reduce the code indentation
No functional changes.

llvm-svn: 230678
2015-02-26 20:09:42 +00:00
Simon Atanasyan 009c28a231 [Mips] Mark some MipsELFFile member functions as constant
No functional changes.

llvm-svn: 230677
2015-02-26 20:09:37 +00:00
Davide Italiano a82ae9146e [Core] Do not reclaim absolute atoms in resolver.
This fixes a linker crash (found out while testing --gc-sections,
testcase provided by Rafael Avila de Espindola).
While this behaviour was found while testing ELF, it' not necessarily
ELF specific and this change is (apparently) harmless on all the
other drivers.

Differential Revision:  D7823
Reviewed by:    ruiu

llvm-svn: 230614
2015-02-26 05:39:57 +00:00
Michael J. Spencer 09358d247a Add Example Sub Target.
llvm-svn: 230594
2015-02-26 00:48:10 +00:00
Michael J. Spencer 6a272cdc83 [ELF][x86-64] Make the X86_64LinkingContext and X86_64TargetHandler derivable.
llvm-svn: 230593
2015-02-26 00:47:34 +00:00
Michael J. Spencer 39c30439c1 Remove unused variables.
llvm-svn: 230578
2015-02-25 23:48:33 +00:00
Michael J. Spencer 751bb41be4 [ELF][x86] Detemplatify ELFT. There's only a single valid instantiation.
llvm-svn: 230574
2015-02-25 23:27:13 +00:00