Commit Graph

1983 Commits

Author SHA1 Message Date
Tim Northover 08d6a7bfef MachO: calculate segment offsets in final MachO files properly.
Because of how we were calculating fileOffset and fileSize for segments, most
ended up at a single offset in a finalised MachO file. This meant the data
often didn't even get written in the final object, let alone where it would be
useful.

llvm-svn: 212030
2014-06-30 09:49:30 +00:00
Tim Northover f9b13d6766 MachO: support atomization of dylibs.
For .dylib files, we refrain from actually creating any atoms until they're
requested via the "exports" method.

llvm-svn: 212027
2014-06-30 09:11:38 +00:00
Nick Kledzik 07d2c313a9 [mach-o] fix struct initialization to work with Windows compiler
llvm-svn: 211951
2014-06-27 19:08:56 +00:00
Nick Kledzik 3f69076278 [mach-o] refactor x86_64 relocation handling.
This is first step in reworking how mach-o relocations are processed.
The existing KindHandler is going to become a delgate/helper object for
processing architecture specific references.  The KindHandler knows how
to convert mach-o relocations into References and back, as well, as fixing
up the content the relocation is on.

One of the messy things about mach-o relocations is that they sometime 
come in pairs, but the pairs still convert to one lld::Reference. So, the
conversion has to detect pairs (arch specific) and change the stride.

llvm-svn: 211921
2014-06-27 18:25:01 +00:00
Nick Kledzik 1e8dbd360d Add const to sort() comparator function. Caught by gcc but not clang
llvm-svn: 211833
2014-06-27 01:04:01 +00:00
Nick Kledzik 728d606689 Add utility to SimpleDefinedAtom to sort references
llvm-svn: 211825
2014-06-27 00:30:31 +00:00
Simon Atanasyan 65e2464667 [Driver] Improve the `isPathUnderSysroot()` function. Now it returns a
correct result even if checking paths: a) symlinks and/or b) contains relative
parts like /dir1/dir2/../dir2.

llvm-svn: 211772
2014-06-26 10:48:52 +00:00
Tim Northover 1565e56785 [mach-o]: make sure custom sort method is irreflexive.
The previous function returned true for "s < s", which could completely mess up
the sorting of symbols within a section.

Unfortunately, I don't think there's a robust way to write a test for this.
Anything I come up with will be making assumptions about the particular
implementation of std::sort.

llvm-svn: 211704
2014-06-25 15:12:55 +00:00
Tim Northover f48f0620ed [mach-o]: atomize zero-terminated literals correctly.
When looking through sections with zero-terminated string-literals (__cstring
or __ustring) we were constantly rechecking the first few bytes of the string
for '\0' rather than advancing along. This obviously failed unless all strings
within the section had the same length as that first one.

llvm-svn: 211682
2014-06-25 11:21:51 +00:00
Tim Northover 36bd9ab2c5 [mach-o] don't assume all sections have symbols
We were trying to examine the first symbol in a section that we wanted to
atomize by symbols, even when there wasn't one. Instead, we should make the
initial anonymous symbol cover the entire section in that situation.

llvm-svn: 211681
2014-06-25 10:59:37 +00:00
Simon Atanasyan d449fc8671 [ELF] Add two new virtual functions to the `OutputELFWriter` class to control
dynamic symbol table populating and DT_NEEDED tag creation.

The `isDynSymEntryRequired` function returns true if the specified shared
library atom requires a dynamic symbol table entry. The `isNeededTagRequired`
function returns true if we need to create DT_NEEDED tag for the shared
library defined specified shared atom.

By default the both functions return true. So there is no functional changes
for all targets except MIPS. Probably we need to spread the same modifications
on other ELF targets but I want to implement and fully tested complete set of
changes for MIPS target first.

For MIPS we create a dynamic symbol table entry for a shared library atom iif
this atom is referenced by a regular defined atom. For example, if library L1
defines symbol T1, library L2 defines symbol T2 and uses symbol T1
and executable file E1 uses symbol T2 but does not use symbol T1 we create
an entry in the E1 dynamic symbol table for symbol T2 and do not create
an entry for T1.

The patch creates DT_NEEDED tags for shared libraries contain shared library
atoms which a) referenced by regular defined atoms; b) have corresponding
copy dynamic relocations (R_MIPS_COPY).

Now the patch does not take in account --as-needed / --no-as-needed command
line options. So it is too restrictive and create DT_NEEDED tags for really
needed shared libraries only. I plan to fix that by subsequent patches.

