summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [lld] Fix trivial typos in commentsKazuaki Ishizaki2020-01-061-4/+4
| | | | | | Reviewed By: ruiu, MaskRay Differential Revision: https://reviews.llvm.org/D72196
* [MachO] Fix detecting malformed DWARF.Igor Kudrin2019-12-171-2/+2
| | | | | | | This fixes an invalid constant used to detect the reserved range when reading the compilation unit header. See also: D64622 and D65039. Differential Revision: https://reviews.llvm.org/D71546
* 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-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-4/+4
| | | | | | | | | | 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
* [MachO] Update LLD to use 64-bit offsets with DataExtractor (3/5)Igor Kudrin2019-08-061-6/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D65639 llvm-svn: 368032
* 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
* [lld] Update uses of DEBUG macro to LLVM_DEBUG.Nicola Zaghen2018-05-151-2/+2
| | | | | | | | | | | The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM Differential Revision: https://reviews.llvm.org/D44977 llvm-svn: 332351
* Fix build broken by llvm r327486Pavel Labath2018-03-141-1/+1
| | | | | | llvm::DWARFFormParams moved to llvm::dwarf::FormParams. llvm-svn: 327489
* 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
* Tweak to match change in LLVM API, in r306315.Paul Robinson2017-06-261-2/+2
| | | | llvm-svn: 306316
* Move Object format code to lib/BinaryFormat.Zachary Turner2017-06-071-3/+3
| | | | | | | | | | | | 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
* Fix code to deal with recent LLVM changes.Greg Clayton2016-11-111-2/+5
| | | | | | https://reviews.llvm.org/D26526 llvm-svn: 286598
* Prevent at compile time converting from Error::success() to Expected<T>Mehdi Amini2016-11-111-16/+16
| | | | | | | | This would trigger an assertion at runtime otherwise. Differential Revision: https://reviews.llvm.org/D26482 llvm-svn: 286562
* Fix build breakage on buildbots that was due to 285309.Greg Clayton2016-10-271-3/+4
| | | | llvm-svn: 285321
* [lld][MachO] Replace some std::string with char* buffers to eliminate mem leaks.Lang Hames2016-07-291-4/+4
| | | | | | | | | | | 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
* [lld][MachO] Remove some debugging output code that was mistakenly left in inLang Hames2016-07-281-16/+0
| | | | | | r276935. llvm-svn: 276944
* [lld][MachO] Re-apply r276921 with fix - initialize strings for debug stringLang Hames2016-07-271-12/+322
| | | | | | copies. llvm-svn: 276935
* [lld][MachO] Temporarily revert r276921 - it's causing bot-failures on Linux.Lang Hames2016-07-271-321/+12
| | | | llvm-svn: 276928
* [lld][MachO] Add debug info support for MachO.Lang Hames2016-07-271-12/+321
| | | | | | | | | 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
* Fix a bunch of -Wpessimizing-move issues.Pete Cooper2016-03-311-1/+1
| | | | | | Thanks to Rui for pointing out this warning was firing. llvm-svn: 264977
* Convert normalized file to atoms methods to new error handling. NFC.Pete Cooper2016-03-301-105/+110
| | | | | | | This converts almost all of the error handling in atom creation to llvm::Error instead of std::error_code. llvm-svn: 264968
* Change getReferenceInfo/getPairReferenceInfo to use new Error handling. NFC.Pete Cooper2016-03-301-62/+68
| | | | | | | | | | | | 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
* Fix EHFrame processing to add implicit references when needed.Pete Cooper2016-03-151-30/+199
| | | | | | | | | | | | | | | | | 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
* Generate version min load commands when the platform is unknown.Pete Cooper2016-02-041-0/+2
| | | | | | | | | | | In the case where we are emitting to an object file, the platform is possibly unknown, and the source object files contained load commands for version min, we can take the maximum of those min versions and emit in in the output object file. This test also tests r259739. llvm-svn: 259742
* Move SimpleDefinedAtom::addReference to DefinedAtom.Pete Cooper2016-02-011-16/+18
| | | | | | | | | | | | Most of the other methods to access Reference's were on DefinedAtom so this just keeps them all together. This will be used in a future patch in ObjCPass which needs to add new references. The method is virtual because we may add references to different data structures depending on whether we parsed a macho file or yaml. llvm-svn: 259436
* Atomize the ObjC category list section.Pete Cooper2016-02-011-0/+3
| | | | | | | | | __DATA, __objc_catlist contains a list of pointers to categories. We want to atomize it so that the ObjC pass can later optimize and remove categories. That will be a later patch. llvm-svn: 259386
* Add an ObjCPass to the MachO linker.Pete Cooper2016-01-191-31/+27
| | | | | | | | | 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
* Cache the objc image info constraints in file.Pete Cooper2016-01-191-6/+7
| | | | | | | | | | 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
* Only emit files with subsections_via_symbols if all inputs had that set.Pete Cooper2016-01-161-0/+1
| | | | | | | | | | | | When generating a relocatable file, its only valid to set this flag if all of the inputs also had the flag. Otherwise we may atomize incorrectly when we link the relocatable file again. Reviewed by Lang Hames. Differential Revision: http://reviews.llvm.org/D16018 llvm-svn: 257976
* Give error on binaries containing GC objc image infos.Pete Cooper2016-01-161-4/+12
| | | | | | | | The image info struct contains flags for what kind of GC/retain/release is required. Give an error if we parse GC flags as these are unsupported. llvm-svn: 257974
* Add checking of differing swift versions in input files.Pete Cooper2016-01-161-0/+3
| | | | | | | 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 that the objc image info version is exactly 0Pete Cooper2016-01-151-0/+8
| | | | llvm-svn: 257953
* Error check the size of the __objc_imageinfo sectionPete Cooper2016-01-141-0/+44
| | | | llvm-svn: 257841
* Check for mismatched arch and OS when linking MachO files.Pete Cooper2016-01-141-0/+4
| | | | | | | | | | | | 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
* Don't emit relocs for the __eh_frame section as they can be implicit.Pete Cooper2016-01-071-1/+5
| | | | | | | | | | | | | | The __eh_frame section contains relocations which can always be implicitly generated. This patch tracks whether sections have only implicitly relocations and skips emitting them to the object file if that is the case. The test case here ensures that this is the case for __eh_frame sections. Reviewed by Lang Hames. http://reviews.llvm.org/D15594 llvm-svn: 257099
* Add more debugging output to MachO lld. NFC.Pete Cooper2015-12-161-0/+15
| | | | | | | In debug builds there's now a dump method on Section and improved printing of atoms. llvm-svn: 255826
* [lld][MachO] Recognize __thread_bss sections as zero-fill and set all theLang Hames2015-12-111-1/+3
| | | | | | | | | appropriate bits. This fixes the remaining clang regression test failures when linking clang with lld on Darwin. llvm-svn: 255390
* Verify that macho-o delta64 relocs have the same offset.Pete Cooper2015-12-101-21/+47
| | | | | | | | | | The delta64 relocation is represented as the pair ARM64_RELOC_SUBTRACTOR and ARM64_RELOC_UNSIGNED. Those should always have the same offset, so this adds a check and tests to ensure this is the case. Also updated the error printing in this case to shows both relocs when erroring on pair. llvm-svn: 255274
* [lld] Add MachO thread-local storage support.Lang Hames2015-06-231-0/+3
| | | | | | | | 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 sure MachO FDEs read their augmentation data strings from the rightLang Hames2015-05-161-18/+28
| | | | | | CIE, not just the most recently encountered one. llvm-svn: 237491
* [LLD] Properly relocate the LSDA field of MachO eh-frames.Lang Hames2015-05-131-40/+153
| | | | | | | Previously the LSDA field was not being relocated during linking, leading to failures for some EH tests. llvm-svn: 237222
* Define make_dynamic_error_code(const char *).Rui Ueyama2015-04-141-3/+3
| | | | | | | | | | | | The function took either StringRef or Twine. Since string literals are ambiguous when resolving the overloading, many code calls used this function with explicit type conversion. That led awkward code like make_dynamic_error_code(Twine("Error occurred")). This patch adds a function definition for string literals, so that you can directly call the function with literals. llvm-svn: 234841
* Use alignment values everywhere instead of log2.Rui Ueyama2015-03-261-1/+2
| | | | | | | | This patch defines implicit conversion between integers and PowerOf2 instances, so uses of the classes is now implicit and look like regular integers. Now we are ready to remove the scaffolding. llvm-svn: 233245
* [Core,MachO,Test] Remove trailing whitespace.Shankar Easwaran2015-02-221-19/+19
| | | | llvm-svn: 230192
* Separate file parsing from File's constructors.Rui Ueyama2014-12-121-19/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a second patch for InputGraph cleanup. Sorry about the size of the patch, but what I did in this patch is basically moving code from constructor to a new method, parse(), so the amount of new code is small. This has no change in functionality. We've discussed the issue that we have too many classes to represent a concept of "file". We have File subclasses that represent files read from disk. In addition to that, we have bunch of InputElement subclasses (that are part of InputGraph) that represent command line arguments for input file names. InputElement is a wrapper for File. InputElement has parseFile method. The method instantiates a File. The File's constructor reads a file from disk and parses that. Because parseFile method is called from multiple worker threads, file parsing is processed in parallel. In other words, one reason why we needed the wrapper classes is because a File would start reading a file as soon as it is instantiated. So, the reason why we have too many classes here is at least partly because of the design flaw of File class. Just like threads in a good threading library, we need to separate instantiation from "start" method, so that we can instantiate File objects when we need them (which should be very fast because it involves only one mmap() and no real file IO) and use them directly instead of the wrapper classes. Later, we call parse() on each file in parallel to let them do actual file IO. In this design, we can eliminate a reason to have the wrapper classes. In order to minimize the size of the patch, I didn't go so far as to replace the wrapper classes with File classes. The wrapper classes are still there. In this patch, we call parse() immediately after instantiating a File, so this really has no change in functionality. Eventually the call of parse() should be moved to Driver::link(). That'll be done in another patch. llvm-svn: 224102
* [mach-o] propagate dylib version numbersNick Kledzik2014-11-191-1/+3
| | | | | | | | | | | | | | Mach-o does not use a simple SO_NEEDED to track dependent dylibs. Instead, the linker copies four things from each dylib to each client: the runtime path (aka "install name"), the build time, current version (dylib build number), and compatibility version The build time is no longer used (it cause every rebuild of a dylib to be different). The compatibility version is usually just 1.0 and never changes, or the dylib becomes incompatible. This patch copies that information into the NormalizedMachO format and propagates it to clients. llvm-svn: 222300
* [mach-o] remove extra leading underscore on __bss and __gotNick Kledzik2014-11-061-2/+2
| | | | llvm-svn: 221425
* [mach-o] Add support for interposing tuples sectionNick Kledzik2014-11-061-0/+2
| | | | | | | | | | Darwin uses two-level-namespace lookup for symbols which means the static linker records where each symbol must be found at runtime. Thus defining a symbol in a dylib loaded earlier will not effect where symbols needed by later dylibs will be found. Instead overriding is done through a section of type S_INTERPOSING which contains tuples of <interposer, interposee>. llvm-svn: 221421
* MachO: Remove an unused variable from processSectionDavid Majnemer2014-11-051-2/+0
| | | | | | | | | The local variable `cfi` became dead in r220730 when it's use was obviated; it was replaced with a call to read32. No functionality change intended. llvm-svn: 221412
OpenPOWER on IntegriCloud