Commit Graph

1722 Commits

Author SHA1 Message Date
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
Michael J. Spencer e1de2a39df [docs] Add list of missing GNU ld command line options.
llvm-svn: 203491
2014-03-10 21:25:43 +00:00
Simon Atanasyan fe3e0a2abf [Mips] Fix addendum reading for R_MIPS_26 relocation.
llvm-svn: 203412
2014-03-09 13:20:01 +00:00
Simon Atanasyan c146325b26 [Mips] Fix addendum reading for R_MIPS_32 relocation.
llvm-svn: 203411
2014-03-09 13:19:54 +00:00
Simon Atanasyan 0f96aca940 [Mips] Fix addendum reading for R_MIPS_HI16 / R_MIPS_LO16 relocations.
llvm-svn: 203410
2014-03-09 13:19:46 +00:00
Simon Atanasyan cfffe940a8 [Mips] Create ELF object reader for MIPS target.
llvm-svn: 203409
2014-03-09 13:19:36 +00:00
Simon Atanasyan 3af8664858 [ELF] Factor out the code creates a Reference for the specified symbol
and relocation entry into the two virtual functions.

llvm-svn: 203408
2014-03-09 13:19:29 +00:00
Simon Atanasyan 305c864756 [Mips] Rename R_MIPS_26 relocation handling test case.
llvm-svn: 203407
2014-03-09 13:05:39 +00:00
Simon Atanasyan 6928b38c99 [Mips] Remove redundant 'mips' prefix from names of MipsELFWriter class
fields.

llvm-svn: 203406
2014-03-09 13:05:33 +00:00
Simon Atanasyan 8d8e340c61 [Mips] Reduce the code indentation.
llvm-svn: 203405
2014-03-09 13:05:26 +00:00
Simon Atanasyan 82381f97b9 [Mips] Change unused return type from 'bool' to 'void'.
llvm-svn: 203404
2014-03-09 13:05:20 +00:00
Simon Atanasyan 0784422520 [Mips] Remove unnecessary LLVM_ATTRIBUTE_UNUSED attribute.
llvm-svn: 203403
2014-03-09 13:05:15 +00:00
Simon Atanasyan 6af34b9661 [Mips] Do not inherit MipsDynamicLibraryWriter and MipsExecutableWriter
from MipsELFWriter class. MipsELFWriter is just a helper.

llvm-svn: 203402
2014-03-09 13:05:09 +00:00
Simon Atanasyan 16c425e985 [Mips] Mark class by 'final' keyword.
llvm-svn: 203401
2014-03-09 13:05:03 +00:00
Simon Atanasyan 8801c45110 [Mips] Remove redundant 'mips' prefix from names of MipsTargetHandler
and MipsDynamicSymbolTable classes fields.

llvm-svn: 203400
2014-03-09 13:04:56 +00:00
Simon Atanasyan 4881a93b73 [Mips] Remove redundant call to the unique_ptr::get() method followed
by the returned pointer dereferencing.

llvm-svn: 203399
2014-03-09 13:04:50 +00:00
Simon Atanasyan f08deab395 [Mips] Remove unused class field.
llvm-svn: 203398
2014-03-09 13:04:45 +00:00
Rui Ueyama 0b87794f2b Remove extra space.
llvm-svn: 203331
2014-03-08 01:45:39 +00:00
Rui Ueyama 2348be8b6d Add one more test for r203308.
llvm-svn: 203328
2014-03-08 01:27:22 +00:00
Rui Ueyama 7caea31189 Fix a bug that mergeCases table does not match the merge constants.
MergeCases table should not have an entry for MergeContents because atoms with
MergeContents attribute should never have name. This issue was not caught by a
test because getting a value of 6th element of an array of array actually gets
the first element's value of the next array, and that happened to be a valid
value. Added asserts to catch that error.

llvm-svn: 203322
2014-03-08 00:44:01 +00:00
Michael J. Spencer 95a90099fa [docs] Add missing features for the x86-64 ELF backend.
llvm-svn: 203313
2014-03-07 23:54:27 +00:00
Rui Ueyama c79dd2f80a [PECOFF] Support a new type of weak symbol.
Summary:
COMDAT_SELECT_SAME_SIZE is a COMDAT type that I presume exist only in COFF.
The semantics of the type is that linker should merge such COMDAT sections if
their sizes are the same. Otherwise it's an error.

Reviewers: Bigcheese, shankarke, kledzik

CC: llvm-commits

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

