Commit Graph

2958 Commits

Author SHA1 Message Date
Davide Italiano 8dd4e70222 [Driver] Remove break after return. NFCI.
llvm-svn: 278834
2016-08-16 18:23:44 +00:00
Duncan P. N. Exon Smith 623c4c1572 MachO: Use ilist_half_embedded_sentinel_traits, NFC
Use ilist_half_embedded_sentinel_traits for the list of
lld::mach_o::normalized::TrieEdge, rather than duplicating the code.

llvm-svn: 278523
2016-08-12 16:25:04 +00:00
Davide Italiano 54eb8ffd55 [Core] Retire yet another unused member function.
The code in lib/ could use a lot of love :(

llvm-svn: 278506
2016-08-12 12:37:23 +00:00
Davide Italiano 0f672ed87a [Core] Simplify a bit. NFCI.
llvm-svn: 278505
2016-08-12 12:34:39 +00:00
Pete Cooper ef5bea9dca Dead strip DESC bits should only be set on object files.
It only makes sense to set on N_NO_DEAD_STRIP on a relocatable object file.  Otherwise the bits aren't useful for anything.  Matches the ld64 behaviour.

llvm-svn: 278419
2016-08-11 21:27:18 +00:00
Pete Cooper 1ed8f1f6e5 Better compress lazy binding info to match ld64.
We should be using one of BIND_OPCODE_SET_DYLIB_SPECIAL_IMM, BIND_OPCODE_SET_DYLIB_ORDINAL_IMM,
and BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB depending on whether ordinals are <= 0, <= 15, > 15.

This matches the behaviour of ld64.

llvm-svn: 278407
2016-08-11 20:59:27 +00:00
Pete Cooper 21f475e1c4 Generate slightly more compressed binding opcodes when entries are the same as last time.
We already had logic for binding opcodes had the same addend as last time.  This adds
the cases where the ordinal, symbol name, type, and segment offsets are the same as
the last emitted ordinal.

This gets us one step closer to emitting rebase opcodes as compressed as ld64 can manage.

llvm-svn: 278405
2016-08-11 20:37:02 +00:00
Pete Cooper 732f1ef9de Arm64 stubs alignment is 2, not 4.
This matches the behaviour of ld64 when looking at the alignment of the stubs section in the final image.

llvm-svn: 278398
2016-08-11 20:18:05 +00:00
Pete Cooper 46cd113c87 Change when we choose to add an LC_LOAD_DYLIB to the final image.
Currently we do this when an atom is used, but we need to do it when a
dylib is referenced on the cmdline as this matches ld64.

This fixes much confusion over which maps are indexed with installName
vs path.  There is likely other confusion so i'll be seeing if i can remove
path() completely in a future commit as path() shouldn't really be needed by anyone.

llvm-svn: 278396
2016-08-11 20:10:14 +00:00
Pete Cooper 932bce6ade Fix off-by-one error in default currentVersion.
A version of 0x1000 is 0.16.0, not 1.0.0 as the comment said.  Fix the
value to match the comment, and also the one test case which had this
wrong.

llvm-svn: 278381
2016-08-11 18:41:14 +00:00
Davide Italiano 7ca0645c80 [Core] Retire addReplacement() member function.
llvm-svn: 278327
2016-08-11 10:50:01 +00:00
Lang Hames 8c2406b1fc [lld][MachO] Fix LC_SEGEMENT[_64] filesize computation in -r mode.
Using vmsize to populate this file works when outputing MachO images, but fails
when outputting relocatable objects. This patch fixes the computation to use
file offsets, which works for both output types.

Fixes <rdar://problem/27727666>

llvm-svn: 278297
2016-08-10 22:15:09 +00:00
Davide Italiano c682303d6f [Core] tentativeDefinition() is now unused.
llvm-svn: 278181
2016-08-10 00:01:13 +00:00
Pete Cooper 5559b24935 The first string table entry should be a null terminated space, not just null.
This matches the behaviour of ld64 which initializes the string table with
' ' then '\0'.  lld only had the '\0' and needed the ' '.

llvm-svn: 278071
2016-08-08 23:20:04 +00:00
Benjamin Kramer df8f196f9a Unpollute the global namespace. lld edition.
llvm-svn: 277926
2016-08-06 13:52:37 +00:00
Pete Cooper d0de3683ec ExportTrie nodes need to be visisted in order.
The export trie was being emitted in the order the nodes were
added to the vector, but instead needs to be visited in the order
that the nodes are traversed.  This matches the behaviour of ld64.

llvm-svn: 277869
2016-08-05 21:37:12 +00:00
Davide Italiano d62d116add [MachO] Factor out some common code in the Driver.
llvm-svn: 277761
2016-08-04 19:56:26 +00:00
Davide Italiano 6bb5d2ddd3 [MachO/Core] Remove (now) unused static member function. NFCI.
llvm-svn: 277760
2016-08-04 19:49:11 +00:00
Kevin Enderby 0fa9fd0f28 Needed change to lld for the changes to libObject/Archive interfaces now returning Expected<>
for the llvm trunk change in r277656

llvm-svn: 277657
2016-08-03 21:58:48 +00:00
Lang Hames 70c80b336b [lld][MachO] Replace some std::string with char* buffers to eliminate mem leaks.
The MachO debug support code (committed in r276935) occasionally needs to
allocate string copies, and was doing so by creating std::strings on a
BumpPtrAllocator. The strings were untracked, so the destructors weren't being
run and we were leaking the memory when the allocator was thrown away. Since
it's easier than tracking the strings, this patch switches the copies to char
buffers allocated directly in the bump-ptr allocator.

llvm-svn: 277208
2016-07-29 20:04:18 +00:00
Kevin Enderby 01e41f11a7 Matching change needed to lld for llvm trunk change r277177.
Where Archive::getMemoryBufferRef() was changed to return Expected<>

llvm-svn: 277183
2016-07-29 17:56:00 +00:00
Lang Hames 242fde1b36 [lld][MachO] Remove some debugging output code that was mistakenly left in in
r276935.

llvm-svn: 276944
2016-07-28 00:28:48 +00:00
Lang Hames 436f7d6606 [lld][MachO] Re-apply r276921 with fix - initialize strings for debug string
copies.

llvm-svn: 276935
2016-07-27 22:55:30 +00:00
Lang Hames f2260567ca [lld][MachO] Temporarily revert r276921 - it's causing bot-failures on Linux.
llvm-svn: 276928
2016-07-27 22:46:02 +00:00
Lang Hames 560333749f [lld][MachO] Add debug info support for MachO.
This patch causes LLD to build stabs debugging symbols for files containing
DWARF debug info, and to propagate existing stabs symbols for object files
built using '-r' mode. This enables debugging of binaries generated by LLD
from MachO objects.

llvm-svn: 276921
2016-07-27 21:31:25 +00:00
Lang Hames 75069a1668 [lld][MachO] Add support for S_ATTR_DEBUG to the MachO YAML reader/writer.
This enables proper recognition of debug sections by attribute, which will be
used in the near future by test-cases for MachO debugging support.

llvm-svn: 276770
2016-07-26 17:17:17 +00:00
Peter Collingbourne 76681d6ab5 Add qualification to fix MSVC build.
llvm-svn: 276720
2016-07-26 02:10:56 +00:00
Peter Collingbourne feee2103c6 COFF: Implement /linkrepro flag.
This flag is implemented similarly to --reproduce in the ELF linker.

This patch implements /linkrepro by moving the cpio writer and associated
utility functions to lldCore, and using that implementation in both linkers.

One COFF-specific detail is that we store the object file from which the
resource files were created in our reproducer, rather than the resource
files themselves. This allows the reproducer to be used on non-Windows
systems for example.

Differential Revision: https://reviews.llvm.org/D22418

llvm-svn: 276719
2016-07-26 02:00:42 +00:00
Davide Italiano fbcf69587e [MachO] Add a couple of missing braces.
Differential Revision:  https://reviews.llvm.org/D21979

llvm-svn: 276213
2016-07-20 23:55:34 +00:00
Lang Hames 622ef17f5d [lld] Update LLD for Archive::child_iterator change in LLVM r275361.
llvm-svn: 275362
2016-07-14 02:35:18 +00:00
Kevin Enderby b9e053cfd7 Matching change for lld for the llvm change of Archive::create() from ErrorOr<...> to Expected<...> in r274160.
llvm-svn: 274161
2016-06-29 20:36:11 +00:00
Lang Hames a5c7adcb38 [lld][MachO] Remove SimpleFile::definedAtoms().
This method just duplicates the functionality of SimpleFile::defined().

llvm-svn: 274048
2016-06-28 18:42:33 +00:00
Lang Hames 1fc0023ebf [lld][MachO] Remove stray comment.
llvm-svn: 273917
2016-06-27 20:00:20 +00:00
Lang Hames 3b3b4d792f [lld][MachO] Add support for x86-64 negDelta64 references and fix negDelta32.
These references are used to implement MachO/x64-64 subtractor relocations
where the minuend is being fixed up, rather than the subtrahend. The 64-bit
version was not previously supported, the 32-bit version was partially
implemented but contained bugs not caught by existing test cases. This
patch fixes both functionality and test coverage.

llvm-svn: 273759
2016-06-25 00:29:54 +00:00
Benjamin Kramer bd521201b7 Apply clang-tidy's misc-move-constructor-init to lld.
No functionality change intended.

llvm-svn: 271686
2016-06-03 16:57:13 +00:00
Eugene Zelenko 20a38451f5 Fix some Include What You Use warnings; other minor fixes.
Differential revision: http://reviews.llvm.org/D19735

llvm-svn: 268093
2016-04-29 19:47:09 +00:00
Eugene Zelenko a7a55c4d27 Fix builds broken in r267008.
llvm-svn: 267010
2016-04-21 17:27:04 +00:00
Eugene Zelenko 1a299eab32 Fix Clang-tidy misc-unused-using-decls and Include What You Use warnings.
Differential revision: http://reviews.llvm.org/D19348

llvm-svn: 267008
2016-04-21 17:14:10 +00:00
Mehdi Amini de3f7678d1 Add missing header (NFC)
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266597
2016-04-18 09:33:41 +00:00
Mehdi Amini 0bc6b2b5a0 Add missing header (NFC)
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266596
2016-04-18 09:26:29 +00:00
Lang Hames 33fd854584 [lld][MachO] Clean up some unnecessarily verbose code. NFC.
Suggested by Dave Blaikie in review of r265447. Thanks Dave!

llvm-svn: 265566
2016-04-06 17:18:55 +00:00
Lang Hames 24f5a3eb03 [lld][MachO] Check Expected<T> for error prior to destruction.
This should fix the failures on the LLD bots caused by r265446.

llvm-svn: 265477
2016-04-05 22:06:48 +00:00
Pete Cooper f4d7688e4b Revert "Remove useless unreachable. Switch coverage already gives us this. NFC"
This reverts commit r264945.

The commit only removed an unreachable in a method with a covered switch, but
GCC is likely to warn on this, and the coding standards recommend just leaving
in the unreachable.

llvm-svn: 264983
2016-03-31 01:23:23 +00:00
Pete Cooper eadf9e4ec9 Remove unused variants of make_dynamic_error_code. NFC.
make_dynamic_error_code was used to create a std::error_code with
a std::string message.  Now that we are migrating to llvm::Error,
there are no calls to these make_dynamic_error_code methods.

There is one single call to make_dynamic_error_code remaining, the one
inside GenericError::convertToErrorCode().  That method is only called
from File::doParse() which should be a temporary situation.  We need
to work out how to deal with File::parse() caching the error result from
doParse().  Caching errors isn't supported in the new scheme, and probably
isn't needed here, but we need to work that out.

Once thats done, dynamic error and all utilities around it can be deleted.

llvm-svn: 264982
2016-03-31 01:21:50 +00:00
Pete Cooper 2f6216c181 Use Expected<T> instead of ErrorOr<T>in yaml reader. NFC
llvm-svn: 264981
2016-03-31 01:13:04 +00:00
Pete Cooper d0a643e7dc Change library search methods to return Optional instead of ErrorOr.
These methods weren't really throwing errors.  The only error used
was that a file could not be found, which isn't really an error at all
as we are searching paths and libraries for a file.  All of the callers
also ignored errors and just used the returned path if one was available.

Changing to return Optional<StringRef> as that actually reflects what
we are trying to do here: optionally find a given path.

llvm-svn: 264979
2016-03-31 01:09:35 +00:00
Pete Cooper dc59c794d0 Fix a bunch more of -Wpessimizing-move issues.
Thanks to Rui for pointing out this warning was firing.

llvm-svn: 264978
2016-03-31 00:38:02 +00:00
Pete Cooper e487da165c Fix a bunch of -Wpessimizing-move issues.
Thanks to Rui for pointing out this warning was firing.

llvm-svn: 264977
2016-03-31 00:35:50 +00:00
Pete Cooper 514594bdd3 Convert a few macho reader/writer helpers to new error handling. NFC.
These methods were responsible for some of the few remaining calls
to llvm::errorCodeToError.  Converting them makes us have more Error's
in the api and fewer error_code's.

llvm-svn: 264974
2016-03-31 00:08:16 +00:00
Pete Cooper c6e7b8146a Convert readBinary to llvm::Error. NFC
llvm-svn: 264973
2016-03-30 23:58:24 +00:00