Commit Graph

1830 Commits

Author SHA1 Message Date
Nick Kledzik 936d5205bb [mach-o] fix use of resolver functions to not cause duplicate sections.
The previous commit uncovered a bug in the mach-o writer whereby two __text
sections were created.  But the test case did not catch that.  So I updated
the test case to run the linker a second time, reading the output of the
first pass.  

llvm-svn: 210624
2014-06-11 01:30:55 +00:00
Rui Ueyama 195f04afeb Fix pecoff/export.test on Windows.
llvm-svn: 210621
2014-06-11 01:18:05 +00:00
Nick Kledzik 6085539bed [mach-o] add support for parsing resolver functions
llvm-svn: 210612
2014-06-11 00:24:16 +00:00
Rafael Espindola 3a3532ebb9 Mark a few functions noexcept.
llvm-svn: 210590
2014-06-10 21:26:18 +00:00
Simon Atanasyan 842a90d264 [ReaderWriter] Simplify initialization of class fields.
No functional changes.

llvm-svn: 210532
2014-06-10 13:43:24 +00:00
Simon Atanasyan 014f0ca0d3 [ELF] Fix typo in the type name of the range-based loop item.
No functional changes.

llvm-svn: 210531
2014-06-10 13:43:19 +00:00
Simon Atanasyan 6790b14ebb [ELF] Fix the bug -- LLD crashes if the --whole-archive option
is around non-archive.

llvm-svn: 210530
2014-06-10 13:43:13 +00:00
Nick Kledzik ec140834d4 [mach-o] refactor mach-o output section selection to be table driven.
In -r mode the sections use the table used to parse .o files.  Otherwise
use final exectuable table.  No functionality change.

llvm-svn: 210506
2014-06-10 01:50:00 +00:00
Nick Kledzik b423266e93 [mach-o] parse multiple symbols on same address into aliases
llvm-svn: 210502
2014-06-09 23:35:37 +00:00
Simon Atanasyan 1de1d63aec [Mips] Make dt-textrel.test test case independent from external input files.
llvm-svn: 210469
2014-06-09 13:45:58 +00:00
Rui Ueyama d7b32b93e0 Remove dead parameter.
llvm-svn: 210461
2014-06-09 09:58:53 +00:00
Rui Ueyama c97b661475 Re-commit r210425.
llvm-svn: 210456
2014-06-09 08:57:37 +00:00
Rui Ueyama 8708a0ea7e Add missing dependency for check-lld.
llvm-svn: 210455
2014-06-09 08:42:38 +00:00
Rui Ueyama 2ad8c22a55 Revert "[Mips] Make got16.test test case independent from external input files."
This reverts commit r210425 because the test added in the commit
is broken.

llvm-svn: 210451
2014-06-09 08:23:58 +00:00
Simon Atanasyan 8804e5cb49 [Mips] Make got16.test test case independent from external input files.
llvm-svn: 210425
2014-06-08 11:33:05 +00:00
Simon Atanasyan c8e86fb032 [Mips] Handle Mips TLS relocations R_MIPS_TLS_GOTTPREL / R_MIPS_TLS_GD / R_MIPS_TLS_LDM etc.
llvm-svn: 210394
2014-06-07 13:20:53 +00:00
Simon Atanasyan 8065fb761e [Mips] Make dynlib-dynsym.test self contained.
llvm-svn: 210258
2014-06-05 12:39:12 +00:00
Rui Ueyama 0291dd2c8a Revert "[PECOFF] Support COMDAT associative sections."
This reverts accidental commit r210240.

llvm-svn: 210243
2014-06-05 07:40:59 +00:00
Rui Ueyama 733b45f3b0 Add SymbolTable::isCoalescedAway
isCoalescedAway(x) is faster than replacement(x) != x as the former
does not follow the replacement atom chain. Also it's easier to use.

llvm-svn: 210242
2014-06-05 07:37:29 +00:00
Rui Ueyama 52edc49031 Print error message in LinkOnce handler.
Rather than outside of the handler function to make the code simple.