llvm-svn: 203308
2014-03-07 23:05:10 +00:00
Benjamin Kramer 68f8699031 Add missing std:: qualifiers.
llvm-svn: 203244
2014-03-07 14:50:15 +00:00
Simon Atanasyan e9ba661696 [Mips] Removed extra space. Thanks to dexonsmith's eagle eye.
llvm-svn: 203201
2014-03-07 04:50:53 +00:00
Michael J. Spencer dae078f341 [docs] Option parsing driver work is pretty much done.
llvm-svn: 203189
2014-03-07 01:42:35 +00:00
Michael J. Spencer 1dd276672f [docs] Update current status.
llvm-svn: 203188
2014-03-07 01:42:19 +00:00
Rui Ueyama 16e543bc02 Add "override" and remove "virtual" where appropriate.
For the record, I used clang-modernize to add "override" and perl to remove
"virtual".

llvm-svn: 203164
2014-03-06 21:14:04 +00:00
Simon Atanasyan 54f6f7bd77 [Mips] Replace "virtual" by "override" in member function declarations
where it is appropriate.

llvm-svn: 203102
2014-03-06 10:29:45 +00:00
Rui Ueyama 3e37326166 Add a document about Windows support.
llvm-svn: 203017
2014-03-05 22:35:32 +00:00
Rui Ueyama b63570ecb6 Fix broken link.
llvm-svn: 203004
2014-03-05 20:39:57 +00:00
Rui Ueyama 746c915c9d Visual Studio 11 = VS2012
llvm-svn: 203003
2014-03-05 20:36:07 +00:00
Rui Ueyama d6ad741e5e Add "override" to member functions where appropriate.
llvm-svn: 202998
2014-03-05 19:50:03 +00:00
Rui Ueyama 182437e63f [PECOFF] Sort x64 exception handler table.
Just like x86 exception handler table, the table for x64 needs to be sorted
so that runtime can binary search on it. Unlike x86, the table entry for x64
has multiple fields, and they need to be sorted according to its BeginAddress
field. This patch also fixes a bug in relocations.

llvm-svn: 202874
2014-03-04 18:39:12 +00:00
Ahmed Charles d779459f21 [C++11] Add #include's for OwningPtr.
Allows removing #include's in LLVM while switching to std::unique_ptr.

llvm-svn: 202679
2014-03-03 07:20:05 +00:00
Benjamin Kramer 3445d9edad [C++11] Work around an incompatibility between llvm::tie and std::tie.
llvm-svn: 202645
2014-03-02 13:45:18 +00:00
Chandler Carruth d40922989a Fix a typo spotted by Anton.
llvm-svn: 202638
2014-03-02 13:00:23 +00:00
Chandler Carruth 5de228b287 [C++11] Replace LLVM_OVERRIDE with just "override" now that we're all
using MSVC 2012 or newer.

llvm-svn: 202627
2014-03-02 09:39:44 +00:00
Chandler Carruth 6eface7c9d [C++11] Switch from LLVM_FINAL to just "final" now that all of LLVM is
requiring MSVC 2012 or newer.

llvm-svn: 202626
2014-03-02 09:35:33 +00:00
Chandler Carruth 03b4e3a8cb [C++11] Update LLD documentation to just refer to the LLVM documentation
for C++11 issues.

llvm-svn: 202623
2014-03-02 09:17:09 +00:00
Chandler Carruth 620b89017e [C++1y] Don't error if the user is enabling C++1y, which is *newer* than
C++11. I'm not sure that this is a good idea, but I know some crazy
folks on the core working group who like to live dangerously, and they
should still be able to build LLD. =D

llvm-svn: 202568
2014-03-01 03:18:56 +00:00
Rui Ueyama 5522e81f12 [PECOFF] Sort SEH table entries according to its value.
It looks like the contents of the table need to be sorted according to its
value, so that the runtime can find the entry by binary search. I'm not 100%
sure if we really have to do that, but at least I can say it's safe to do
because the contents of .sxdata is just a list of exception handlers' RVAs.

llvm-svn: 202550
2014-02-28 22:17:53 +00:00
Rui Ueyama b85f31c7a2 [PECOFF] Set "Exception Table" field in PE32+ header.
llvm-svn: 202527
2014-02-28 18:25:09 +00:00
Shankar Easwaran 8353f965c4 [Hexagon] Rename the header file.
This is to accomodate future changes for newer revisions of the DSP.

No change in functionality.

