summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/MachO
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix the ELF shared library build targetsGreg Fitzgerald2015-01-232-2/+4
| | | | | | | | | | lldELF is used by each ELF backend. lldELF's ELFLinkingContext also held a reference to each backend, creating a link-time cycle. This patch moves the backend references to lldDriver. Differential Revision: http://reviews.llvm.org/D7119 llvm-svn: 226922
* Fix five of the shared library build targetsGreg Fitzgerald2015-01-212-3/+3
| | | | | | | | | | | | | | | | | | Before this patch there was a cyclic dependency between lldCore and lldReaderWriter. Only lldConfig could be built as a shared library. * Moved Reader and Writer base classes into lldCore. * The following shared libraries can now be built: lldCore lldYAML lldNative lldPasses lldReaderWriter Differential Revision: http://reviews.llvm.org/D7105 From: Greg Fitzgerald <garious@gmail.com> llvm-svn: 226732
* add_lld_library -> add_llvm_libraryGreg Fitzgerald2015-01-211-8/+5
| | | | | | | | | | | * Works better for shared libraries (sets PRIVATE instead of INTERFACE) * Fixes http://llvm.org/bugs/show_bug.cgi?id=22269 * Also, use build-target names instead of component names Differential Revision: http://reviews.llvm.org/D7074 From: Greg Fitzgerald <garious@gmail.com> llvm-svn: 226702
* Add LLVM_LINK_COMPONENTS for the shared object buildGreg Fitzgerald2015-01-161-0/+2
| | | | | | | Differential Revision: http://reviews.llvm.org/D7023 From: Greg Fitzgerald <garious@gmail.com> llvm-svn: 226346
* 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
* Simplify.Rui Ueyama2015-01-151-7/+5
| | | | llvm-svn: 226153
* Remove InputGraph and use std::vector<Node> instead.Rui Ueyama2015-01-151-2/+1
| | | | | | In total we have removed more than 1000 lines! llvm-svn: 226149
* Rename InputElement Node.Rui Ueyama2015-01-151-6/+6
| | | | | | | | | InputElement was named that because it's an element of an InputGraph. It's losing the origin because the InputGraph is now being removed. InputElement's subclass is FileNode, that naming inconsistency needed to be fixed. llvm-svn: 226147
* Remove InputGraph::size().Rui Ueyama2015-01-151-1/+1
| | | | llvm-svn: 226140
* Re-commit r225766, r225767, r225769, r225814, r225816, r225829, and r225832.Rui Ueyama2015-01-151-3/+1
| | | | | | | These changes depended on r225674 and had been rolled back in r225859. Because r225674 has been re-submitted, it's safe to re-submit them. llvm-svn: 226132
* Re-commit r225674: Convert other drivers to use WrapperNode.Rui Ueyama2015-01-153-18/+17
| | | | | | | | The original commit had an issue with Mac OS dylib files. It didn't handle fat binary dylib files correctly. This patch includes a fix. A test for that case has already been committed in r225764. llvm-svn: 226123
* [cleanup] Re-sort #include lines using llvm/utils/sort_includes.pyChandler Carruth2015-01-145-5/+1
| | | | | | | | This is just a mechanical cleanup, no functionality changed. This just fixes very minor inconsistencies with how #include lines were spaced and sorted in LLD. llvm-svn: 225978
* Revert "Convert other drivers to use WrapperNode" and subsequent commits.Rui Ueyama2015-01-143-16/+21
| | | | | | | r225764 broke a basic functionality on Mac OS. This change reverts r225764, r225766, r225767, r225769, r225814, r225816, r225829, and r225832. llvm-svn: 225859
* Replace vector<unique_ptr<File> with unique_ptr<File>.Rui Ueyama2015-01-131-3/+1
| | | | | | | Because each InputElement has exactly one File, we no longer have to use a vector to store pointers to Files. llvm-svn: 225814
* Convert other drivers to use WrapperNode.Rui Ueyama2015-01-133-18/+15
| | | | llvm-svn: 225764
* [macho] Minor install_name fixesJean-Daniel Dupas2014-12-202-1/+5
| | | | | | | | | | | | | | | | | | | Summary: Fix the binary file reader to properly read dyld version info. Update the install_name test case to properly test the binary reader. We can't use '-print_atoms' as the output format is 'native' yaml and it does not contains the dyld current and compatibility versions. Also change the timestamp value of LD_ID_DYLD to match the one generated by ld64. The dynamic linker (dyld) used to expects different values for timestamp in LD_ID_DYLD and LD_LOAD_DYLD for prebound images. While prebinding is deprecated, we should probably keep it safe and match ld64. Reviewers: kledzik Subscribers: llvm-commits Projects: #lld Differential Revision: http://reviews.llvm.org/D6736 llvm-svn: 224681
* [macho] -rpath supportJean-Daniel Dupas2014-12-184-0/+31
| | | | | | | | | | | | | | | | | | | | | Summary: Work on adding -rpath support to the mach-o linker. This patch is based on the ld64 behavior for the command line option validation. It includes a basic test to check that the LC_RPATH load commands are properly generated when that option is used. It also add LC_RPATH support to the binary reader, but I don't know how to test it though. Reviewers: kledzik Subscribers: llvm-commits Projects: #lld Differential Revision: http://reviews.llvm.org/D6724 llvm-svn: 224544
* 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-122-19/+16
| | | | | | | | | | | | | | 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-124-41/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Re-commit r223330: Rewrite InputGraph's GroupRui Ueyama2014-12-101-0/+32
| | | | llvm-svn: 223867
* Fix Darwin linker. Patch from Jean-Daniel Dupas.Rui Ueyama2014-12-101-1/+1
| | | | llvm-svn: 223865
* [mach-o] fix leak in atoms -> normalizedNick Kledzik2014-12-051-0/+17
| | | | llvm-svn: 223530
* [mach-o] Switch MachOFile and MachODylibFile to use BumpPtr in lld::FileNick Kledzik2014-12-051-28/+24
| | | | llvm-svn: 223529
* [mach-o] Pass vectors by reference and name empty vector.Nick Kledzik2014-12-051-5/+8
| | | | llvm-svn: 223527
* Revert "Rewrite InputGraph's Group"Rui Ueyama2014-12-041-32/+0
| | | | | | | | This reverts commit r223330 because it broke Darwin and ELF linkers in a way that we couldn't have caught with the existing test cases. llvm-svn: 223373
* Rewrite InputGraph's GroupRui Ueyama2014-12-041-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The aim of this patch is to reduce the excessive abstraction from the InputGraph. We found that even a simple thing, such as sorting input files (Mach-O) or adding a new file to the input file list (PE/COFF), is nearly impossible with the InputGraph abstraction, because it hides too much information behind it. As a result, we invented complex interactions between components (e.g. notifyProgress() mechanism) and tricky code to work around that limitation. There were many occasions that we needed to write awkward code. This patch is a first step to make it cleaner. As a first step, this removes Group class from the InputGraph. The grouping feature is now directly handled by the Resolver. notifyProgress is removed since we no longer need that. I could have cleaned it up even more, but in order to keep the patch minimum, I focused on Group. SimpleFileNode class, a container of File objects, is now limited to have only one File. We shold have done this earlier. We used to allow putting multiple File objects to FileNode. Although SimpleFileNode usually has only one file, the Driver class actually used that capability. I modified the Driver class a bit, so that one FileNode is created for each input File. We should now probably remove SimpleFileNode and directly store File objects to the InputGraph in some way, because a container that can contain only one object is useless. This is a TODO. Mach-O input files are now sorted before they are passe to the Resolver. DarwinInputGraph class is no longer needed, so removed. PECOFF still has hacky code to add a new file to the input file list. This will be cleaned up in another patch. llvm-svn: 223330
* [mach-o] Fix TrieEdge leakNick Kledzik2014-12-021-5/+6
| | | | | | | | In PR21682 Jean-Daliel Dupas found a leak in the trie builder and suggested a fix was to use a list instead of SmallVector so that the list elements could be allocated in the BumpPtrAllocator. llvm-svn: 223104
* [mach-o] add support for arm64 compact unwind infoNick Kledzik2014-12-021-11/+68
| | | | | | | Tim previously added generic compact unwind processing and x86_64 support. This patch adds arm64 support. llvm-svn: 223103
* Silence a -Wcast-qual warningDavid Majnemer2014-11-221-1/+1
| | | | llvm-svn: 222598
* [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-198-20/+84
| | | | | | | | | | | | | | 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] for 32-bit arm, in -r mode support B (not BL) to undefined symbolNick Kledzik2014-11-181-1/+3
| | | | | | | | | | | | | When fixing up BL instructions, the linker has to compare the thumbness of the target to decide if the instruction needs to be converted to BLX. But with B instruction there is no BX, so the linker asserts if the target is not the same thumbness. This assert was firing in -r mode when the target was undefined which it interpreted as being non-thumb. Test case change is to add a B (in both thumb and arm code) to an undefined symbol and round trip through -r mode. llvm-svn: 222266
* [mach-o] zero-fill sections have no file offsetNick Kledzik2014-11-182-11/+22
| | | | | | | In mach-o, sections of type S_ZEROFILL are special cased and to always have their section.offset field be zero. llvm-svn: 222202
* [mach-o] extract atom alignment information from mach-o filesNick Kledzik2014-11-183-11/+21
| | | | llvm-svn: 222201
* [mach-o] enhance arm64 reloc parser to support local pointer relocationsNick Kledzik2014-11-181-1/+5
| | | | | | | | | | | The arm64 assembler almost always uses r_extern=1 relocations in which the r_symbolnum field is the index of the symbol the relocation references. But sometimes it will set r_extern=0 in which case the linker needs to read the content of the reloction to determine the target. Add test case that the r_extern=0 relocation round trips. llvm-svn: 222200
* [mach-o] fix typos. No function changeNick Kledzik2014-11-181-5/+1
| | | | llvm-svn: 222199
* [mach-o] enhance arm64 reloc parser to support local pointer relocationsNick Kledzik2014-11-181-5/+19
| | | | | | | | | | | The arm64 assembler almost always uses r_extern=1 relocations in which the r_symbolnum field is the index of the symbol the relocation references. But sometimes it will set r_extern=0 in which case the linker needs to read the content of the reloction to determine the target. Add test case that the r_extern=0 relocation round trips. llvm-svn: 222198
* [mach-o] fix typos. No function changeNick Kledzik2014-11-181-4/+3
| | | | llvm-svn: 222197
* Follow-up to r221913. Fix some -Wcast-qual warning reasons.Simon Atanasyan2014-11-146-40/+44
| | | | llvm-svn: 221974
* [mach-o] Sort GOT entries by name to make links reproducibleNick Kledzik2014-11-121-5/+18
| | | | | | | | | | | | | The GOT slots were being laid out in a random order by the GOTPass which caused randomness in the output file. Note: With this change lld now bootstraps on darwin. That is: 1) link lld using system linker to make lld.1 2) link lld using lld.1 to make lld.2 3) link lld using lld.2 to make lld.3 Now lld.2 and lld.3 are identical. llvm-svn: 221831
* [mach-o] Support linker synthesized mach_header symbols.Nick Kledzik2014-11-123-1/+86
| | | | | | | | | | | | | | | | | | | | | | | On darwin in final linked images, the __TEXT segment covers that start of the file. That means in memory a process can see the mach_header (and load commands) for every loaded image in a process. There are APIs that take and return the mach_header addresses as a way to specify a particular loaded image. For completeness, any code can get the address of the mach_header of the image it is in by using &__dso_handle. In addition there are mach-o type specific symbols like __mh_execute_header. The linker needs to supply a definition for any of these symbols if used. But the address the symbol it resolves to is not in any section. Instead it is the address of the start of the __TEXT segment. I needed to make a small change to SimpleFileNode to not override resetNextIndex() because the Driver creates a SimpleFileNode to hold the internal/implicit files that the context/writer can create. For some reason SimpleFileNode overrode resetNextIndex() to do nothing instead of reseting the index (which mach-o needs if the internal file is an archive). llvm-svn: 221822
* [mach-o] Fix lazy binding offsetsNick Kledzik2014-11-117-123/+114
| | | | | | | | | | The way lazy binding works in mach-o is that the linker generates a helper function and has the stub (PLT) initially jump to it. The helper function pushes an extra parameter then jumps into dyld. The extra parameter is an offset into the lazy binding info where dyld will find the information about which symbol to bind and way lazy binding pointer to update. llvm-svn: 221654
* [mach-o] remove stray debug outputNick Kledzik2014-11-071-3/+0
| | | | llvm-svn: 221553
* [mach-o] Add support for -order_file optionNick Kledzik2014-11-071-2/+86
| | | | | | | | | | | The darwin linker lets you rearrange functions and data for better locality (less paging). You do this with the -order_file option which supplies a text file containing one symbol per line. Implementing this required a small change to LayoutPass to add a custom sorter hook. llvm-svn: 221545
* [mach-o] Add support for -S optionNick Kledzik2014-11-061-1/+2
| | | | | | | | | | | | The darwin linker does not process dwarf debug info. Instead it produces a "debug map" in the output file which points back to the original .o files for anything that wants debug info (e.g. debugger). The -S option means "don't add a debug map". lld for mach-o currently does not generate the debug map, so there is nothing to do when this option is used. But we need to process the option to get existing projects building. llvm-svn: 221432
* [mach-o] remove extra leading underscore on __bss and __gotNick Kledzik2014-11-062-4/+4
| | | | llvm-svn: 221425
OpenPOWER on IntegriCloud