summaryrefslogtreecommitdiffstats
path: root/lld/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* [lld][MachO] Clean up some unnecessarily verbose code. NFC.Lang Hames2016-04-061-4/+1
| | | | | | Suggested by Dave Blaikie in review of r265447. Thanks Dave! llvm-svn: 265566
* [lld][MachO] Check Expected<T> for error prior to destruction.Lang Hames2016-04-051-15/+17
| | | | | | This should fix the failures on the LLD bots caused by r265446. llvm-svn: 265477
* Revert "Remove useless unreachable. Switch coverage already gives us this. ↵Pete Cooper2016-03-311-0/+1
| | | | | | | | | | | | 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
* Remove unused variants of make_dynamic_error_code. NFC.Pete Cooper2016-03-311-8/+0
| | | | | | | | | | | | | | | | | 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
* Use Expected<T> instead of ErrorOr<T>in yaml reader. NFCPete Cooper2016-03-312-4/+5
| | | | llvm-svn: 264981
* Change library search methods to return Optional instead of ErrorOr.Pete Cooper2016-03-312-18/+21
| | | | | | | | | | | | 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
* Fix a bunch more of -Wpessimizing-move issues.Pete Cooper2016-03-311-4/+4
| | | | | | Thanks to Rui for pointing out this warning was firing. llvm-svn: 264978
* Fix a bunch of -Wpessimizing-move issues.Pete Cooper2016-03-313-4/+4
| | | | | | Thanks to Rui for pointing out this warning was firing. llvm-svn: 264977
* Convert a few macho reader/writer helpers to new error handling. NFC.Pete Cooper2016-03-312-30/+34
| | | | | | | | 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
* Convert readBinary to llvm::Error. NFCPete Cooper2016-03-303-11/+12
| | | | llvm-svn: 264973
* Convert normalized file to atoms methods to new error handling. NFC.Pete Cooper2016-03-304-119/+128
| | | | | | | This converts almost all of the error handling in atom creation to llvm::Error instead of std::error_code. llvm-svn: 264968
* Convert lld file writing to llvm::Error. NFC.Pete Cooper2016-03-307-41/+44
| | | | | | | This converts the writeFile method, as well as some of the ones it calls in the normalized binary file writer and yaml writer. llvm-svn: 264961
* Fix -Wpessimizing-move warnings.Rui Ueyama2016-03-301-2/+2
| | | | llvm-svn: 264951
* Remove useless unreachable. Switch coverage already gives us this. NFCPete Cooper2016-03-301-1/+0
| | | | llvm-svn: 264945
* Convert file handle* methods to llvm::Error instead of std::error_code. NFC.Pete Cooper2016-03-302-30/+39
| | | | | | | This updates most of the file handling methods in the linking context and resolver to use the new API. llvm-svn: 264924
* Change loadFileList to llvm::Error. NFCPete Cooper2016-03-301-14/+16
| | | | llvm-svn: 264921
* Convert lld Pass::runOnFile to llvm::Error from std::error_code. NFC.Pete Cooper2016-03-309-23/+27
| | | | | | | Pretty mechanical change here. Just replacing all the std::error_code() with llvm::Error() and make_dynamic_error_code with make_error<GenericError> llvm-svn: 264917
* Change getReferenceInfo/getPairReferenceInfo to use new Error handling. NFC.Pete Cooper2016-03-307-215/+217
| | | | | | | | | | | | Adds a GenericError class to lld/Core which can carry a string. This is analygous to the dynamic_error we currently use in lld/Core. Use this GenericError instead of make_dynamic_error_code. Also, provide an implemention of GenericError::convertToErrorCode which for now converts it in to the dynamic_error_code we used to have. This will go away once all the APIs are converted. llvm-svn: 264910
* Remove dead flags.Rui Ueyama2016-03-285-99/+19
| | | | | | | | | | | searchArchivesToOverrideTentativeDefinitions and searchSharedLibrariesToOverrideTentativeDefinitions are always false. For the dead flags, we have a fairly large amount of code which is never be executed. http://reviews.llvm.org/D17791 llvm-svn: 264653
* Use None to construct an empty ArrayRef. NFC.Pete Cooper2016-03-241-1/+1
| | | | | | Suggested by David Blaikie in response to r264234. llvm-svn: 264311
* Avoid UB when creating empty atoms. NFC.Pete Cooper2016-03-241-0/+2
| | | | | | | | | The stack-size.yaml test had an empty atom content array. This is legal, but asking a BumpPtrAllocator for 0 sized data may not be legal. Instead just avoid requesting any data when we can just return an empty ArrayRef instead. llvm-svn: 264234
* Avoid UB deref of nullptr to reference. NFC.Pete Cooper2016-03-241-0/+5
| | | | | | | | | Its possible for file to have no entry atom which means that there is no atom to check for being a thumb function. Instead just skip the thumb check and set the entry address to 0, which matches the current behaviour of getting a default initialised int from a map. llvm-svn: 264233
* Use a memcpy to avoid unaligned store UB.Pete Cooper2016-03-241-6/+9
| | | | | | | On a 32-bit output, we may write LC_MAIN (which contains a uint64_t) to an unaligned address. This changes it to use a memcpy instead which is UB safe. llvm-svn: 264232
* Use unaligned read to fix UB. NFC.Pete Cooper2016-03-241-3/+4
| | | | | | | | | | | We were casting a potentially unaligned pointer to uint32_t and dereferencing. As the pointer ultimately comes from the object file, there's no way to guarantee alignment, so use the little32_t read instead. Also, little32_t knows about endianness, so in theory this may have broken on big endian machines. llvm-svn: 264231
* Parsed alignment should be a power of 2.Pete Cooper2016-03-242-2/+28
| | | | | | | | | | The .o path always makes sure to store a power of 2 value in the Section alignment. However, the YAML code didn't verify this. Added verification and updated all the tests which had a 3 but meant to have 2^3. llvm-svn: 264228
* Fix more cases of UB from allocating 0 sized data. NFC.Pete Cooper2016-03-236-17/+25
| | | | | | | | | | | | The size of a section can be zero, even when it contains atoms, so long as all of the atoms are also size 0. In this case we were allocating space for a 0 sized buffer. Changed this to only allocate when we need the space, but also cleaned up all the code to use MutableArrayRef instead of uint8_t* so its much much safer as we get bounds checking on all of our section creation logic. llvm-svn: 264204
* Use a memcpy to avoid unaligned store UB.Pete Cooper2016-03-231-5/+8
| | | | | | | On a 32-bit output, we may write LC_SOURCE_VERSION (which contains a uint64_t) to an unaligned address. This changes it to use a memcpy instead which is UB safe. llvm-svn: 264202
* Add the needed lld change for r264187 in llvm.Kevin Enderby2016-03-231-1/+4
| | | | | | | Sorry had this fixed in my check out but failed mention it in my commit message for r264187. llvm-svn: 264188
* Copy MachO struct to temporary to avoid unaligned load UB.Pete Cooper2016-03-231-4/+4
| | | | | | | We were already copying this data to a temporary for endian swaps. Now we just always copy it, but still only do the endian swaps when needed. llvm-svn: 264172
* Move empty atom check to target independent code. NFC.Pete Cooper2016-03-222-5/+5
| | | | | | | | | | Turns out that checking only x86 for empty atoms to fix UBSan then requires the same code in the other targets too. Better to just check this in the main run loop instead of in each target. Should be NFC, other than fixing UBSan failures. llvm-svn: 264116
* Avoid memcpy from nullptr. NFC.Pete Cooper2016-03-221-0/+5
| | | | | | | | | | This was caught by the UBSan bot. When the atom has no size, we would issue a memcpy with size0 and a nullptr for the source. Also, this code should never have references inside an empty atom so add an assert for that while we're here. llvm-svn: 264115
* Don't memcpy from a null source. Found by UBSanPete Cooper2016-03-221-0/+2
| | | | llvm-svn: 264114
* More MSVC bot appeasement. Explicitly define rvalue methods on SortKey.Pete Cooper2016-03-221-0/+19
| | | | | | | | | | | | | | OwningAtomPtr does not have OwningAtomPtr(OwningAtomPtr&) or the equivalent operator= as we only want to use rvalue references in it. SortKey didn't like this on MSVC as it was synthesizing SortKey(SortKey&) and trying to use the OwningAtomPtr(OwningAtomPtr&) method which was private an unimplemented. Now we explicitly have the methods on SortKey so hopefully the bot will be happier. llvm-svn: 264077
* Use owning pointers instead of raw pointers for Atom's to fix leaks.Pete Cooper2016-03-2219-159/+319
| | | | | | | | | | | | | | | | | | | | | | | | 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
* DenseMap resize() is now named reserved(), adapt the call sitesMehdi Amini2016-03-221-2/+2
| | | | | From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 264028
* Revert "Use owning pointers instead of raw pointers for Atom's to fix leaks."Pete Cooper2016-03-2219-319/+159
| | | | | | | | | | | | 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-2219-159/+319
| | | | | | | | | | | | | | | | | | | | 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
* Move ownership of Pass File's to the MachoLinkingContext.Pete Cooper2016-03-216-12/+14
| | | | | | | | | In trying to fix the leaks in the MachO lld codebase, we need to have a better model for file and atom ownership. Having the context own everything seems like the simplest model, so change all the passes to allocate File's on the context instead of owning files as a member. llvm-svn: 264004
* Always pass an allocator to YAMLTraits.Pete Cooper2016-03-171-4/+9
| | | | | | | | | | | The YAML traits new's when not passed an allocator to parse data. For atom types, this is a leak as we don't destruct atoms. For the File here, we do actually destruct File's so that single case of not using an allocator will be fine. Should fix a bunch more leaks. llvm-svn: 263680
* Use allocator in YAML code to avoid leaking atom content.Pete Cooper2016-03-161-4/+6
| | | | | | | | | | In lld we allocate atoms on an allocator and so don't run their destructors. This means we also shouldn't allocate memory inside them without that also being on an allocator. Reviewed by Lang Hames and Rafael Espindola. llvm-svn: 263677
* Fix EHFrame processing to add implicit references when needed.Pete Cooper2016-03-156-32/+252
| | | | | | | | | | | | | | | | | The current code for processCIE and processFDE returns out if it sees any references. The problem with this is that some references could be explicit in the binary, while others are implicit as they can be inferred from the content of the EHFrame itself. This change walks the references we have against the references we need, and verifies that all explicit references are in the correct place, and generates any missing implicit ones. Reviewed by Lang Hames and Nick Kledzik. Differential Revision: http://reviews.llvm.org/D15439 llvm-svn: 263590
* Simplify string operations. NFC.Rui Ueyama2016-03-031-16/+9
| | | | llvm-svn: 262569
* Merge DarwinLdDriver and Driver.Rui Ueyama2016-03-023-118/+83
| | | | | | | | | | | Now that DarwinLdDriver is the only derived class of Driver. This patch merges them and actually removed the class because they can now just be non-member functions. This change simplifies a common header, Driver.h. http://reviews.llvm.org/D17788 llvm-svn: 262502
* Use C++11 initializers for data members.Rui Ueyama2016-03-021-11/+1
| | | | | | http://reviews.llvm.org/D17793 llvm-svn: 262501
* Use C++11 initializers for data members.Rui Ueyama2016-03-021-7/+1
| | | | llvm-svn: 262447
* Remove more dead code.Rui Ueyama2016-03-021-1/+1
| | | | llvm-svn: 262445
* Remove default implementations that are always overridden by subclasses.Rui Ueyama2016-03-021-7/+0
| | | | llvm-svn: 262444
* Remove more dead code.Rui Ueyama2016-03-021-1/+0
| | | | llvm-svn: 262443
* Remove dead code.Rui Ueyama2016-03-021-2/+0
| | | | llvm-svn: 262436
* Remove remaining files of Core.Rui Ueyama2016-03-022-51/+0
| | | | llvm-svn: 262435
OpenPOWER on IntegriCloud