llvm-svn: 211674
2014-06-25 07:55:55 +00:00
Rafael Espindola bce7feb6c4 Update for llvm api change.
llvm-svn: 211596
2014-06-24 13:57:13 +00:00
Rafael Espindola 96b676c312 Update for llvm api change.
llvm-svn: 211548
2014-06-23 22:29:12 +00:00
Simon Atanasyan 3b8c86b985 [Mips] Make rel-dynamic-03.test test case independent from external input files.
llvm-svn: 211491
2014-06-23 12:28:11 +00:00
Simon Atanasyan b1032ad260 [Mips] Make rel-dynamic-01.test test case independent from external input files.
llvm-svn: 211463
2014-06-22 11:58:08 +00:00
Simon Atanasyan fa30168395 [Mips] Remove redundant checking from the RelocationPass::isDynamic() function.
No functional changes.

llvm-svn: 211431
2014-06-21 08:36:12 +00:00
Tim Northover db128a2d3f PE/COFF: move PAGE_SIZE into the PECOFFLinkingContext.
A refactoring, with the added benefit of helping OS X builds.

llvm-svn: 211371
2014-06-20 16:45:16 +00:00
Tim Northover d30a1f2cb2 MachO: rename _outputFileType to avoid shadowing parent field.
llvm-svn: 211367
2014-06-20 15:59:00 +00:00
Simon Atanasyan e8a2875774 [Mips] Make rel-copy.test test case independent from external input files.
llvm-svn: 211355
2014-06-20 12:54:06 +00:00
Simon Atanasyan 825c5992d8 [Mips] Make r26-1.test test case independent from external input files.
llvm-svn: 211263
2014-06-19 10:18:58 +00:00
Rui Ueyama 61d7f97000 [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."

I added a new reference type, kindAssociate. If a target atom is
coalesced away, the referring atom is removed by Resolver, so that
they are treated as a group.

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

llvm-svn: 211106
2014-06-17 16:19:33 +00:00
Simon Atanasyan e5b03cb790 [Mips] Make plt-header.test test case independent from external input files.
llvm-svn: 211099
2014-06-17 13:08:11 +00:00
Rafael Espindola 19d02371c9 Update for llvm api change.
llvm-svn: 211034
2014-06-16 16:09:08 +00:00
Simon Atanasyan 0469dbd43f [Mips] Make hilo16-5.test test case independent from external input files.
llvm-svn: 211017
2014-06-16 11:54:42 +00:00
Simon Atanasyan 004c49b017 [Mips] Make gp-sym-2.test test case independent from external input files.
llvm-svn: 210987
2014-06-15 12:04:40 +00:00
Simon Atanasyan 2e67be3cc2 [Mips] Make gp-sym-1.test test case independent from external input files.
llvm-svn: 210981
2014-06-14 21:18:50 +00:00
Artyom Skrobov f8874b0a05 Using llvm::sys::swapByteOrder() for the common case of byte-swapping a value in place
llvm-svn: 210979
2014-06-14 13:26:14 +00:00
Simon Atanasyan 4156ac2ecd [Mips] Make exe-got.test test case independent from external input files.
llvm-svn: 210977
2014-06-14 12:55:03 +00:00
Artyom Skrobov 17587fb028 Left two files out of the previous commit
llvm-svn: 210975
2014-06-14 12:40:04 +00:00
Artyom Skrobov 9b3f647bf3 llvm::sys::SwapByteOrder() renamed to llvm::sys::getSwappedBytes()
Further to this, llvm::sys::swapByteOrder() will be added, acting in-place

llvm-svn: 210974
2014-06-14 12:14:25 +00:00
Rafael Espindola 372bc70c63 Update for llvm api change.
llvm-svn: 210919
2014-06-13 17:20:48 +00:00
Rafael Espindola b34440f9c4 Remove unused and odd code.
This code was never being used and any use of it would look fairly strange.
For example, it would try to map a NativeReaderError::file_malformed to
std::errc::invalid_argument.

llvm-svn: 210913
2014-06-13 15:36:45 +00:00
Simon Atanasyan f0f8207995 [Mips] Make exe-fileheader.test test case independent from external input files.
llvm-svn: 210893
2014-06-13 11:44:23 +00:00
Rafael Espindola 2cef13cf71 Remove a 'using std::error_code' I missed in the previous pass.
llvm-svn: 210878
2014-06-13 03:24:40 +00:00
Rafael Espindola f743031b8b More prefixing of error_code.
llvm-svn: 210831
2014-06-12 21:35:33 +00:00
Rafael Espindola 6400ed4e75 Refer to error_code with an std prefix.
llvm-svn: 210820
2014-06-12 20:42:12 +00:00
Rafael Espindola 54427ccef3 include system_error directly.
llvm-svn: 210801
2014-06-12 17:15:58 +00:00
Rafael Espindola 1675d51eac Run llvm/utils/sort_includes.py in a few files.
This will reduce the noise in a followup patch.

llvm-svn: 210800
2014-06-12 17:12:28 +00:00
Rafael Espindola 7264b0bf29 Uses #include "..." instead of #include <...> for llvm headers.
llvm-svn: 210799
2014-06-12 17:08:11 +00:00
Simon Atanasyan 033ecd1cc8 [Mips] Make exe-dynamic.test test case independent from external input files.
llvm-svn: 210796
2014-06-12 16:46:47 +00:00
Rafael Espindola b1a4d3a26c Don't import error_code into the lld namespace.
llvm-svn: 210785
2014-06-12 14:53:47 +00:00
Rafael Espindola 4956850fdc replace llvm::error_code with std::error_code.
llvm-svn: 210781
2014-06-12 14:04:54 +00:00
Rafael Espindola 99c78a9f3c Don't use make_error_code from the llvm namespace.
llvm-svn: 210741
2014-06-12 03:13:49 +00:00
Rafael Espindola 92d8b456d9 Use error_category from the std namespace.
llvm-svn: 210732
2014-06-12 01:44:19 +00:00
Rafael Espindola 7cc0d413b5 Use error_condition from the std namespace.
llvm-svn: 210730
2014-06-12 01:28:12 +00:00
Rafael Espindola 28db74b2f0 Fix test build on windows.
llvm-svn: 210714
2014-06-11 22:23:45 +00:00
Rui Ueyama e05d380486 Move Simple.h and Alias.h to include/Core.
Because the files in Core actually depend on these files.

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

llvm-svn: 210710
2014-06-11 21:47:51 +00:00
Rafael Espindola 7b0d7cf96b Quick fix for the windows build.
We have to look for both std::make_error_code as well as our overloads.

llvm-svn: 210704
2014-06-11 21:04:06 +00:00
Rui Ueyama 8ab4e2ce25 group-cmd-search test is not supposed to pass on Windows.
llvm-svn: 210697
2014-06-11 20:00:22 +00:00
Rafael Espindola 7b8b9ae1cb Use std::error_code instead of llvm::error_code.
This is an update for a llvm api change.

llvm-svn: 210689
2014-06-11 19:05:58 +00:00
Simon Atanasyan 87a06716e6 [Mips] Fix the bug -- symbol referred by the R_MIPS_TLS_GD relocation
does not get an entry in the dynamic symbol table.

llvm-svn: 210648
2014-06-11 10:08:08 +00:00
Rafael Espindola 1f7701c19c Missed these from the previous commit.
llvm-svn: 210629
2014-06-11 03:35:50 +00:00
Rafael Espindola 4b4cdf5e3a Inherit from error_category instead of _do_message.
There is no std::_do_message and these classes override message anyway.

llvm-svn: 210626
2014-06-11 03:28:13 +00:00
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
Nick Kledzik cc28bc1816 [mach-o] Wire up mach-o binary reader to reader registry
llvm-svn: 209868
2014-05-30 01:13:49 +00:00
Nick Kledzik f317d66c31 [mach-0] Add support for parsing compact unwind info section
llvm-svn: 209865
2014-05-29 23:50:48 +00:00
Nick Kledzik b367c25f28 [mach-o] Add support for parsing __eh_frame section. Generalize support for whether symbols in a section are ignored or illegal
llvm-svn: 209858
2014-05-29 23:07:20 +00:00
Nick Kledzik 9ede702bc4 [mach-o] Add support for parsing CFString sections
llvm-svn: 209844
2014-05-29 20:44:21 +00:00
Simon Atanasyan 7b3dd1789c [Mips] Do not mix _gp and _gp_disp symbols in relocation handling.
No functional changes.

llvm-svn: 209709
2014-05-28 04:10:01 +00:00
Nick Kledzik cda69a279d [mach-o] Add support for parsing of weak-def symbols
llvm-svn: 209707
2014-05-28 02:04:45 +00:00
Nick Kledzik 8399d69cb2 [mach-o] rename test case
llvm-svn: 209705
2014-05-28 01:31:04 +00:00
Nick Kledzik 388f3d02de [mach-o] Support parsing of non-lazy-pointer sections
llvm-svn: 209704
2014-05-28 01:16:35 +00:00
Nick Kledzik a4a08d31cf [mach-o] Add support for initializers and terminators in object files
llvm-svn: 209700
2014-05-27 23:20:52 +00:00
Nick Kledzik 81e105e8d6 [mach-o] Add checks that string literals in object files are zero terminated
llvm-svn: 209685
2014-05-27 20:37:08 +00:00
Nick Kledzik 3e90e5f187 [mach-o] Add support for reading utf16 string literal sections
llvm-svn: 209684
2014-05-27 20:25:06 +00:00
Nick Kledzik 181ce5ee03 Add make_dynamic_error_code().
This is a short-term fix to allow lld Readers to return error messages
with dynamic content.  

The long term fix will be to enhance ErrorOr<> to work with errors other
than error_code.  Or to change the interface to Readers to pass down a
diagnostics object through which all error messages are written.

llvm-svn: 209681
2014-05-27 19:35:41 +00:00
Simon Atanasyan 1c04babce3 [Mips] Handle relocations against __gnu_local_gp symbol.
llvm-svn: 209644
2014-05-27 05:23:16 +00:00
Simon Atanasyan e145a7da87 [Mips] Do not count global GOT entries using the separate variable. Use
size of global GOT entries map for that.

llvm-svn: 209616
2014-05-26 08:32:38 +00:00
Simon Atanasyan bacee46924 [Mips] Reduce code duplication. Join relocation handling functions which
perform calculations for R_MIPS_GOT16 and R_MIPS_CALL16 relocations.

llvm-svn: 209594
2014-05-25 10:07:04 +00:00
Simon Atanasyan 6c68ffe3ef [Mips] Factor out the code assign a value to the absolute atom into the
separate function.

llvm-svn: 209593
2014-05-25 09:05:06 +00:00
Simon Atanasyan 23fe15a62d [Mips] Factor out the code create Mips specific runtime file into
the MipsELFWriters member function.

llvm-svn: 209592
2014-05-25 09:04:57 +00:00
Simon Atanasyan f7534383f5 [Mips] Remove unused class member declaration.
llvm-svn: 209591
2014-05-25 09:04:45 +00:00
Simon Atanasyan 6d1a09f39f [Mips] Reduce code duplication. Join relocation handling functions which
perform similar calculations.

llvm-svn: 209590
2014-05-25 09:04:15 +00:00
Simon Atanasyan 2ffbb19335 [Mips] Handle R_MIPS_TLS_TPREL_HI16 / R_MIPS_TLS_TPREL_LO16 relocations.
llvm-svn: 209582
2014-05-24 16:45:31 +00:00
Rui Ueyama 0e57b91f9c Use short identifier.
llvm-svn: 209497
2014-05-23 03:08:05 +00:00
Rui Ueyama f713cced0e [PECOFF] Make a separate pass for /alternatename symbols.
/alternatename is a command line option to define a weak alias. You
can use it as /alternatename:foo=bar to define "foo" as a weak alias
for "bar".

Because it's a command line option, the weak alias mapping is in the
LinkingContext object, and not in a object file being read.

Previously, we looked up the mapping each time we read a new symbol
from a file, to check if there is a weak alias defined for the symbol.
That's not wrong, but had made function signature's a bit complicated --
we had to pass the mapping object to many functions. Now their
parameter lists are much cleaner.

This also has another (unrealized) benefit. parseFile() now read a
file and then add alias symbols to the file. In the first pass a
LinkingContext object is not used at all. That should make it easy
to read files from archive files speculatively, as the first pass
is free from side effect.

llvm-svn: 209486
2014-05-23 00:02:42 +00:00
Rui Ueyama ba46cdb21f Move alias symbols from ELFLinkingContext to LinkingContext.
Alias symbols are SimpleDefinedAtoms and are platform neutral. They
don't have to belong ELF. This patch is to make it available to all
platforms. No functionality change intended.

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

llvm-svn: 209475
2014-05-22 21:37:56 +00:00
Nick Kledzik 8a0bc44b71 [mach-o] Fix so that mach-o semantic errors return an error rather than assert
llvm-svn: 209469
2014-05-22 20:05:43 +00:00
Nick Kledzik d48cb047e4 [mach-o] Remove MachOFormat.hpp, everything now uses llvm/Support/MachO.h
llvm-svn: 209385
2014-05-22 01:56:40 +00:00
Nick Kledzik e39685964b [mach-o] Use lit.local.cfg to enable mach-o test cases to be run
llvm-svn: 209383
2014-05-22 01:47:17 +00:00
Nick Kledzik a0c13a2420 [mach-o] parse literal sections into atoms
llvm-svn: 209379
2014-05-22 01:42:06 +00:00
Rui Ueyama 328da5527e Simplify nullptr check.
llvm-svn: 209357
2014-05-22 00:36:36 +00:00
Rui Ueyama 8f2394d456 Fix comment.
llvm-svn: 209334
2014-05-21 23:07:16 +00:00
Rui Ueyama 339d12ff12 [PECOFF] Fix unsafe memory access.
llvm-svn: 209323
2014-05-21 21:51:11 +00:00
Rui Ueyama 9f4674c828 [PECOFF] Check for a Characteristics field of a .debug section.
llvm-svn: 209317
2014-05-21 19:44:08 +00:00
Simon Atanasyan 37fe06711f [Mips] Simplify handling of R_MIPS_LO16 / R_MIPS_HI16 relocations
against _gp_disp symbol.

llvm-svn: 209315
2014-05-21 18:23:46 +00:00
Rafael Espindola 38eed1b86d Update for llvm's r209253.
llvm-svn: 209293
2014-05-21 13:07:41 +00:00
Rui Ueyama 85a0321b15 [PECOFF] Discard .debug sections.
llvm-svn: 209274
2014-05-21 05:56:31 +00:00
Rui Ueyama 5c35c8c9ab [PECOFF] Make COFFObjectReader thread-safe.
llvm-svn: 209271
2014-05-21 04:17:05 +00:00
Rui Ueyama 9b0a69d6dc [PECOFF] Acquire mutex before accessing shared objects.
addResolvableSymbols() queues input files, and readAllSymbols() reads
from them. In practice it's currently safe because they are called from
a single thread. But it's not guaranteed.

Also, acquiring the same mutex is needed not to see inconsistent memory
contents that is allowed in the C++ memory model.

llvm-svn: 209254
2014-05-20 23:05:09 +00:00
Rui Ueyama 1255496271 [PECOFF] Do not use anonymous namespace in a header.
llvm-svn: 209243
2014-05-20 21:58:34 +00:00
Alp Toker 2e62f7220f Fix typos
llvm-svn: 209213
2014-05-20 16:17:53 +00:00
Simon Atanasyan c2ec8c5281 [Mips] Show warning if the linker cannot find a pair for a R_MIPS_HI16
relocation. In fact this case violates ABI but sometimes compilers might
produce such code.

llvm-svn: 209153
2014-05-19 18:48:57 +00:00
Simon Atanasyan 9ab2cd0301 [Mips] Fix calculation of initial GOT entry value when this entry is
referenced by a local symbol.

llvm-svn: 209063
2014-05-17 04:58:26 +00:00
Nick Kledzik e09cfc5f8a [mach-o] Add support for zero-fill sections.
llvm-svn: 208928
2014-05-15 23:03:50 +00:00
Nick Kledzik 61fdef6086 [mach-o] Add support and test cases for parsing tentative definitions
llvm-svn: 208919
2014-05-15 20:59:23 +00:00
Rui Ueyama 5def41ee40 [PECOFF] Read files lazily.
ExportedSymbolRenameFile is not always used. In most cases we don't
need to read given files at all. So lazy load would help. This doesn't
change the meaining of the program.

llvm-svn: 208818
2014-05-14 22:35:47 +00:00
Rui Ueyama 50c337a47c Remove trailing whitespaces.
llvm-svn: 208815
2014-05-14 21:49:38 +00:00
Nick Kledzik dba52ad488 [mach-o] Add test case for parsing nlist -> Scope
llvm-svn: 208814
2014-05-14 21:37:14 +00:00
Nick Kledzik 0224e3475d Add -print_atoms options to DarwinLdDriver which dumps final state of all atoms in yaml
llvm-svn: 208813
2014-05-14 21:32:21 +00:00
Rui Ueyama 2a52251153 Fix regression introduced in r205566.
In r205566, I made a change to Resolver so that Resolver revisit
only archive files in --start-group and --end-group pair. That's
not correct, as it also has to revisit DSO files.

This patch is to fix the issue.

Added a test to demonstrate the fix. I confirmed that it succeeded
before r205566, failed after r205566, and is ok with this patch.

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

llvm-svn: 208797
2014-05-14 17:29:27 +00:00