summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/MachO/File.h
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
* 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
* Change when we choose to add an LC_LOAD_DYLIB to the final image.Pete Cooper2016-08-111-1/+1
| | | | | | | | | | | 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
* [lld][MachO] Re-apply r276921 with fix - initialize strings for debug stringLang Hames2016-07-271-1/+15
| | | | | | copies. llvm-svn: 276935
* [lld][MachO] Temporarily revert r276921 - it's causing bot-failures on Linux.Lang Hames2016-07-271-15/+1
| | | | llvm-svn: 276928
* [lld][MachO] Add debug info support for MachO.Lang Hames2016-07-271-1/+15
| | | | | | | | | 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
* [lld][MachO] Remove stray comment.Lang Hames2016-06-271-2/+0
| | | | llvm-svn: 273917
* [lld][MachO] Add support for x86-64 negDelta64 references and fix negDelta32.Lang Hames2016-06-251-0/+2
| | | | | | | | | | 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
* Add missing header (NFC)Mehdi Amini2016-04-181-0/+1
| | | | | From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266596
* Convert readBinary to llvm::Error. NFCPete Cooper2016-03-301-4/+4
| | | | llvm-svn: 264973
* Convert normalized file to atoms methods to new error handling. NFC.Pete Cooper2016-03-301-6/+4
| | | | | | | This converts almost all of the error handling in atom creation to llvm::Error instead of std::error_code. llvm-svn: 264968
* Remove dead flags.Rui Ueyama2016-03-281-2/+1
| | | | | | | | | | | 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 owning pointers instead of raw pointers for Atom's to fix leaks.Pete Cooper2016-03-221-10/+16
| | | | | | | | | | | | | | | | | | | | | | | | 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-16/+10
| | | | | | | | | | | | 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-10/+16
| | | | | | | | | | | | | | | | | | | | 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
* Generate version min load commands when the platform is unknown.Pete Cooper2016-02-041-0/+12
| | | | | | | | | | | 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
* MachoFile should default to using subsections_via_symbols.Pete Cooper2016-02-011-1/+1
| | | | | | | | | | | | When we parse a MachoFile, we set a number of members from the parsed file, for example, subsectionsViaSymbols. However, a number of passes, such as ObjCPass, create local copies of MachoFile and don't get the benefit of setting flags and other fields in the parser. Instead we can just give a more sensible default as the parser will definitely get the correct value from the file anyway. llvm-svn: 259426
* Initialize member variable.Pete Cooper2016-01-251-1/+1
| | | | | | Found by Rafael using valgrind in https://llvm.org/bugs/show_bug.cgi?id=21466. llvm-svn: 258718
* Cache the objc image info constraints in file.Pete Cooper2016-01-191-0/+9
| | | | | | | | | | 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/+6
| | | | | | | | | | | | 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
* Add checking of differing swift versions in input files.Pete Cooper2016-01-161-0/+4
| | | | | | | 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/+8
| | | | | | | | | | | | 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 File::kind's for all subclasses of File.Pete Cooper2016-01-141-2/+8
| | | | | | | | | | | | This is to enable isa<> support for any files which need it. It will be used in an upcoming patch to differentiate MachOFile from other implicitly generated files. Reviewed by Lang Hames. Differential Revision: http://reviews.llvm.org/D16103 llvm-svn: 257830
* [lld][MachO] Recognize __thread_bss sections as zero-fill and set all theLang Hames2015-12-111-2/+15
| | | | | | | | | appropriate bits. This fixes the remaining clang regression test failures when linking clang with lld on Darwin. llvm-svn: 255390
* Fix Clang-tidy modernize-use-auto warnings, other minor fixes.Eugene Zelenko2015-11-101-10/+7
| | | | | | Differential revision: http://reviews.llvm.org/D14553 llvm-svn: 252661
* Use alignment values everywhere instead of log2.Rui Ueyama2015-03-261-3/+3
| | | | | | | | 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
* Remove implicit constructor and operator int from PowerOf2.Rui Ueyama2015-03-261-3/+3
| | | | | | | | | | This patch is to make instantiation and conversion to an integer explicit, so that we can mechanically replace all occurrences of the class with integer in the next step. Now get() returns an alignment value rather than its log2 value. llvm-svn: 233242
* [Core,MachO,Test] Remove trailing whitespace.Shankar Easwaran2015-02-221-7/+7
| | | | llvm-svn: 230192
* Move common code to base class.Rui Ueyama2015-01-161-20/+0
| | | | llvm-svn: 226329
* [ELF] Add --as-needed.Rui Ueyama2015-01-161-0/+2
| | | | | | | | | | | | The previous default behavior of LLD is --as-needed. LLD linked against a DSO only if the DSO file was actually used to link an executable (i.e. at least one symbol was resolved using the shared library file.) In this patch I added a boolean flag to FileNode for --as-needed. I also added an accessor to DSO name to shared library file class. llvm-svn: 226274
* Protect doParse() because that's not a public interface.Rui Ueyama2014-12-151-0/+1
| | | | llvm-svn: 224235
* Make File always take the ownership of a MemoryBuffer.Rui Ueyama2014-12-121-15/+12
| | | | | | | | | | | | | | The documentation of parseFile() said that "the resulting File object may take ownership of the MemoryBuffer." So, whether or not the ownership of a MemoryBuffer would be taken was not clear. A FileNode (a subclass of InputElement, which is being deprecated) keeps the ownership if a File doesn't take it. This patch makes File always take the ownership of a buffer. Buffers lifespan is not always the same as File instances. Files are able to deallocate buffers after parsing the contents. llvm-svn: 224113
* Separate file parsing from File's constructors.Rui Ueyama2014-12-121-7/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Switch MachOFile and MachODylibFile to use BumpPtr in lld::FileNick Kledzik2014-12-051-28/+24
| | | | llvm-svn: 223529
* [mach-o] fix whitespaceNick Kledzik2014-11-201-3/+3
| | | | llvm-svn: 222457
* [mach-o] use reference with "auto" to prevent copiesNick Kledzik2014-11-201-3/+3
| | | | | | Patch by Jean-Daniel Dupas llvm-svn: 222455
* [mach-o] propagate dylib version numbersNick Kledzik2014-11-191-3/+11
| | | | | | | | | | | | | | 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
* Fix MSVC warning.Rui Ueyama2014-11-191-6/+9
| | | | | | | | | This patch fixes the following MSVC warning. warning C4334: '<<' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) llvm-svn: 222293
* [mach-o] extract atom alignment information from mach-o filesNick Kledzik2014-11-181-3/+10
| | | | llvm-svn: 222201
* Fix warnings about missing override.Rafael Espindola2014-11-031-1/+2
| | | | llvm-svn: 221165
* Sort include files according to convention.Shankar Easwaran2014-10-181-4/+1
| | | | llvm-svn: 220131
* [macho] Create references from __eh_frame FDEs to their function.Tim Northover2014-10-151-1/+14
| | | | | | | | | | | | | We'll also need references back to the CIE eventually, but for now making sure we can work out what an FDE is referring to is enough. The actual kind of reference needs to be different between architectures, probably because of MachO's chronic shortage of relocation types but I don't really want to know in case I find out something that distresses me even more. rdar://problem/18208653 llvm-svn: 219824
* [mach-o] support N_NO_DEAD_STRIP nlist.desc bitNick Kledzik2014-08-211-11/+14
| | | | | | | Mach-O symbols can have an attribute on them means their content should never be dead code stripped. This translates to deadStrip() == deadStripNever. llvm-svn: 216234
* [mach-o] Support re-exported dylibsNick Kledzik2014-08-131-20/+70
| | | | | | | | | | | | | | | | | | | | In general two-level namespace means each program records exactly which dylib each undefined (imported) symbol comes from. But, sometimes the implementor wants to hide the implementation dylib. For instance libSytem.dylib is the base dylib all Darwin programs must link with. A few years ago it was split up into two dozen dylibs by all are hidden behind libSystem.dylib which re-exports each sub-dylib. All clients still think libSystem.dylib is the implementor. To support this, the linker must load "indirect" dylibs and not just the "direct" dylibs specified on the command line. This is done in the createImplicitFiles() method after all command line specified files are loaded. Since an indirect dylib may have already been loaded as a direct dylib (or indirectly via a previous direct dylib), the MachOLinkingContext keeps a list of all loaded dylibs. With this change hello world can now be linked against the real OS or SDK. llvm-svn: 215605
* [mach-o] add initial support for modes in arm code.Nick Kledzik2014-07-231-0/+10
| | | | | | | | | This patch just supports marking ranges that are thumb code (vs arm code). Future patches will mark data and jump table ranges. The ranges are encoded as References with offsetInAtom being the start of the range and the target being the same atom. llvm-svn: 213712
* [mach-o] refactor KindHandler into ArchHandler and simplify passes.Nick Kledzik2014-07-161-2/+5
| | | | | | | | | | | All architecture specific handling is now done in the appropriate ArchHandler subclass. The StubsPass and GOTPass have been simplified. All architecture specific variations in stubs are now encoded in a table which is vended by the current ArchHandler. llvm-svn: 213187
* [mach-o] Add parsing of arm/thumb relocationsNick Kledzik2014-07-041-6/+7
| | | | | | | | | | This converts the very complicated mach-o arm relocations into the simple Reference Kinds in lld. The next patch will use the internal Reference kinds to fix up arm/thumb code. llvm-svn: 212306
* MachO: support atomization of dylibs.Tim Northover2014-06-301-0/+56
| | | | | | | For .dylib files, we refrain from actually creating any atoms until they're requested via the "exports" method. llvm-svn: 212027
* [mach-o] fix struct initialization to work with Windows compilerNick Kledzik2014-06-271-6/+14
| | | | llvm-svn: 211951
* [mach-o] refactor x86_64 relocation handling.Nick Kledzik2014-06-271-9/+71
| | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud