Commit Graph

485 Commits

Author SHA1 Message Date
Simon Atanasyan e3e8a0a913 [ELF] Regroup code creates ELF relocations references ELFReference into
a couple of new virtual functions.

Follow-up to the rL203408. Two virtual functions `createRelocationReference()`
responsible for creation of `ELFReference` have been replaced by a couple of
new virtual functions `createRelocationReferences()` (plural). Each former
function creates a //single// ELFReference for a specified `Elf_Rela`
or `Elf_Rel` relocation records. The new functions responsible for creation
of //all// relocation references for provided symbol.

For all targets except MIPS there are no functional changes.

MIPS ABI has a notion of //paired// relocations. An effective addend of such
relocations are calculated using addends of both pair's members.
Each `R_MIPS_HI16` and `R_MIPS_GOT16` (for local symbols) relocations must have
an associated `R_MIPS_LO16` entry immediately following it in the list
of relocations. Immediately does not mean "next record" in relocations section
but "next record referenced the same symbol". Moreover a single `R_MIPS_LO16`
relocation can be paired with multiple preceding `R_MIPS_HI16/R_MIPS_GOT16`
relocations.

The paired relocation can have offsets belong to the different symbols.
That is why we need to have access to list of all relocations during
construction of `ELFReference` for MIPS target.

The patch reviewed by Shankar Easwaran.

llvm-svn: 206102
2014-04-12 03:59:46 +00:00
Simon Atanasyan 5eb139fc7c [Mips] Rewrite R_MIPS_26 handling test using the yaml2obj tool.
llvm-svn: 206020
2014-04-11 04:44:05 +00:00
Simon Atanasyan b65826124c [Mips] Rewrite R_MIPS_32 handling test using the yaml2obj tool.
llvm-svn: 206019
2014-04-11 04:43:59 +00:00
Simon Atanasyan 62377c6875 [Mips] R_MIPS_PC32 relocation support.
llvm-svn: 206018
2014-04-11 04:33:21 +00:00
Rui Ueyama 20b075e526 [PECOFF] Fix common symbol alignment.
Differential Revision: http://reviews.llvm.org/D3322

llvm-svn: 205826
2014-04-09 01:01:51 +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
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
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 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 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 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
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 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 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
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
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 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
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 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
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
Rui Ueyama ebffa9b4be [PECOFF] Fix arguments passed to lib.exe.
llvm-svn: 203891
2014-03-14 05:04:08 +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 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
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
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 305c864756 [Mips] Rename R_MIPS_26 relocation handling test case.
llvm-svn: 203407
2014-03-09 13:05: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 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
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
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
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