llvm-svn: 210241
2014-06-05 07:37:25 +00:00
Rui Ueyama f3cb9d1d57 [PECOFF] Support COMDAT associative sections.
COFF supports a feature similar to ELF's section groups. This
patch implements it.

In ELF, section groups are identified by their names, and they are
treated somewhat differently from regular symbols. In COFF, the
feature is realized in a more straightforward way. A section can
have an annotation saying "if Nth section is linked, link this
section too."

Implementing such feature is easy. We can add a reference from a
target atom to an original atom, so that if the target is linked,
the original atom is also linked. If not linked, both will be
dead-stripped. So they are treated as a group.

I added a new reference type, kindAssociate. It does nothing except
preventing referenced atoms from being dead-stripped.

No change to the Resolver is needed.

Reviewers: Bigcheese, shankarke, atanasyan

Subscribers: llvm-commits

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

llvm-svn: 210240
2014-06-05 07:37:20 +00:00
Iain Sandoe c4d9bedcfc Initial set of Makefiles
This provides support for the autoconfing & make build style.
The format, style and implementation follows that used within the llvm and clang projects.

TODO: implement out-of-source documentation builds.
llvm-svn: 210177
2014-06-04 09:54:07 +00:00
Rui Ueyama 5fa471e252 Fix a wrong comment.
Previously FileArchive ctor comment said that only its subclasses
can be instantiated, but the ctor is actually public and is
instantiated by ArchiveReader.

Remove the wrong comment and reorder the member functions so that
public members appear before private ones.

llvm-svn: 210175
2014-06-04 09:09:06 +00:00
Rui Ueyama e5d36a910e Add a comment, fix style.
llvm-svn: 210174
2014-06-04 09:00:55 +00:00
Rui Ueyama d62d131e49 Fix format.
llvm-svn: 210172
2014-06-04 08:39:56 +00:00
Nick Kledzik a2d602560b [mach-o] Make anonymous atom out of section content before any symbol
In sections that are broken into atoms at symbols, if the first symbol in the
section is not at the start of the section, then make an anonymous atom for
the section content that is before the first symbol.

llvm-svn: 210142
2014-06-04 00:34:27 +00:00
Nick Kledzik cb9f890b77 [mach-o] Refactor sections -> atoms to be table driven.
Previously each section kind had its own code to loop over the section and
parse it into atoms.  This refactoring has two tables.  The first maps sections
to ContentType.  The second maps ContentType to information on how to find 
the atom boundaries.  

A few bugs in test cases were discovered as part of the refactoring.  
No change in functionality intended.

llvm-svn: 210138
2014-06-03 23:36:50 +00:00
Rafael Espindola e3986f3e04 Remove dead code.
New code should probably use shared_ptr anyway.

llvm-svn: 210110
2014-06-03 15:36:31 +00:00
Simon Atanasyan fd5b2346cc [Mips] Make la25-stub.test self contained.
No functional changes.

llvm-svn: 210094
2014-06-03 09:59:42 +00:00
Rui Ueyama eafa806b72 Improve error message.
Previously the parser always printed out an error message followed
by "Invalid file type" even if the file type is correct.

llvm-svn: 210093
2014-06-03 08:40:49 +00:00
Rui Ueyama 009f91a9ee Rename FileToMutable -> SimpleFileWrapper.
FileToMutable is what this class does, but this class (or, to be precise,
an instance of this class) is a wrapper of the other SimpleFile. It's odd
that the class was named like a function.