llvm-svn: 202350
2014-02-27 06:28:49 +00:00
Rui Ueyama 1710fe7de9 [PECOFF] Add a test for /SAFESEH:NO for non-x86 machine type.
llvm-svn: 202322
2014-02-27 00:05:43 +00:00
Rui Ueyama cfa657795d [PECOFF] Add a test for /SAFESEH:NO.
llvm-svn: 202314
2014-02-26 23:15:41 +00:00
Simon Atanasyan 930ea1892f [Mips] Remove non-ASCII symbol from the comment.
llvm-svn: 202290
2014-02-26 19:23:52 +00:00
Simon Atanasyan 46ff3ce2bd [Mips] Split reloc26 function into two parts - for processing local and
external relocations.

llvm-svn: 202289
2014-02-26 19:17:20 +00:00
Simon Atanasyan 2043ee167c [Mips] Use a correct number of bits when apply result of calculated relocation.
llvm-svn: 202288
2014-02-26 19:17:14 +00:00
Simon Atanasyan a444eae5ce [Mips] Exit from the class method as soon as possible.
llvm-svn: 202287
2014-02-26 19:17:07 +00:00
Rui Ueyama 2e09d93f74 [PECOFF] Emit Load Configuration and SEH Table for x86.
If all input files are compatible with Structured Exception Handling, linker
is supposed to create an exectuable with a table for SEH handlers. The table
consists of exception handlers entry point addresses.

The basic idea of SEH in x86 Microsoft ABI is to list all valid entry points
of exception handlers in an read-only memory, so that an attacker cannot
override the addresses in it. In x86 ABI, data for exception handling is mostly
on stack, so it's volnerable to stack overflow attack. In order to protect
against it, Windows runtime uses the table to check a return address, to
ensure that the address is really an valid entry point for an exception handler.

Compiler emits a list of exception handler functions to .sxdata section. It
also emits a marker symbol "@feat.00" to indicate that the object is compatible
with SEH. SEH is a relatively new feature for COFF, and mixing SEH-compatible
and SEH-incompatible objects will result in an invalid executable, so is the
marker.

If all input files are compatible with SEH, LLD emits a SEH table. SEH table
needs to be pointed by Load Configuration strucutre, so when emitting a SEH
table LLD emits it too. The address of a Load Configuration will be stored to
the file header.

llvm-svn: 202248
2014-02-26 08:27:59 +00:00
NAKAMURA Takumi 955d27a4ce [CMake] Use target_link_libraries(INTERFACE|PRIVATE) on CMake-2.8.12 to increase opportunity for parallel build.
target_link_libraries(INTERFACE) doesn't bring inter-target dependencies in add_library,
although final targets have dependencies to whole dependent libraries.
It makes most libraries can be built in parallel.

target_link_libraries(PRIVATE) is used to shaared library.
Each dependent library is linked to the target.so, and its user will not see its grandchildren.
For example,

  - libclang.so has sufficient libclang*.a(s).
  - c-index-test requires just only libclang.so.

FIXME: lld is tweaked minimally. Adding INTERFACE in each library would be better thing.
llvm-svn: 202241
2014-02-26 06:53:16 +00:00
NAKAMURA Takumi 9cd9ad6b9d [CMake] Introduce cmake_policy(CMP0022) for target_link_libraries(INTERFACE|PRIVATE).
For now, use both keywords, INTERFACE and PRIVATE via the variable,
  - ${cmake_2_8_12_INTERFACE}
  - ${cmake_2_8_12_PRIVATE}

They could be cleaned up when we introduce 2.8.12.

llvm-svn: 202239
2014-02-26 06:45:11 +00:00
NAKAMURA Takumi 9f4ee24ac6 lldReaderWriter: move LLVM_LINK_COMPONENTS. It seems Subdirectories don't depend on LLVMObject.
Please give LLVMObject explicitly in each subdirectory if any of subdirectories required it.

llvm-svn: 202236
2014-02-26 06:28:09 +00:00
NAKAMURA Takumi 23850261c6 [CMake] Declare cmake_minimum_required() unconditionally.
llvm-svn: 202235
2014-02-26 06:27:59 +00:00
Rui Ueyama aaf2816d59 [PECOFF] Add a utility function to add DIR32 relocation.
llvm-svn: 202217
2014-02-26 02:38:40 +00:00
Rui Ueyama f9be75f538 [PECOFF] Fix DLLCharacteristics field.
IMAGE_DLL_CHARACTERISTICS_NO_SEH flag should be set only when SEH is disabled.

