Commit Graph

1722 Commits

Author SHA1 Message Date
Rui Ueyama 7088e3470c [ELF] Add a test for -rpath.
llvm-svn: 205663
2014-04-05 02:15:23 +00:00
Rui Ueyama ac0f7ca3a8 [ELF] Fix --soname option.
Currently LLD accepts only "-soname <string>", but all the following
options are actually valid.

  --soname=foo
  --soname foo
  -soname=foo
  -soname foo
  -h foo

This patch fixes that issue.

llvm-svn: 205662
2014-04-05 02:07:04 +00:00
Rui Ueyama e36fbea175 [ELF] Diagnose malformed --dynsym option.
llvm-svn: 205654
2014-04-04 22:36:30 +00:00
Michael J. Spencer ead3b1a544 [X86-64] Add missing relocation.
llvm-svn: 205645
2014-04-04 19:22:14 +00:00
Rui Ueyama 60ea496448 This is yet another case clang-modernize failed to add "override".
llvm-svn: 205644
2014-04-04 19:17:59 +00:00
Rui Ueyama 331f482cf6 Split a utility function not to use goto statement.
llvm-svn: 205643
2014-04-04 18:34:40 +00:00
Rui Ueyama e8af3e48fd useNew is set to false in all branches, so set it to false outside the if-else.
llvm-svn: 205642
2014-04-04 18:21:53 +00:00
Rui Ueyama 01cc718375 Replace dyn_cast<T>s immediately followed by asserts with cast<T>s.
llvm-svn: 205641
2014-04-04 18:21:51 +00:00
Rui Ueyama fb7936d07c Fix indentation.
llvm-svn: 205639
2014-04-04 18:12:27 +00:00
Rui Ueyama fbd6c44e6a Revert "temporary commit."
This reverts commit r205635 that was submitted by mistake.

llvm-svn: 205637
2014-04-04 18:06:56 +00:00
Rui Ueyama 770305804f temporary commit.
llvm-svn: 205635
2014-04-04 18:01:52 +00:00
Rui Ueyama 992fdc0785 SymbolTable::size() returns an unsigned int.
It's better to use the same type rather than a fixed width integer type
that may be different from the return type.

llvm-svn: 205597
2014-04-04 01:22:51 +00:00
Rui Ueyama 7cac0f784c Use range-based for loop. No functionality change.
llvm-svn: 205594
2014-04-04 00:59:50 +00:00
Rui Ueyama 0b8e053ebd Do not use temporary variables to pass them to forEachUndefines.
So that it's obvious that we pass these callbacks only to forEachUndefines.

llvm-svn: 205593
2014-04-04 00:39:37 +00:00
Rui Ueyama 8dc9f0a371 Return a vector rather than mutating a given one.
This is cleaner and as efficient as before.

Differential Revision: http://llvm-reviews.chandlerc.com/D3284

llvm-svn: 205590
2014-04-04 00:15:52 +00:00
Rui Ueyama 8bd093b1e5 Rename getInputGraph() and getNextFile().
Seems getSomething() is more common naming scheme than just a noun
to get something, so renaming these members.

Differential Revision: http://llvm-reviews.chandlerc.com/D3285

llvm-svn: 205589
2014-04-04 00:14:04 +00:00
Rui Ueyama 1c3486a312 Update comment.
llvm-svn: 205579
2014-04-03 22:58:41 +00:00
Rui Ueyama 71c0202dd0 Minor cleanups.
llvm-svn: 205578
2014-04-03 22:43:42 +00:00
Rui Ueyama 4f010d2f66 Replace a recursion with a loop for speed.
llvm-svn: 205576
2014-04-03 22:36:55 +00:00
Rui Ueyama 450d987e3a Do not check deadStripNever twice.
Atoms with deadStripNever attribute has already been added to the
dead strip root set at end of Resolver::doDefinedAtom, so no need
to check it for each atom again.

Differential Revision: http://llvm-reviews.chandlerc.com/D3282

llvm-svn: 205575
2014-04-03 22:24:40 +00:00
Rui Ueyama 70625fb163 Move code into a helper function.
Move code that always runs after doUndefinedAtom into doUndefinedAtom
for readability.

llvm-svn: 205574
2014-04-03 22:21:59 +00:00
Rui Ueyama 517f0d9b5f Minor cleanup.
llvm-svn: 205570
2014-04-03 21:16:37 +00:00
Rui Ueyama 83e6acc7f2 Simplify two if's.
llvm-svn: 205569
2014-04-03 21:11:22 +00:00
Rui Ueyama fb44f5e278 Fix comments.
llvm-svn: 205568
2014-04-03 21:06:23 +00:00
Rui Ueyama 6aa91cf13d Early return.
llvm-svn: 205567
2014-04-03 21:00:03 +00:00
Rui Ueyama 9457510abf Fix ELFFileNode::resetNextIndex().
ELFLinkingContext has a method addUndefinedAtomsFromSharedLibrary().
The method is being used to skip a shared library within --start-group
and --end-group if it's not the first iteration of the group.

We have the same, incomplete mechanism to skip a shared library within
a group too. That's implemented in ELFFileNode. It's intended to not
return a shared library on the second or further iterations in the
first place. This mechanism is preferred over
addUndefinedAtomsFromSharedLibrary because the policy is implemented
in Input Graph -- that's what Input Graph is for.

This patch removes the dupluicate feature and fixes ELFFileNode.

Differential Revision: http://llvm-reviews.chandlerc.com/D3280

llvm-svn: 205566
2014-04-03 20:54:47 +00:00
Rui Ueyama 69fcde8b0a Expand 'auto' that's hard for human to deduce its real type.
llvm-svn: 205564
2014-04-03 20:47:50 +00:00
Rui Ueyama 4469ce6c7b Add empty() to atom_collection.
"x.empty()" is more idiomatic than "x.size() == 0". This patch is to
add such method and use it in LLD.

Differential Revision: http://llvm-reviews.chandlerc.com/D3279

llvm-svn: 205558
2014-04-03 19:51:14 +00:00
Rui Ueyama e8fa7c079e Remove "virtual" and add "override".
Seems clang-modernize couldn't add "override" to nested classes, so
doing it by hand. Also removed unused virtual member function that
is not overriding anything, that seems to have been added by mistake.

llvm-svn: 205552
2014-04-03 18:25:36 +00:00
Rui Ueyama 2b2ac91fab Remove "this->".
For most member function calls we do not use "this->" in this file.
Remove the rest for consistency.

llvm-svn: 205550
2014-04-03 18:13:14 +00:00
Rui Ueyama 27754f10f5 Add comment for Linker Script node.
llvm-svn: 205510
2014-04-03 04:10:52 +00:00
Rui Ueyama b0e3b66fa5 Remove ordinals from Input Graph elements.
An ordinal is set to each child of Input Graph, but no one actually
uses it. The only piece of code that gets ordinaly values is
sortInputElements in InputGraph.cpp, but it does not actually do
anything -- we assign ordinals in increasing order just before
calling sort, so when sort is called it's already sorted. It's no-op.
We can simply remove it. No functionality change.

Differential Revision: http://llvm-reviews.chandlerc.com/D3270

llvm-svn: 205501
2014-04-03 02:21:44 +00:00
Rui Ueyama f819851b65 Fix style.
llvm-svn: 205490
2014-04-03 00:01:57 +00:00
Rui Ueyama 519a45ce36 Minor style fix.
llvm-svn: 205486
2014-04-02 23:17:39 +00:00
Rui Ueyama 63d3a54980 Concatenate strings that are unnecessarily separated.
llvm-svn: 205475
2014-04-02 22:32:51 +00:00
Rui Ueyama 7c62b1e2df Minor cleanup.
llvm-svn: 205470
2014-04-02 21:57:29 +00:00
Rui Ueyama 88c8599de9 Remove unused fields/member functions from unit test.
llvm-svn: 205469
2014-04-02 21:49:27 +00:00
Rui Ueyama d33a3d8892 Remove unused include.
llvm-svn: 205466
2014-04-02 21:39:44 +00:00
Rui Ueyama edd5c0a9ea Simplify communication between Resolver and Input Graph.
Resolver is sending too much information to Input Graph than Input
Graph actually needs. In order to collect the detailed information,
which wouldn't be consumed by anyone, we have a good amount of code
in Resolver, Input Graph and Input Elements. This patch is to
simplify it. No functionality change.

Specifically, this patch replaces ResolverState enum with a boolean
value. The enum defines many bits to notify the progress about
linking to Input Graph using bit masks, however, what Input Graph
actually does is to compare a given value with 0. The details of
the bit mask is simply being ignored, so the efforts to collect
such data is wasted.

This patch also changes the name of the notification interface from
setResolverState to notifyProgress, to make it sounds more like
message passing style. It's not a setter but something to notify of
an update, so the new name should be more appropriate than before.

Differential Revision: http://llvm-reviews.chandlerc.com/D3267

