summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [lld] Fix trivial typos in commentsKazuaki Ishizaki2020-01-061-1/+1
| | | | | | Reviewed By: ruiu, MaskRay Differential Revision: https://reviews.llvm.org/D72196
* Fix component buildRui Ueyama2019-11-191-1/+1
| | | | | b11386f9be9b2dc7276a758d64f66833da10bdea broke lld build if `-DBUILD_SHARED_LIBS=ON` is passed to CMake.
* Make it possible to redirect not only errs() but also outs()Rui Ueyama2019-11-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change is for those who use lld as a library. Context: https://reviews.llvm.org/D70287 This patch adds a new parmeter to lld::*::link() so that we can pass an raw_ostream object representing stdout. Previously, lld::*::link() took only an stderr object. Justification for making stdoutOS and stderrOS mandatory: I wanted to make link() functions to take stdout and stderr in that order. However, if we change the function signature from bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stderrOS = llvm::errs()); to bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stdoutOS = llvm::outs(), raw_ostream &stderrOS = llvm::errs()); , then the meaning of existing code that passes stderrOS silently changes (stderrOS would be interpreted as stdoutOS). So, I chose to make existing code not to compile, so that developers can fix their code. Differential Revision: https://reviews.llvm.org/D70292
* [LLD] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-3/+3
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368936
* Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song2019-08-051-2/+2
| | | | | | F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
* Use llvm::stable_sortFangrui Song2019-04-231-5/+4
| | | | | | | | | Make some small adjustment while touching the code: make parameters const, use less_first(), etc. Differential Revision: https://reviews.llvm.org/D60989 llvm-svn: 358943
* [ELF][MachO][wasm] Simplify range-style std::find{,_if} with STLExtras.h ↵Fangrui Song2019-03-291-2/+1
| | | | | | utilities. NFC llvm-svn: 357269
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Fix clang -Wimplicit-fallthrough warnings across llvm, NFCReid Kleckner2018-11-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch should not introduce any behavior changes. It consists of mostly one of two changes: 1. Replacing fall through comments with the LLVM_FALLTHROUGH macro 2. Inserting 'break' before falling through into a case block consisting of only 'break'. We were already using this warning with GCC, but its warning behaves slightly differently. In this patch, the following differences are relevant: 1. GCC recognizes comments that say "fall through" as annotations, clang doesn't 2. GCC doesn't warn on "case N: foo(); default: break;", clang does 3. GCC doesn't warn when the case contains a switch, but falls through the outer case. I will enable the warning separately in a follow-up patch so that it can be cleanly reverted if necessary. Reviewers: alexfh, rsmith, lattner, rtrieu, EricWF, bollu Differential Revision: https://reviews.llvm.org/D53950 llvm-svn: 345882
* [Darwin] Use errorHandler from liblldCommonBrian Gesiak2018-06-121-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Error handling in liblldCore and the Darwin toolchain prints to an output stream. A TODO in the project explained that a diagnostics interface resembling Clang's should be added. For now, the simple diagnostics interface defined in liblldCommon seems like an improvement. It prints colors when they're available, uses locks for thread-safety, and abstracts away the `"error: "` and newline literal strings that litter the Darwin toolchain code. To use the liblldCommon error handler, a link dependency is added to the liblldDriver library. Test Plan: 1. check-lld 2. Invoke `ld64.lld -r` in a terminal that supports color output. Confirm that "ld64.lld: error: -arch not specified and could not be inferred" is output, and that the "error:" is colored red! Reviewers: ruiu, smeenai Reviewed By: ruiu Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D47998 llvm-svn: 334466
* Move new lld's code to Common subdirectory.Rui Ueyama2017-10-021-1/+1
| | | | | | | | | | New lld's files are spread under lib subdirectory, and it isn't easy to find which files are actually maintained. This patch moves maintained files to Common subdirectory. Differential Revision: https://reviews.llvm.org/D37645 llvm-svn: 314719
* Move Object format code to lib/BinaryFormat.Zachary Turner2017-06-071-1/+1
| | | | | | | | | | | | This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 llvm-svn: 304864
* Remove unnecessary llvm/Config/config.h includesMichal Gorny2016-12-141-1/+0
| | | | | | | | | | | | | | | | | | Remove the includes of <llvm/Config/config.h> private LLVM header. The relevant files seem not to use any definitions from that file, and it is not available when building against installed LLVM. The use in lib/ReaderWriter/MachO/MachOLinkingContext.cpp originates from rL218718, and the use in ELF/Strings.cpp from rL274804 (where it was moved from Symbols.cpp). In both cases, they were added as a part of demangling support, and they provided HAVE_CXXABI_H. Since we are now using the LLVM demangler library instead, the code was removed and the includes and no longer necessary. Differential Revision: https://reviews.llvm.org/D27757 llvm-svn: 289707
* Prevent at compile time converting from Error::success() to Expected<T>Mehdi Amini2016-11-111-2/+2
| | | | | | | | This would trigger an assertion at runtime otherwise. Differential Revision: https://reviews.llvm.org/D26482 llvm-svn: 286562
* [MachO] Factor out a fair amount of duplicated code. NFCI.Davide Italiano2016-09-121-26/+14
| | | | llvm-svn: 281260
* Use the demangler in llvm.Rafael Espindola2016-09-061-7/+2
| | | | llvm-svn: 280733
* Change when we choose to add an LC_LOAD_DYLIB to the final image.Pete Cooper2016-08-111-1/+4
| | | | | | | | | | | 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
* Fix off-by-one error in default currentVersion.Pete Cooper2016-08-111-2/+2
| | | | | | | | 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
* Change library search methods to return Optional instead of ErrorOr.Pete Cooper2016-03-311-13/+14
| | | | | | | | | | | | 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
* Convert file handle* methods to llvm::Error instead of std::error_code. NFC.Pete Cooper2016-03-301-8/+8
| | | | | | | This updates most of the file handling methods in the linking context and resolver to use the new API. llvm-svn: 264924
* Use owning pointers instead of raw pointers for Atom's to fix leaks.Pete Cooper2016-03-221-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | This is a re-commit of r264022 with a fix for MSVC. The issue there was that the code was running DefinedAtom::~Atom() for some value and instead needed to cast to Atom before running ~Atom. Original commit message follows. Currently each File contains an BumpPtrAllocator in which Atom's are allocated. Some Atom's contain data structures like std::vector which leak as we don't run ~Atom when they are BumpPtrAllocate'd. Now each File actually owns its Atom's using an OwningAtomPtr. This is analygous to std::unique_ptr and may be replaced by it if possible. An Atom can therefore only be owned by a single File, so the Resolver now moves them from one File to another. The MachOLinkingContext owns the File's and so clears all the Atom's in ~MachOLinkingContext, then delete's all the File's. This makes sure all Atom's have been destructed before any of the BumpPtrAllocator's in which they run have gone away. Should hopefully fix the remaining leaks. Will keep an eye on the bots to make sure. llvm-svn: 264067
* Revert "Use owning pointers instead of raw pointers for Atom's to fix leaks."Pete Cooper2016-03-221-13/+1
| | | | | | | | | | | | This reverts commit r264022. This breaks the Window's bots which don't like that i'm calling ~Atom when the this pointer is a sublcass of Atom. Reverting for now until I try find a better fix. I tried using std::unique_ptr with a custom deleter as a quick fix, but it didn't work well in the YAML parser. llvm-svn: 264023
* Use owning pointers instead of raw pointers for Atom's to fix leaks.Pete Cooper2016-03-221-1/+13
| | | | | | | | | | | | | | | | | | | | Currently each File contains an BumpPtrAllocator in which Atom's are allocated. Some Atom's contain data structures like std::vector which leak as we don't run ~Atom when they are BumpPtrAllocate'd. Now each File actually owns its Atom's using an OwningAtomPtr. This is analygous to std::unique_ptr and may be replaced by it if possible. An Atom can therefore only be owned by a single File, so the Resolver now moves them from one File to another. The MachOLinkingContext owns the File's and so clears all the Atom's in ~MachOLinkingContext, then delete's all the File's. This makes sure all Atom's have been destructed before any of the BumpPtrAllocator's in which they run have gone away. Should hopefully fix the remaining leaks. Will keep an eye on the bots to make sure. llvm-svn: 264022
* Use C++11 initializers for data members.Rui Ueyama2016-03-021-11/+1
| | | | | | http://reviews.llvm.org/D17793 llvm-svn: 262501
* Silence MSVC warning about falling off the end of a function after a fully ↵Reid Kleckner2016-02-101-0/+1
| | | | | | covered switch llvm-svn: 260417
* Use unsigned long long instead of uint64_t to appease botsPete Cooper2016-02-041-1/+1
| | | | llvm-svn: 259748
* Add support for the source_version cmdline option.Pete Cooper2016-02-041-0/+29
| | | | | | | | | This is of the form A.B.C.D.E and to match ld64's behaviour, is always output to files, even when the version is 0. rdar://problem/24472630 llvm-svn: 259746
* Default to an unknown OS instead of MacOSX.Pete Cooper2016-02-041-18/+24
| | | | | | | | | | | | Defaulting to unknown matches ld64, but it also makes sure that all of our code can handle not knowing the platform. For example, a later commit will add support for version min load commands with an unknown platform, which is a feature supported by ld64. No test case here. The next commit will have one with the version min code that needed this patch. llvm-svn: 259739
* Add support for export_dynamic cmdline option and behaviour.Pete Cooper2016-01-221-2/+4
| | | | | | | | | | | This option matches the behaviour of ld64, that is it prevents globals from being dead stripped in executables and dylibs. Reviewed by Lang Hames Differential Revision: http://reviews.llvm.org/D16026 llvm-svn: 258554
* Add an ObjCPass to the MachO linker.Pete Cooper2016-01-191-0/+10
| | | | | | | | | This pass currently emits an objc image info section if one is required. This section contains the aggregated version and flags for all of the input files. llvm-svn: 258197
* Set the objc constraint on the context based on the parsed files.Pete Cooper2016-01-191-0/+35
| | | | | | | | | | | | Like arch, os, etc, when we know we are going to use a file, we check that the file has compatible objc constraints to the context, throw appropriate errors where that is not the case, and hopefully set the objc constraints on the context for use later. Added 2 tests to ensure that we don't have incompatibilities between host and simulator code as both will get x86 based architectures. llvm-svn: 258173
* Cache the objc image info constraints in file.Pete Cooper2016-01-191-5/+4
| | | | | | | | | | Image info flags describe the objc constraint which is GC/retain/release/etc. These need to be parsed and stored in the file so that we can do error checking. That will come in a later commit. llvm-svn: 258160
* Add checking of differing swift versions in input files.Pete Cooper2016-01-161-0/+11
| | | | | | | Swift versions are part of the objc image info section, and must match for all files linked which actually have an image info section llvm-svn: 257964
* Check for mismatched arch and OS when linking MachO files.Pete Cooper2016-01-141-0/+24
| | | | | | | | | | | | This patch makes use of the handleLoadedFile hook added in r257814. That method is used to check the arch and the OS of the files we are linking against the arch and OS on the context. The first test to use this ensures that we do not try to combine i386 Mac OS code with i386 simulator code. llvm-svn: 257837
* Add handleLoadedFile hook to the context.Pete Cooper2016-01-141-0/+4
| | | | | | | | | | | | | | This is called from the resolver on each file we decide we actually want to use. Future commits will make use of this to extract useful information from the files and do error checking against the context. For example, ensure that files are the same arch as each other. Reviewed by Lang Hames. Differential Revision: http://reviews.llvm.org/D16093 llvm-svn: 257814
* [lld][Darwin] Add support for the -sectcreate option.Lang Hames2015-10-241-0/+15
| | | | llvm-svn: 251183
* [LLD] Fix Clang-tidy modernize-use-nullptr warnings; other minor cleanups.Rui Ueyama2015-10-021-16/+1
| | | | | | Patch from Eugene Zelenko! llvm-svn: 249111
* [lld][MachO] Fix a think-o to get the twolevel/dynamic_lookup test passing.Lang Hames2015-09-281-6/+4
| | | | llvm-svn: 248736
* [lld][MachO] Initial implementation of -flat_namespace and -undefined.Lang Hames2015-09-281-1/+13
| | | | | | | | | This is a basic initial implementation of the -flat_namespace and -undefined options for LLD-darwin. It ignores several subtlties, but the result is close enough that we can now link LLVM (but not clang) on Darwin and pass all regression tests. llvm-svn: 248732
* [LLD][MachO] Fix a FIXME: Subtract base address from atom address when buildingLang Hames2015-09-211-0/+3
| | | | | | export trie. llvm-svn: 248217
* [lld] Add MachO thread-local storage support.Lang Hames2015-06-231-0/+13
| | | | | | | | This allows LLD to correctly link MachO objects that use thread-local storage. Differential Revision: http://reviews.llvm.org/D10578 llvm-svn: 240454
* [lld] Make the MachO -stack_size default '0', add a test case.Lang Hames2015-05-221-1/+1
| | | | | | Addresses some review comments for r237841. llvm-svn: 237979
* [LLD] Add support for the -stack_size option to Darwin ld.Lang Hames2015-05-201-3/+3
| | | | llvm-svn: 237841
* [LLD] Add a mutex to prevent concurrent modification of the dylib maps inLang Hames2015-05-131-0/+1
| | | | | | MachOLinkingContext. llvm-svn: 237217
* Use MemoryBufferRef instead of MemoryBuffer&. NFC.Rafael Espindola2015-04-271-3/+2
| | | | | | This just reduces the noise from another patch. llvm-svn: 235933
* Simplify now that there is only one file. NFC.Rafael Espindola2015-04-241-6/+4
| | | | llvm-svn: 235747
* Return ErrorOr<std::unique_ptr<File>>. NFC.Rafael Espindola2015-04-241-3/+4
| | | | llvm-svn: 235744
* Delete unnecessary generality in loadFile.Rafael Espindola2015-04-241-2/+4
| | | | | | | | | | | | | loadFile could load mulitple files just because yaml has a feature for putting multiple documents in one file. Designing a linker around what yaml can do seems like a bad idea to me. This patch changes it to read a single file. There are further improvements to be done to the api and they will follow shortly. llvm-svn: 235724
* Replace the `createImplicitFiles` method return type with `void`Simon Atanasyan2015-04-061-2/+2
| | | | | | | All instances of the `createImplicitFiles` always return `true` and this return value is used nowhere. llvm-svn: 234205
* Rename align2 -> align.Rui Ueyama2015-03-261-4/+4
| | | | | | I believe "2" stands for log2. Just "align" would be appropriate now. llvm-svn: 233248
OpenPOWER on IntegriCloud