llvm-svn: 202215
2014-02-26 02:31:53 +00:00
Shankar Easwaran a328344367 [LinkerScript] parse OUTPUT_FORMAT : treat quotedStrings as identifier
llvm-svn: 202166
2014-02-25 17:02:54 +00:00
Rui Ueyama d08472f6c3 [COFF] Refactor .drectve section handling. No functionality change.
llvm-svn: 202113
2014-02-25 05:37:47 +00:00
Shankar Easwaran 2ea5148eff [LinkerScript] OUTPUT_FORMAT: Parse Quoted Strings
llvm-svn: 202111
2014-02-25 05:17:24 +00:00
Shankar Easwaran 7a0818dd4a [test] use llvm-config to drive testing in assert mode/debug mode
llvm-svn: 202101
2014-02-25 02:29:17 +00:00
Shankar Easwaran 822ea4f9a3 [LinkerScript] parse OUTPUT_ARCH.
llvm-svn: 202100
2014-02-25 01:55:13 +00:00
Nico Rieck b9d84f4d14 [lld] Include reference kind in cycle detector debug output
This restores the debug output to how it was before r197727 broke it. This
went undetected because the corresponding test was never run due to broken
feature detection.

llvm-svn: 202079
2014-02-24 21:14:37 +00:00
Nico Rieck 78f2b48e7d Fix feature detection in lld's lit.cfg
llvm-svn: 202078
2014-02-24 21:13:53 +00:00
Rafael Espindola f27f9fa136 Update for LLVM api change.
llvm-svn: 202054
2014-02-24 18:20:36 +00:00
Rafael Espindola 27810169cb Don't assume that F_None is the default. It is about to change.
llvm-svn: 202039
2014-02-24 15:06:34 +00:00
Nico Rieck aa675e9379 [PECOFF] Fix uninitialized variable
llvm-svn: 201970
2014-02-23 10:40:15 +00:00
NAKAMURA Takumi b31e03007a [CMake] add_lld_library: link_system_libs is not needed any more. LLVMSupport may provide dependencies to system libs.
llvm-svn: 201967
2014-02-23 04:43:45 +00:00
Rui Ueyama a5dc335574 [PECOFF] Implement /SAFESEH option.
LLD now prints an error message if /SAFESEH option is specified and one or
more input files are not compatible with SEH.

llvm-svn: 201900
2014-02-21 22:50:27 +00:00
Rui Ueyama d9e7c22ee4 [PECOFF] Driver support for /SAFESEH option.
Syntactically /SAFESEH is a boolean flag -- you can pass /SAFESEH or /SAFESEH:no.

The meaning of /SAFESEH is as follows.

 - If /SAFESEH is specified, the linker will produce an executable with SEH table.
   If any input files are not compatible with SEH, it's an error.
 - If /SAFESEH:no is specified, the linker will not emit SEH table even if all
   input files are compatible with SEH.
 - If no option is specified, the linker emits SEH table if all input files are
   compatible with SEH.

llvm-svn: 201895
2014-02-21 22:30:43 +00:00
Shankar Easwaran 9578442fe9 [ELF] Dont generate PHDR when creating dynamic libraries.
llvm-svn: 201741
2014-02-19 23:46:13 +00:00
Shankar Easwaran babba413f5 [ELF] Fix alignment for dynamic relocation sections.
The sections .rela/.rel.(*) have a alignment of 2 in the final image created by
the linker. This needs to be properly set to the right alignment depending on
the architecture(32/64bits).

llvm-svn: 201740
2014-02-19 23:46:08 +00:00
Simon Atanasyan b72ea717d0 [Mips] Use the 'CHECK-NEXT' where we need to check a test output exactly
line by line.

llvm-svn: 201133
2014-02-11 07:17:09 +00:00
Simon Atanasyan 06f8ea4c07 [Mips] Simplify the code. Replace redundant 'switch' operator by the single 'if' one.
llvm-svn: 201131
2014-02-11 06:36:16 +00:00
Simon Atanasyan bf987c2dae [Mips] Handle R_MIPS_COPY relocation.
llvm-svn: 201129
2014-02-11 05:34:02 +00:00
Simon Atanasyan ceb0b86822 [Mips] Add "data" symbols to the test input file. No functional changes.
llvm-svn: 201128
2014-02-11 05:33:53 +00:00
Rafael Espindola 20d93679c7 Update for llvm api change.
llvm-svn: 201109
2014-02-10 20:24:27 +00:00
Nick Kledzik cdf2c8be58 [mach-o] use new way to copy StringRefs
llvm-svn: 200956
2014-02-06 23:48:52 +00:00
Simon Atanasyan 0743a72caa Accept and handle absolute symbols with empty name.
llvm-svn: 200911
2014-02-06 07:35:16 +00:00
Simon Atanasyan b828ebb5dd [Mips] In case of executable file linking MIPS ABI requires to add even
undefined symbols to '.dynsym' if these symbols have corresponding entries
in a global part of GOT.