llvm-svn: 205463
2014-04-02 21:02:44 +00:00
Rui Ueyama 0f58c7cc3a Remove dead code.
llvm-svn: 205454
2014-04-02 19:42:35 +00:00
Rui Ueyama 601073287f Remove a function that's not defined.
llvm-svn: 205406
2014-04-02 06:59:28 +00:00
Rui Ueyama b461b1c785 s/llvm::dyn_cast/dyn_cast/
llvm-svn: 205404
2014-04-02 06:54:46 +00:00
Rui Ueyama 0ca88e3863 Use cast<T> instead of dyn_cast<T>.
llvm-svn: 205403
2014-04-02 06:54:43 +00:00
Rui Ueyama cd1d4193b3 Remove unused variables.
llvm-svn: 205402
2014-04-02 06:43:08 +00:00
Rui Ueyama 43a589cc82 Remove dead code.
llvm-svn: 205401
2014-04-02 06:38:46 +00:00
Rui Ueyama 9b1877f704 Devirtualize Resolver.
No one inherits Resolver. Virtualizing the member functions was just
making it inefficient.

llvm-svn: 205399
2014-04-02 06:18:12 +00:00
Rui Ueyama 1ecad2c993 Remove dead code.
llvm-svn: 205397
2014-04-02 05:57:19 +00:00
Shankar Easwaran bef1f22aaa [TODO] revisit features TODO in the driver
llvm-svn: 205395
2014-04-02 05:45:52 +00:00
Rui Ueyama eb4b54349d Move nextFile() from LinkingContext to InputGraph.
LinkingContext and InputGraph are unnecessarily entangled. Most linker
input file data, e.g. the vector containing input files, the next index
of the input file, etc. are managed by InputGraph, but only the current
input file is for no obvious reason managed by LinkingContext.

This patch is to move code from LinkingContext to InputGraph to fix it.
It's now clear who's reponsible for managing input file state, which is
InputGraph, and LinkingContext is now free from that responsibility.
It improves the readability as we now have fewer dependencies between
classes. No functionality change.

Differential Revision: http://llvm-reviews.chandlerc.com/D3259

llvm-svn: 205394
2014-04-02 05:03:40 +00:00
Shankar Easwaran 086f8a6ef5 [ELF] Create Attribute class associated with Input files.
The attribute class holds positional attributes for Input files specified on the
command line for the Gnu flavor.

llvm-svn: 205392
2014-04-02 03:57:39 +00:00
Shankar Easwaran a00abba152 [ELF] Add -z muldefs option.
This adds -z muldefs option which is widely used over
--allow-multiple-definition.

This option is supported by the GNU linker.

llvm-svn: 205391
2014-04-02 03:57:37 +00:00
Rui Ueyama 92e4846a7b Remove unused function.
llvm-svn: 205388
2014-04-02 02:57:39 +00:00
Rui Ueyama 0045b90e75 Fix indentation.
llvm-svn: 205384
2014-04-02 01:49:44 +00:00
Rui Ueyama 273ae7e089 Remove unused function.
llvm-svn: 205383
2014-04-02 01:47:38 +00:00
Rui Ueyama 60ede621ef De-virtualize InputGraph's member functions.
There's no class derived from InputGraph. Making member functions virtual
just makes it a bit inefficient.

llvm-svn: 205377
2014-04-02 00:14:33 +00:00
Rui Ueyama 5b8be49fed Remove unused enum Position::ANY and third parameter of insertElementAt().
insertElementAt()'s third parameter is not only unused but also ignored
if you pass Position::END. The actual meaning of the parameter was obscure.

Differential Revision: http://llvm-reviews.chandlerc.com/D3256

llvm-svn: 205376
2014-04-01 23:58:17 +00:00
Rui Ueyama 2243015825 Merge ELFGroup with Group.
Group class is designed for GNU LD's --start-group and --end-group. There's
no obvious need to have two classes for it -- one as an abstract base class
and the other as a concrete class.

llvm-svn: 205375
2014-04-01 23:55:20 +00:00
Rui Ueyama ce749af25b Rename insertOneElementAt -> insertElementAt.
insertElementsAt() is removed, so "One" in insertOneElementAt() no longer
make much sense. Rename it for brevity.

llvm-svn: 205372
2014-04-01 23:17:28 +00:00
Rui Ueyama 804b1b9965 Remove duplicate code in unit tests carried in from main code.
llvm-svn: 205371
2014-04-01 23:10:14 +00:00
Rui Ueyama 04afaeff52 Simplify InputGraphTest.
llvm-svn: 205369
2014-04-01 22:42:38 +00:00
Rui Ueyama 26eb6c5bc2 Inline empty constructor.
llvm-svn: 205366
2014-04-01 22:11:18 +00:00
Rui Ueyama 5632e26d36 Greatly simplify InputGraph.
InputGraph has too many knobs and controls that are not being used. This
patch is to remove dead code, unused features and a class. There are two
things that worth noting, besides simple dead code removal:

1. ControlNode class is removed. We had it as the base class of Group
class, but it provides no functionality particularly meaningful. We now
have shallower class hierarchy that is easier to understand.

2. InputGraph provides a feature to replace a node with its internal data.
It is being used to "expand" some type of node, such as a Linker Script
node, with its actual files. We used to have two options when replacing
it -- ExpandOnly or ExpandAndReplace. ExpandOnly was to expand it but not
remove the node from the tree. There is no use of that option in the code,
so it was a dead feature.

Differential Revision: http://llvm-reviews.chandlerc.com/D3252

llvm-svn: 205363
2014-04-01 21:55:36 +00:00
Rui Ueyama 068fc01234 Remove dynamic casts.
Asserting with cast<T> did not actually make much sense because there was no
need to use dynamic casting in the first place. We could make the compiler to
statically type check these objects.

llvm-svn: 205350
2014-04-01 19:00:21 +00:00
Rui Ueyama 46fd56d0df s/dyn_cast/cast/ where return value should never be null.
cast<X> asserts the type is correct and does not return null on failure.
So we should use cast<X> rather than dyn_cast<X> at such places where we
don't expect type conversion could fail.

llvm-svn: 205332
2014-04-01 18:04:56 +00:00
Rui Ueyama e081e22036 [PECOFF] Make PECOFFFileNode::parse idempotent.
PECOFFFileNode::parse can be called twice -- once by WinLink driver and
once more by Driver. We want to make sure that the second call won't mess
up the internal data.

llvm-svn: 205284
2014-04-01 06:18:19 +00:00
Rui Ueyama 1e7d0721ae [PECOFF] Treat .imp as an import library file.
Some Clang build uses .imp not .lib file extension for an import library file,
so we need to treat such file as a library file.

Ideally we should not rely on file extensions to detect file type. Instead
we should use magic bytes at beginning of a file. The GNU-compatible driver
actually does that but it made writing unit tests hard, so I chose an ad-hoc
approach for now.

llvm-svn: 205283
2014-04-01 06:11:09 +00:00
Shankar Easwaran 9316c40a1b [core] support .gnu.linkonce sections
.gnu.linkonce sections are similar to section groups.

They were supported before section groups existed and provided a way
to resolve COMDAT sections using a different design.

There are few implementations that use .gnu.linkonce sections
to store simple floating point constants which doesnot require complex section
group support but need a way to store only one copy of the floating point
constant in a binary.

.gnu.linkonce based symbol resolution achieves that.

Review : http://llvm-reviews.chandlerc.com/D3242

llvm-svn: 205280
2014-04-01 03:49:55 +00:00
Rafael Espindola c0d21793be Check-in binary to isolate the lld test form a changing llvm-mc.
llvm-svn: 205238
2014-03-31 18:56:30 +00:00
Shankar Easwaran 50136f1f4e Revert "[core] support .gnu.linkonce sections"
This reverts commit 5d5ca72a7876c3dd3dd1db83dc6a0d74be9e2cd1.

Discuss on a better design to raise error when there is a similar group with Gnu
linkonce sections and COMDAT sections.

llvm-svn: 205224
2014-03-31 17:12:06 +00:00
Shankar Easwaran 79cfed55fc [core] support .gnu.linkonce sections
.gnu.linkonce sections are similar to section groups. They were supported before
section groups existed and provided a way to resolve COMDAT sections using a
different design. There are few implementations that use .gnu.linkonce sections
to store simple floating point constants which doesnot require complex section
group support but need a way to store only one copy of the floating point
constant. .gnu.linkonce based symbol resolution achieves that.

llvm-svn: 205163
2014-03-31 03:16:37 +00:00
Rafael Espindola e2bab04b85 Forgot to replace a %t1 in the previous commit.
llvm-svn: 205078
2014-03-29 06:45:26 +00:00
Rafael Espindola 90eeff28c6 Check in binaries to avoid dependency on broken llvm-mc behavior.
On these tests llvm-mc will convert got relocations with a symbol to section
relocations. This is invalid, since the relocation doesn't reference the symbol
itself, so its offset in a section in irrelevant.

Given the object files, these are still valid lld tests, so just run the
tests directly on the binaries.

Found by running check-lld after fixing the relocation handling in llvm-mc.

llvm-svn: 205077
2014-03-29 06:26:51 +00:00
Rui Ueyama bc69bce7de [MachO] Remove "virtual" and add "override".
llvm-svn: 205057
2014-03-28 21:36:33 +00:00
Rui Ueyama 9d0698e0f2 [ELF] Add "override" and remove "virtual".
llvm-svn: 205056
2014-03-28 21:26:13 +00:00
Rui Ueyama aa6c9285f4 [ELF] Terminate argv with nullptr.
Also remove unused vector.