llvm-svn: 210089
2014-06-03 08:12:33 +00:00
Rui Ueyama 6668b5a8b8 Fix build breakage.
llvm-svn: 210087
2014-06-03 07:53:37 +00:00
Rui Ueyama 6848f96c7a Inline short member function.
llvm-svn: 210086
2014-06-03 07:52:42 +00:00
Rui Ueyama 95be0d014a Use auto for obvious types.
llvm-svn: 210085
2014-06-03 07:43:15 +00:00
Rui Ueyama 9ef8a9c94b No need to compute valBit until mask bit is 1.
llvm-svn: 210084
2014-06-03 07:39:32 +00:00
Rui Ueyama 076caf7897 Use range-based for loop.
llvm-svn: 210082
2014-06-03 07:27:49 +00:00
Rui Ueyama 9939b5ab5e Remove unusual use of using.
llvm-svn: 210081
2014-06-03 07:24:46 +00:00
Rui Ueyama 04ade04e98 Reference::target() doesn't and shouldn't return a nullptr.
llvm-svn: 210074
2014-06-03 05:04:07 +00:00
Rafael Espindola 1d364c18e2 This lambda returns a boolean, update the return statements.
llvm-svn: 210071
2014-06-03 04:41:30 +00:00
Rui Ueyama 9aee050a0c Remove group-parent references.
Previously section groups are doubly linked to their children.
That is, an atom representing a group has group-child references
to its group contents, and content atoms also have group-parent
references to the group atom. That relationship was invariant;
if X has a group-child edge to Y, Y must have a group-parent
edge to X.

However we were not using group-parent references at all. The
resolver only needs group-child edges.

This patch simplifies the section group by removing the unused
reverse edge. No functionality change intended.

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

llvm-svn: 210066
2014-06-03 03:07:49 +00:00
Rui Ueyama 23487e878b Make dead-striping to handle reverse edges.
Layout-before edges are no longer used for layout, but they are
still there for dead-stripping. If we would just remove them
from code, LLD would wrongly remove live atoms that were
referenced by layout-befores.

This patch fixes the issue. Before dead-stripping, it scans all
atoms to construct a reverse map for layout-after edges. Dead-
stripping pass uses the map to traverse the graph.

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

llvm-svn: 210057
2014-06-03 01:59:02 +00:00
Rui Ueyama 02162b9cfa Run clang-format.
llvm-svn: 210015
2014-06-02 11:13:11 +00:00
Rui Ueyama d3159ce8d6 s/vector/std::vector/
llvm-svn: 210014
2014-06-02 10:58:47 +00:00
Rui Ueyama 6ffe42eee5 Simplify markLive().
Reference::target() never returns a nullptr, so NULL check
is not needed and is more harmful than doing nothing.
No functionality change.

llvm-svn: 210008
2014-06-02 08:06:57 +00:00
Simon Atanasyan 2c2486446c [Mips] Reduce number of input files used my Mips tests.
No functional changes.

llvm-svn: 210004
2014-06-02 04:20:01 +00:00
Simon Atanasyan b635d04589 [Mips] Implement .{ctors,dtors}.<priority> sections ordering.
Arrange .ctors/.dtors sections in the following order:
  .ctors from crtbegin.o or crtbegin?.o
  .ctors from regular object files
  .ctors.* (sorted) from regular object files
  .ctors from crtend.o or crtend?.o

This order is specific for MIPS traget. For example, on X86
the .ctors.* sections are merged into the .init_array section.

llvm-svn: 209987
2014-06-01 06:28:42 +00:00
Rafael Espindola a72f21d195 There is no std::errc:success, remove the llvm one.
llvm-svn: 209958
2014-05-31 03:20:37 +00:00
Rafael Espindola 63ed1a3519 Use error_code() instead of error_code::succes()
There is no std::error_code::success, so this removes much of the noise
in transitioning to std::error_code.

llvm-svn: 209948
2014-05-31 01:22:21 +00:00
Nick Kledzik acfad80250 [mach-o] Add support for custom sections
llvm-svn: 209928
2014-05-30 22:51:04 +00:00
Simon Atanasyan 2aae2b4609 [ELF] Fix incorrect sorting of .init_array / .fini_array sections.
The main problem is in the predicate passed to the `std::stable_sort()`.
This predicate always returns false if **both** section's names do not
start with `.init_array` or `.fini_array` prefixes. In short, it does not
define a strict weak orderng. Suppose we have the following sections:

  .A .init_array.1 .init_array.2

The predicate states that:

  not .init_array.1 < .A
  not .A < .init_array.2
  but .init_array.1 < .init_array.2 !!!

The second problem is that `.init_array` section without number should
go last in the list. Not it has the lowest priority '0' and goes first.

The patch fixes both of the problems.

llvm-svn: 209875
2014-05-30 05:29:46 +00:00