summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Use arithmetic type to represent alignments (not in log2) everywhere.Rui Ueyama2015-03-261-2/+2
| | | | | | | This is the final step of conversion. Now log2 numbers are removed from everywhere! llvm-svn: 233246
* Remove implicit constructor and operator int from PowerOf2.Rui Ueyama2015-03-261-4/+1
| | | | | | | | | | 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
* Add a scaffolding to merge alignment representations.Rui Ueyama2015-03-261-2/+2
| | | | | | | | | | | | | | | | | We are using log2 values and values themselves to represent alignments. For example, alignment 8 is sometimes represented as 3 (8 == 2^3). We want to stop using log2 values. Because both types are regular arithmetic types, we cannot get help from a compiler to find places we mix two representations. That makes this merging work surprisingly hard because if I make a mistake, I'll just get wrong results at runtime (Yay types!). In this patch, I introduced a class to represents power-of-two values, which is basically an alias for an integer type. Once the migration is done, the class will be removed. llvm-svn: 233232
* [ELF] Ability to resolve undefined symbols lazilyDenis Protivensky2015-03-141-1/+1
| | | | | | | | | Handle resolution of symbols coming from linked object files lazily. Add implementation of handling _GLOBAL_OFFSET_TABLE_ and __exidx_start/_end symbols for ARM platform. Differential Revision: http://reviews.llvm.org/D8159 llvm-svn: 232261
* [MachO] Use setter for globalsAreDeadStripRoots. NFC intended.Davide Italiano2015-03-091-2/+2
| | | | llvm-svn: 231629
* Add missing includes for make_unique, lld edition.Benjamin Kramer2015-03-021-0/+1
| | | | llvm-svn: 230925
* Remove YAML/Native round-trip passes.Rui Ueyama2015-02-201-1/+0
| | | | | | | | | | | | | | | | | | | | The round-trip passes were introduced in r193300. The intention of the change was to make sure that LLD is capable of reading end writing such file formats. But that turned out to be yet another over-designed stuff that had been slowing down everyday development. The passes ran after the core linker and before the writer. If you had an additional piece of information that needs to be passed from front-end to the writer, you had to invent a way to save the data to YAML/Native. These passes forced us to do that even if that data was not needed to be represented neither in an object file nor in an executable/DSO. It doesn't make sense. We don't need these passes. http://reviews.llvm.org/D7480 llvm-svn: 230069
* [ELF] Demangle: don't expose raw info when getter is available.Davide Italiano2015-02-181-1/+1
| | | | | | | Differential Revision: D7693 Reviewed by: shankarke llvm-svn: 229635
* MachO: Move LayoutPass to MachO directory.Rui Ueyama2015-02-051-8/+2
| | | | | | | | | | | | | | | | | | | | | | The real user of the LayoutPass is now only Mach-O, so move that pass out of the common directory to Mach-O directory. "Core" architecture were using the LayoutPass. I modified that to use a simple OrderPass. I think no one actually have authority what feature should be in Core and what's not, but I believe the LayoutPass is not very suitable for Core. Before more code starts depending on the complex pass, it's better to remove that from Core. I could have simplified that pass because Mach-O is the only user of the LayoutPass. For example, the second parameter of the LayoutPass constructor can be converted from optional to mandatory. I didn't do that in this patch to keep it simple. I'll do in a followup patch. http://reviews.llvm.org/D7311 llvm-svn: 228341
* [MachO] Remove dependency on lldDriverGreg Fitzgerald2015-01-231-2/+20
| | | | | | | | | Moved getMemoryBuffer from DarwnLdDriver to MachOLinkingContext. lldMachO shared library target now builds. Differential Review: http://reviews.llvm.org/D7155 llvm-svn: 226963
* Fix five of the shared library build targetsGreg Fitzgerald2015-01-211-2/+2
| | | | | | | | | | | | | | | | | | 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
* 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-151-12/+12
| | | | | | | | 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-141-1/+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-141-11/+15
| | | | | | | 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-131-12/+10
| | | | llvm-svn: 225764
* [macho] -rpath supportJean-Daniel Dupas2014-12-181-0/+4
| | | | | | | | | | | | | | | | | | | | | 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
* Re-commit r223330: Rewrite InputGraph's GroupRui Ueyama2014-12-101-0/+32
| | | | llvm-svn: 223867
* 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] propagate dylib version numbersNick Kledzik2014-11-191-0/+16
| | | | | | | | | | | | | | 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 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
* Remove #ifdef __FreeBSDRui Ueyama2014-10-271-4/+2
| | | | | | | r220665 makes configure or CMake to set HAVE_CXXABI_H on FreeBSD 10.0. We don't need this ugly ifdef condition anymore. llvm-svn: 220666
* [mach-o] Support old style objc class names in export listsNick Kledzik2014-10-241-0/+20
| | | | | | | | | Objective-C switched to a new ABI which uses a different mangling for class names. But to keep projects building that use export lists that use the old class name mangling, the linker recognizes the old names and transforms them to the new mangling. llvm-svn: 220598
* Use __cxa_demangle on FreeBSD to fix buildbots.Rui Ueyama2014-10-211-2/+2
| | | | llvm-svn: 220326
* Assume cxxabi.h exists on FreeBSDRui Ueyama2014-10-211-1/+3
| | | | | | | HAVE_CXXABI_H is not defined on FreeBSD but the system actually has the header. CMake test fails because the header depends on size_t. llvm-svn: 220315
* Sort include files according to convention.Shankar Easwaran2014-10-181-6/+2
| | | | llvm-svn: 220131
* [mach-o] Add support for upward linkingNick Kledzik2014-10-161-2/+13
| | | | | | | | To deal with cycles in shared library dependencies, the darwin linker supports marking specific link dependencies as "upward". An upward link is when a lower level library links against a higher level library. llvm-svn: 219949
* [mach-o] Add Pass to create are shim Atoms for ARM interworking.Nick Kledzik2014-10-141-0/+17
| | | | | | | | | | | | | | | Arm code has two instruction encodings "thumb" and "arm". When branching from one code encoding to another, you need to use an instruction that switches the instruction mode. Usually the transition only happens at call sites, and the linker can transform a BL instruction in BLX (or vice versa). But if the compiler did a tail call optimization and a function ends with a branch (not branch and link), there is no pc-rel BX instruction. The ShimPass looks for pc-rel B instructions that will need to switch mode. For those cases it synthesizes a shim which does the transition, then modifies the original atom with the B instruction to target to the shim atom. llvm-svn: 219655
* [mach-o] Use default for min OS version when not specified on command line.Nick Kledzik2014-10-091-0/+20
| | | | | | This matches the current darwin linker. llvm-svn: 219376
* [mach-o] Support fat archivesNick Kledzik2014-10-081-1/+7
| | | | | | | | | | | | | | mach-o supports "fat" files which are a header/table-of-contents followed by a concatenation of mach-o files (or archives of mach-o files) built for different architectures. Previously, the support for fat files was in the MachOReader, but that only supported fat .o files and dylibs (not archives). The fix is to put the fat handing into MachOFileNode. That way any input file kind (including archives) can be fat. MachOFileNode selects the sub-range of the fat file that matches the arch being linked and creates a MemoryBuffer for just that subrange. llvm-svn: 219268
* [mach-o] Add support for -dependency_info command line optionNick Kledzik2014-10-041-4/+66
| | | | | | | | | | | This option is added by Xcode when it runs the linker. It produces a binary file which contains the file the linker used. Xcode uses the info to dynamically update it dependency tracking. To check the content of the binary file, the test case uses a python script to dump the binary file as text which FileCheck can check. llvm-svn: 219039
* Add MachOLinkingContext parameter to MachOFileNode constructor.Nick Kledzik2014-10-011-4/+4
| | | | | | | | | | | No functionality change. This removes a down-cast from LinkingContext to MachOLinkingContext. Also, remove const from LinkingContext::createImplicitFiles() to remove the need for another const cast. Seems reasonable for createImplicitFiles() to need to modify the context (MachOLinkingContext does). llvm-svn: 218796
* [mach-o] Implement -demangle.Nick Kledzik2014-09-301-1/+34
| | | | | | | | | | | | | | The darwin linker has the -demangle option which directs it to demangle C++ (and soon Swift) mangled symbol names. Long term we need some Diagnostics object for formatting errors and warnings. But for now we have the Core linker just writing messages to llvm::errs(). So, to enable demangling, I changed the Resolver to call a LinkingContext method on the symbol name. To make this more interesting, the demangling code is done via __cxa_demangle() which is part of the C++ ABI, which is only supported on some platforms, so I had to conditionalize the code with the config generated HAVE_CXXABI_H. llvm-svn: 218718
* [mach-o] create __unwind_info section on x86_64Tim Northover2014-09-301-0/+12
| | | | | | | | | | | This is a minimally useful pass to construct the __unwind_info section in a final object from the various __compact_unwind inputs. Currently it doesn't produce any compressed pages, only works for x86_64 and will fail if any function ends up without __compact_unwind. rdar://problem/18208653 llvm-svn: 218703
* Modified per David Blakie suggestion.Yaron Keren2014-09-211-2/+1
| | | | llvm-svn: 218198
* Silence these C4715 warnings from Visual C++ (NFC)Yaron Keren2014-09-211-0/+2
| | | | | | | | | | | | | | | llvm\tools\lld\lib\readerwriter\macho\macholinkingcontext.cpp(647): warning C4715: 'lld::MachOLinkingContext::exportSymbolNamed' : not all control paths return a value llvm\tools\lld\lib\readerwriter\macho\machonormalizedfilefromatoms.cpp(723): warning C4715: '`anonymous namespace'::Util::getSymbolTableRegion' : not all control paths return a value While all enum values do appear in the switch, an uninitialized or corrupted enum variable would not be caught without the default: case in the switch. llvm-svn: 218197
* [mach-o]: implement -image_base option on Darwin.Tim Northover2014-09-101-5/+4
| | | | | | | As suggested by Nick, this will make __unwind_info implementation more natural, and it'd have to be done at some point anyway. llvm-svn: 217486
* [mach-o] Add support for arm64 (AAarch64)Nick Kledzik2014-09-091-3/+15
| | | | | | | | | | Most of the changes are in the new file ArchHandler_arm64.cpp. But a few things had to be fixed to support 16KB pages (instead of 4KB) which iOS arm64 requires. In addition the StubInfo struct had to be expanded because arm64 uses two instruction (ADRP/LDR) to load a global which requires two relocations. The other mach-o arches just needed one relocation. llvm-svn: 217469
* [mach-o] Add support for -pie and -no_pieNick Kledzik2014-09-091-1/+18
| | | | | | | | | There is a bit (MH_PIE) in the flags field of the mach_header which tells the kernel is a program was built position independent (for ASLR). The linker automatically attempts to build programs PIE if they are built for a recent OS version. But the -pie and -no_pie options override that default behavior. llvm-svn: 217408
* [mach-o] Let darwin driver infer arch from .o files if -arch not used.Nick Kledzik2014-09-041-0/+5
| | | | | | | | | | | | | | | | Mach-O has a "fat" (or "universal") variant where the same contents built for different architectures are concatenated into one file with a table-of-contents header at the start. But this leaves a dilemma for the linker - which architecture to use. Normally, the linker command line -arch is used to force which slice of any fat files are used. The clang compiler always passes -arch to the linker when invoking it. But some Makefiles invoke the linker directly and don’t specify the -arch option. For those cases, the linker scans all input files in command line order and finds the first non-fat object file. Whatever architecture it is becomes the architecture for the link. llvm-svn: 217189
* [mach-o] Fix initial live atoms with -dead_stripNick Kledzik2014-08-211-0/+16
| | | | | | | When -dead_strip is used with -exported_symbols_list the initial set of live atoms are those in the export list. llvm-svn: 216213
* [mach-o] Add support for -exported_symbols_list and -keep_private_externsNick Kledzik2014-08-211-1/+27
| | | | | | | | | | | | | | Both options control the final scope of atoms. When -exported_symbols_list <file> is used, the file is parsed into one symbol per line in the file. Only those symbols will be exported (global) in the final linked image. The -keep_private_externs option is only used with -r mode. Normally, -r mode reduces private extern (scopeLinkageUnit) symbols to non-external. But add the -keep_private_externs option keeps them private external. llvm-svn: 216146
OpenPOWER on IntegriCloud