llvm-svn: 205052
2014-03-28 20:51:07 +00:00
Rui Ueyama 6d010e8d42 [ELF] Support response file.
Response file is a command line argument in the form of @file. The GNU-
compatible driver expands the file contents, replacing @file argument.

Differential Revision: http://llvm-reviews.chandlerc.com/D3210

llvm-svn: 205038
2014-03-28 19:34:34 +00:00
Rui Ueyama a674f60dfd Attempt to unbreak buildbots.
llvm-svn: 205034
2014-03-28 19:23:13 +00:00
Rui Ueyama 3907f2a802 [ELF] Support --defsym option to define an absolute symbol.
This patch is to support --defsym option for ELF file format/GNU-compatible
driver. Currently it takes a symbol name followed by '=' and a number. If such
option is given, the driver sets up an absolute symbol with the specified
address. You can specify multiple --defsym options to define multiple symbols.

GNU LD's --defsym provides many more features. For example, it allows users to
specify another symbol name instead of a number to define a symbol alias, or it
even allows a symbol plus an offset (e.g. --defsym=foo+3) to define symbol-
relative alias. This patch does not support that, but will be supported in
subsequent patches.

Differential Revision: http://llvm-reviews.chandlerc.com/D3208

llvm-svn: 205029
2014-03-28 19:02:06 +00:00
Rui Ueyama a9a5129ec1 [ELF] Add --allow-multiple-definition option.
If --allow-multiple-definition option is given, LLD does not treat duplicate
symbol error as a fatal error. GNU LD supports this option.

Differential Revision: http://llvm-reviews.chandlerc.com/D3211

llvm-svn: 205015
2014-03-28 16:26:38 +00:00
Rui Ueyama ba539d8dc8 Fix format.
llvm-svn: 204989
2014-03-28 05:17:59 +00:00
Rui Ueyama 8ec57b51d9 [ELF] Remove class declarations that do nothing.
These classes are declared in a .cpp file but not used in the same compliation
unit. They seems to have been copy-and-pasted from ELFReader.h.

llvm-svn: 204988
2014-03-28 05:03:35 +00:00
Rui Ueyama 49f91b346c Replace nested switches with if.
llvm-svn: 204987
2014-03-28 03:29:01 +00:00
Rui Ueyama 14a1e0c0fc Remove extraneous parentheses.
llvm-svn: 204986
2014-03-28 03:26:24 +00:00
Rui Ueyama 200fce4208 Fix typo.
llvm-svn: 204984
2014-03-28 00:59:43 +00:00
Rui Ueyama 9024c36f5a Make anonymous namespace as small as possible.
llvm-svn: 204982
2014-03-27 23:34:32 +00:00
Rui Ueyama e93efaa0e1 Add a comment on kindLayoutBefore.
llvm-svn: 204970
2014-03-27 22:19:14 +00:00
Rui Ueyama 88d8f52b81 Spelling corrections.
llvm-svn: 204967
2014-03-27 22:11:58 +00:00
Rui Ueyama 8be4ce254a Do not use layout-before to layout atoms.
Currently we use both layout-after and layout-before edges to specify atom
orders in the resulting executable. We have a complex piece of code in
LayoutPass.cpp to deal with both types of layout specifiers.

(In the following description, I denote "Atom A having a layout-after edge
to B" as "A -> B", and A's layout-before to B as "A => B".)

However, that complexity is not really needed for this reason: If there
are atoms such that A => B, B -> A is always satisifed, so using only layout-
after relationships will yield the same result as the current code.

Actually we have a piece of complex code that verifies that, for each A -> B,
B => [ X => Y => ... => Z => ] A is satsified, where X, Y, ... Z are all
zero-size atoms. We can get rid of the code from our codebase because layout-
before is basically redundant.

I think we can simplify the code for layout-after even more than this, but
I want to just remove this pass for now for simplicity.

Layout-before edges are still there for dead-stripping, so this change won't
break it. We will remove layout-before in a followup patch once we fix the
dead-stripping pass.

Differential Revision: http://llvm-reviews.chandlerc.com/D3164

llvm-svn: 204966
2014-03-27 22:08:26 +00:00
Rui Ueyama 69a6f0e79a [PECOFF] Avoid C-style cast.
llvm-svn: 204855
2014-03-26 21:10:40 +00:00
Rui Ueyama 9e8ac37d89 [PECOFF] Use RAII object for mutex.
llvm-svn: 204853
2014-03-26 21:08:17 +00:00
Rui Ueyama 664afe94a6 [PECOFF] Use std::mutex.
Use <mutex> instead of "llvm/Support/Mutex.h".

Also change the type of mutex for the context object to recursive mutex, as
the driver could acquire the lock recursively. E.g. If file A has .drectve
section containing /defaultlib:B, the driver tries to parse file B, and if
file B has .drectve section, the driver acquires the lock again.

llvm-svn: 204850
2014-03-26 20:20:53 +00:00
Shankar Easwaran 7ac2a3df64 [core] add SectionGroup support
Review : http://llvm-reviews.chandlerc.com/D3182

llvm-svn: 204830
2014-03-26 16:37:13 +00:00
Michael J. Spencer 876bee8155 [lit] Environment variables get stripped in lit. Manually specify locale.
llvm-svn: 204774
2014-03-26 01:19:07 +00:00
Michael J. Spencer a4f983e258 [lit] Python 3.
llvm-svn: 204773
2014-03-26 00:53:48 +00:00
Rui Ueyama ad386648b8 Remove safeguard from RoundTripYAML pass.
RoundTripYAML pass is removed from the regular execution pass in r204296,
so the safeguard to protect it from OOM error is no longer needed, because
we are sure that the pass is only used for tests, and test files are all
small.

We also want to see RoundTripYAML pass to fail in tests if it fails,
rather than silently skipping failing tests.

llvm-svn: 204772
2014-03-26 00:21:11 +00:00
Rui Ueyama 85093df3bd [PECOFF] Print out command line if we have expanded response files.
If a response file is given via command line, the final command line
arguments will not appear in the log because the actual arguments are
in the given file.

This patch is to show the final command line if /verbose is specified
to help users.

llvm-svn: 204754
2014-03-25 20:40:27 +00:00
Simon Atanasyan e3df81f3ab [Mips] Fix formatting.
llvm-svn: 204607
2014-03-24 14:12:37 +00:00
Simon Atanasyan 1ebfb22638 [Mips] Sort R_MIPS_LO16 / R_MIPS_HI16 / R_MIPS_GOT16 before finding
pairs and calculate AHL addend.

llvm-svn: 204606
2014-03-24 14:09:17 +00:00
Rafael Espindola 016d69d29f Update for llvm change.
llvm-svn: 204585
2014-03-24 05:00:40 +00:00
Simon Atanasyan 6690854109 [Mips] Make the test to be a bit more relaxed to lld YAML output.
llvm-svn: 204541
2014-03-22 06:20:38 +00:00
Rui Ueyama c9411c3357 Use early continues to reduce nesting.
llvm-svn: 204523
2014-03-21 21:46:49 +00:00
Rui Ueyama 83ba74fa3f [PECOFF] Rename link.exe -> lld-link.exe.
Creating the file "link.exe" made some confusion, so it's better to
name it lld-link.exe, as we did for CL (clang-cl.exe).

llvm-svn: 204509
2014-03-21 20:41:48 +00:00
Simon Atanasyan b752d6e18b [Mips] Emit LA25 MIPS stubs to call pic code from non-pic routines.
llvm-svn: 204503
2014-03-21 19:08:02 +00:00
Simon Atanasyan 13985964f4 [Mips] Fix source code formatting. No functional changes.
llvm-svn: 204472
2014-03-21 15:29:07 +00:00
Rui Ueyama b4c358fab8 [PECOFF] Fix possible response file buffer overrun.
Response file is not NUL terminated, so when creating a StringRef for
the buffer contents, we need to pass the buffer size as well as the
pointer pointing to the buffer.

llvm-svn: 204420
2014-03-21 00:48:26 +00:00
Simon Atanasyan 134a8a6311 [Mips] Reduce the number of 'const' casts.
llvm-svn: 204355
2014-03-20 16:26:25 +00:00
Simon Atanasyan df0d62a7cb [Mips] Join two for loops over defined atoms into the single one.
llvm-svn: 204354
2014-03-20 16:26:15 +00:00
Simon Atanasyan 7b571f4ee0 [Mips] Remove the dead code.
llvm-svn: 204353
2014-03-20 16:26:07 +00:00
Simon Atanasyan c452d4f89f [Mips] Remove unused member function argument.
llvm-svn: 204352
2014-03-20 16:25:58 +00:00
Rui Ueyama 6d500da3cc Revert "[ELF] Order DT_NEEDED entries by command line order."
This reverts commit r204291 because it broke buildbots.

llvm-svn: 204317
2014-03-20 06:57:28 +00:00
Rui Ueyama bc6b52e68e Move RoundTrip tests behind LLVM_RUN_ROUNDTRIP_TEST env flag.
If the environment variable is defined and not empty, RoundTrip tests
are run. The reason to move the tests behind the flag is because they
are too slow to enable by default.

LLD linking time on llvm-tblgen improved from 2m7s to 2.3s. About 60x
faster now in this case.

Differential Revision: http://llvm-reviews.chandlerc.com/D3126

llvm-svn: 204296
2014-03-20 02:49:33 +00:00
Michael J. Spencer 05c152b5d1 [gnu-ld] Support -m on non-NetBSD targets.
llvm-svn: 204293
2014-03-20 01:28:36 +00:00
Michael J. Spencer deefb10fd6 [ELF] Order DT_NEEDED entries by command line order.
With this all test-suite tests pass with lld on x86-64 Linux.

llvm-svn: 204291
2014-03-20 01:28:23 +00:00
Rui Ueyama 5f56e9d6cb [PECOFF] Fix parallel read bug.
InputElement::parse() may recursively call WinLinkDriver::parse() to handle
.drectve section contents, and if /defaultlib option exists in the section,
the driver will mutate the input graph to add a new input file to the graph.
So the access to input graph needs to be protected with mutext.

llvm-svn: 204285
2014-03-20 00:06:04 +00:00
Simon Atanasyan 4c5316d0b0 [Mips] Make the test temporary file names self-explanatory.
llvm-svn: 204259
2014-03-19 19:45:59 +00:00
Simon Atanasyan 6210b2ef6b [Mips] Remove unused function.
llvm-svn: 204248
2014-03-19 16:05:32 +00:00
Simon Atanasyan e29132d427 [Mips] Fix handling of R_MIPS_GOT16 relocation and building local part
of GOT.
 * Read addend for R_MIPS_GOT16 relocation.
 * Put only high 16 bits of symbol + addend into GOT entries for
   locally visible symbols.

llvm-svn: 204247
2014-03-19 15:46:25 +00:00
Simon Atanasyan b1ba018ed2 [Mips] Handle R_MIPS_GOT16 relocation for external and local symbols in
a uniform way.

llvm-svn: 204246
2014-03-19 15:46:15 +00:00
Simon Atanasyan 49fa6a41f4 [Mips] Factor out the code creates GOT entry atoms into the two
functions. The first one is for local GOT entries. The second one is for
global GOT entries.

llvm-svn: 204245
2014-03-19 15:46:07 +00:00
Simon Atanasyan a7b553efd1 [Mips] Add 'const' qualifier to the function.
llvm-svn: 204244
2014-03-19 15:46:00 +00:00
Simon Atanasyan c1b62ea310 [Mips] Move AHL addends calculation to the RelocationPass class.
llvm-svn: 204243
2014-03-19 15:45:55 +00:00
Simon Atanasyan d8259fbcc3 [Mips] Move RelocationPass class member function definitions out of the
class.

llvm-svn: 204242
2014-03-19 15:45:49 +00:00
Simon Atanasyan e7e8b26f93 Remove extra semicolon for -Wpedantic.
llvm-svn: 204224
2014-03-19 11:06:07 +00:00
Simon Atanasyan 0edb4bbb4b [PECOFF] Fix -Wsign-compare warning.
llvm-svn: 204223
2014-03-19 11:06:01 +00:00
Simon Atanasyan 0e202224a3 [ELF] Remove unused fields (linking context references).
llvm-svn: 204222
2014-03-19 11:05:55 +00:00
Simon Atanasyan b665ce2c27 Fix warning 'enumeral and non-enumeral type in conditional expression'.
llvm-svn: 204221
2014-03-19 11:05:47 +00:00
Alexey Samsonov 8e6829e436 Remove extra semicolon for -Wpedantic
llvm-svn: 204219
2014-03-19 09:38:31 +00:00
David Majnemer 14b11022b4 [PECOFF] Use richer ways of describing auxiliary symbols
Update all of the unit tests to use the new format.

This depends on D3092.

Reviewers: ruiu

Differential Revision: http://llvm-reviews.chandlerc.com/D3093

llvm-svn: 204215
2014-03-19 04:55:14 +00:00
Rui Ueyama 7ad72ebc5e [PECOFF] Support yet another new type of weak symbol.
COMDAT_SELECT_LARGEST is a COMDAT type that make linker to choose the largest
definition from among all of the definition of a symbol. If the size is the
same, the choice is arbitrary.

Differential Revision: http://llvm-reviews.chandlerc.com/D3011

llvm-svn: 204172
2014-03-18 19:37:50 +00:00
Alexey Samsonov 67dc3e9538 Fix lld build
llvm-svn: 204122
2014-03-18 07:24:10 +00:00
Rui Ueyama a7236598bb [PECOFF] Data type of SectionNumber is now unsigned (r203986).
So we don't need static_cast's to convert it from signed to unsigned.

llvm-svn: 203992
2014-03-15 00:39:12 +00:00
Rui Ueyama 39aa6af23f Remove redundant "virtual" keyword.
llvm-svn: 203903
2014-03-14 07:10:43 +00:00
Rui Ueyama 74af50134b [PECOFF] Handle large objects having more than 32768 sections.
The COFF spec says that the SectionNumber field in the symbol table is 16 bit
signed type, but MSVC treats the field as if it is unsigned.

llvm-svn: 203901
2014-03-14 07:04:01 +00:00
Rui Ueyama aca3c7c6f4 [PECOFF] Fix link order.
LLD fails to link symbol "_main" if the symbol is in a library file and
the library file is given as a bare argument (i.e. not with /defaultlib
option). It's because library files given as bare arguments are processed
before other libraries given with /defaultlib, so when Linker finds msvcrtd
needs a definition for "_main", the file providing the main function has
already been processed and skipped. Linker don't revisit libraries if it's
not given with /defaultlib.

To fix it this patch change the way of command line handling; files end with
".lib" are treated as if they are given with /defaultlib. I don't believe
it's 100% correct behavior but it's better than before.

llvm-svn: 203892
2014-03-14 05:59:16 +00:00
Rui Ueyama ebffa9b4be [PECOFF] Fix arguments passed to lib.exe.
llvm-svn: 203891
2014-03-14 05:04:08 +00:00
Rui Ueyama 516273ba99 [PECOFF] Make WinLinkDriver::parse() and allocate*() functions thread-safe.
Looks like a major cause of instability on Windows is this thread-safety bug.

llvm-svn: 203889
2014-03-14 04:28:38 +00:00
Rui Ueyama f88731f293 [PECOFF] Implement /lib option.
This option is not documented and seems weird, but yeah we need it anyway.

llvm-svn: 203884
2014-03-14 03:06:55 +00:00
Rui Ueyama f020bf7468 [PECOFF] Add one more test for r203875.
This is to make sure that the Windows-style command line tokenizer is
working as expected.

llvm-svn: 203877
2014-03-14 00:44:17 +00:00
Rui Ueyama 7d96f0cc38 Use short identifier, s/diagnostics/diag/.
llvm-svn: 203876
2014-03-14 00:38:34 +00:00
Rui Ueyama b3f679e1ab [PECOFF] Support response files.
If the driver finds a command line option in the form of "@filename", the
option will be replaced with the content of the given file. It's an error
if a response file cannot be read.

llvm-svn: 203875
2014-03-14 00:36:30 +00:00
Ahmed Charles 13c70b6d4b Replace OwningPtr with std::unique_ptr.
This results in some simplifications to the code where an OwningPtr had to
be used with the previous api and then ownership moved to a unique_ptr for
the rest of lld.

llvm-svn: 203809
2014-03-13 16:20:38 +00:00
Rui Ueyama 6ab29444b0 [docs][Windows] Document how to build using Ninja.
llvm-svn: 203756
2014-03-13 05:48:46 +00:00
Rui Ueyama 60b1a6d9e4 Fix Windows build.
llvm-svn: 203753
2014-03-13 05:22:23 +00:00
Rui Ueyama c83b4eb3a1 [PECOFF] Handle objects with unknown machine type header value.
An object whose machine type header value is unknown looks a bit odd but
is valid. If an object contains only machine-type-independent data, you
can leave the type field unspecified. Some files in oldname.lib are such
object files.

llvm-svn: 203752
2014-03-13 05:12:36 +00:00
Rui Ueyama f7ada499f1 [Driver] Create "link[.exe]" symlink for the Windows driver.
Clang creates "clang-cl" as a symlink to (or a copy of) "clang" for the MSVC-
compatible driver. This patch is to do the same thing for "link" and "lld".

Differential Revision: http://llvm-reviews.chandlerc.com/D3066

llvm-svn: 203751
2014-03-13 05:12:31 +00:00
Michael J. Spencer ac1b1d7bfc [docs] Add some more information on missing relocations.
llvm-svn: 203744
2014-03-13 01:11:03 +00:00
Rui Ueyama 21f97ddb58 [docs] Document how to build LLD as a win64 app.
llvm-svn: 203736
2014-03-12 23:40:18 +00:00
Rui Ueyama b325b81138 [ELF] Fix MSVC warning on conversion from enum to bool.
This function returns a boolean value, so returning STT_COMMON does not
make sense.

llvm-svn: 203731
2014-03-12 23:04:27 +00:00
Ahmed Charles d6432c8aed [Cleanup] Sort includes.
llvm-svn: 203666
2014-03-12 15:55:13 +00:00
Rui Ueyama dcd25e31a7 [docs] Add a note on how to build LLD on Windows.
llvm-svn: 203613
2014-03-11 22:40:43 +00:00