llvm-svn: 200716
2014-02-03 20:10:40 +00:00
Simon Atanasyan 0912fe06dc [Mips] Unify #include guard names.
llvm-svn: 200715
2014-02-03 20:10:30 +00:00
Rui Ueyama 153ee54008 Untabify.
llvm-svn: 200712
2014-02-03 19:07:38 +00:00
Shankar Easwaran 6e0e1bc859 [ELF] change LayoutBefore Reference to InGroup Reference
This makes it a lot easier for Section Group design.

llvm-svn: 200675
2014-02-03 04:01:14 +00:00
Joey Gouly cf466800b7 [MachO] Add undefined atoms.
llvm-svn: 200649
2014-02-02 19:34:55 +00:00
Simon Atanasyan e6f6f06c91 [ELF] Customize dynamic table tag used for .got.plt section referencing.
The patch reviewed by Shankar Easwaran and Rui Ueyama.

llvm-svn: 200630
2014-02-02 12:19:29 +00:00
Simon Atanasyan 8379ad056d [Mips] Cleanup assembler code in the test.
llvm-svn: 200629
2014-02-02 12:19:20 +00:00
Rui Ueyama c5326ca9bb [PECOFF] Add a TODO.
llvm-svn: 200599
2014-02-01 00:26:33 +00:00
Rui Ueyama 9661bcf2e1 [PECOFF] Handle /machine option before handling all the other options.
The target machine type affects the meaning of other options, in particular
how to mangle symbols. So we want to handle the option first and then parse
all the other options.

llvm-svn: 200589
2014-01-31 22:58:19 +00:00
Rafael Espindola 8c13e51764 Update for llvm api change.
llvm-svn: 200575
2014-01-31 21:13:59 +00:00
Rui Ueyama d0d01c66ba MSVC2012 does not choose to use uint64_t as underlying type without this.
MSVC2012 seems to choose int as the underlying type for an enum even if one of
its member is unsigned long long.

llvm-svn: 200519
2014-01-31 06:28:32 +00:00
Rui Ueyama 14876abb3d [PECOFF] Set the correct PE header field value.
The charcateristics field should not have IMAGE_FILE_32BIT_MACHINE bit but have
IMAGE_FILE_LARGE_ADDRESS_AWARE bit for PE32+.

llvm-svn: 200518
2014-01-31 05:43:12 +00:00
Rui Ueyama ebc13c47f2 [PECOFF] Do not emit a section if it's empty.
The PE32+ loader does not seem to like an executable with an empty section, so
we should not emit a section if it's empty.

llvm-svn: 200514
2014-01-31 05:15:42 +00:00
Rui Ueyama 8851d45cbf Replace magic numbers with enums.
llvm-svn: 200512
2014-01-31 04:57:03 +00:00
Rui Ueyama ea7e9306c1 [PECOFF] Default image base address for PE32+ is 0x140000000, not 0x400000.
llvm-svn: 200511
2014-01-31 04:49:13 +00:00
Simon Atanasyan bc286a4dbc [ELF] Make private all DynamicTable class fields which are not used in
the descendant classes.

llvm-svn: 200467
2014-01-30 14:20:22 +00:00
Rafael Espindola 8fe1f37c55 Update for llvm api change.
llvm-svn: 200443
2014-01-30 02:49:58 +00:00
Shankar Easwaran b6a6bdab20 [ELF][Hexagon] typeZeroFillQuick is not associated with bss section.
We need to increase the memory and the filesize when we add a typeZeroFillQuick
atom.

llvm-svn: 200369
2014-01-29 04:04:27 +00:00
Simon Atanasyan 7aa9061ead [Mips] Declare MipsDynamicTable class in a separate header file.
llvm-svn: 200328
2014-01-28 18:52:41 +00:00
NAKAMURA Takumi 4162034bb5 [CMake] Apply llvm_update_compile_flags() in add_lld_library().
Sorry for the breakage.

llvm-svn: 200306
2014-01-28 10:45:37 +00:00
Rui Ueyama 4aaba3e220 [PECOFF] Replace magic numbers with sizeof.
llvm-svn: 200278
2014-01-28 01:55:37 +00:00
Rui Ueyama bdc2fc3635 [PECOFF] Convert more binary files to YAML.
Because the object files are now readable to humans, I don't think we need the
source assembly file any more, so I removed them too in this commit.

llvm-svn: 200276
2014-01-28 01:41:39 +00:00
Rui Ueyama 6d3fee23e3 [PECOFF] Remove a redundant test.
peplus.test and pe32plus.test basically covered the same thing, so
remove pe32plus.test and then rename peplus.test -> pe32plus.test.

llvm-svn: 200275
2014-01-28 01:36:13 +00:00