summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/MachO
Commit message (Collapse)AuthorAgeFilesLines
...
* [mach-o] Add support for interposing tuples sectionNick Kledzik2014-11-062-0/+3
| | | | | | | | | | 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
* [mach-o] remove __compact_unwind atoms once __unwind_info has been generatedTim Northover2014-11-042-7/+5
| | | | | | | | | | The job of the CompactUnwind pass is to turn __compact_unwind data (and __eh_frame) into the compressed final form in __unwind_info. After it's done, the original atoms are no longer relevant and should be deleted (they cause problems during actual execution, quite apart from the fact that they're not needed). llvm-svn: 221301
* Fix warnings about missing override.Rafael Espindola2014-11-033-3/+4
| | | | llvm-svn: 221165
* [mach-o] explicitly cast little_n uses to ints to silence MSVCTim Northover2014-10-314-18/+24
| | | | | | Hopefully this'll fix the build failure in the bot. llvm-svn: 221007
* [mach-o] use the addend in GOT-based relocations.Tim Northover2014-10-301-1/+1
| | | | | | | These are used to reference typeinfo data in the exception table section, for example. llvm-svn: 220916
* [mach-o] generate LC_DATA_IN_CODE in final linked imagesNick Kledzik2014-10-281-0/+18
| | | | | | | | | lld was regenerating LC_DATA_IN_CODE in .o output files, but not into final linked images. Update test case to verify data-in-code info makes it into final linked images. llvm-svn: 220827
* TMP: fix readN & writeN to not encourage UBTim Northover2014-10-2710-345/+375
| | | | llvm-svn: 220730
* 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
* [mach-o] Support data-only dylibsNick Kledzik2014-10-243-2/+19
| | | | | | | | In final linked shared images, the __TEXT segment contains both code and the mach-o header/load-commands. In the case of a data-only dylib, there is no code, so we need to force the addition of the __TEXT segment. llvm-svn: 220597
* [mach-o] Support missing MH_SUBSECTIONS_VIA_SYMBOLSNick Kledzik2014-10-216-21/+47
| | | | | | | | | | | | | All compiler generated mach-o object files are marked with MH_SUBSECTIONS_VIA_SYMBOLS. But hand written assembly files need to opt-in if they are written correctly. The flag means the linker can break up a sections at symbol addresses and dead strip or re-order functions. This change recognizes object files without the flag and marks its atoms as not dead strippable and adds a layout-after chain of references so that the atoms cannot be re-ordered. llvm-svn: 220348
* 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-1817-42/+7
| | | | llvm-svn: 220131
* [mach-o] keep Windows library happy.Tim Northover2014-10-181-1/+1
| | | | | | &v[v.size()] may be invalid C++. llvm-svn: 220115
* [CMake] lld: Introduce ${cmake_2_8_12_INTERFACE} onto each ↵NAKAMURA Takumi2014-10-171-1/+1
| | | | | | | target_link_libraries. [PR20254] FIXME: Dependencies should be reorganized. llvm-svn: 220000
* [mach-o] update __eh_frame handling for Nick's suggestionsTim Northover2014-10-164-11/+22
| | | | | | | First, add a comment to support more variation in FDE formats. Second, refactor fde -> function handling into a separate function living in the ArchHandler. llvm-svn: 219959
* [mach-o] Add support for upward linkingNick Kledzik2014-10-163-3/+16
| | | | | | | | 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] avoid overly clever std::find_ifTim Northover2014-10-157-16/+56
| | | | | | | The bots were complaining (possibly because of a lack of traits on the iterator I was trying to use). No functional change. llvm-svn: 219843
* [mach-o] make __unwind_info defer to __eh_frame when necessary.Tim Northover2014-10-159-47/+184
| | | | | | | | | | | | Not all situations are representable in the compressed __unwind_info format, and when this happens the entry needs to point to the more general __eh_frame description. Just x86_64 implementation for now. rdar://problem/18208653 llvm-svn: 219836
* [macho] Create references from __eh_frame FDEs to their function.Tim Northover2014-10-157-1/+135
| | | | | | | | | | | | | 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
* Use isa<> instead of checking return value of definition().Rui Ueyama2014-10-142-2/+2
| | | | | | | definition() is supposed to be used through isa, dyn_cast or cast. It's better to not call that directly. llvm-svn: 219723
* [mach-o] Add Pass to create are shim Atoms for ARM interworking.Nick Kledzik2014-10-149-13/+367
| | | | | | | | | | | | | | | 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-083-37/+57
| | | | | | | | | | | | | | 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
* [mach-o] preserve custom section names on coalesable stringsNick Kledzik2014-10-021-5/+23
| | | | llvm-svn: 218894
* 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] add file comment to compact unwind passTim Northover2014-09-301-1/+3
| | | | llvm-svn: 218704
* [mach-o] create __unwind_info section on x86_64Tim Northover2014-09-3010-12/+585
| | | | | | | | | | | 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-212-5/+2
| | | | llvm-svn: 218198
* Silence these C4715 warnings from Visual C++ (NFC)Yaron Keren2014-09-212-0/+5
| | | | | | | | | | | | | | | 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] Fix two-level namespace ordinalsNick Kledzik2014-09-161-11/+14
| | | | | | | | | On darwin, the linker tools records which dylib (DSO) each undefined was found in, and then at runtime, the loader (dyld) only looks in that one specific dylib for each undefined symbol. Now that llvm-objdump can display that info I can write test cases. llvm-svn: 217898
* Remove unused local typedef.Eric Christopher2014-09-101-1/+0
| | | | llvm-svn: 217532
* [mach-o]: implement -image_base option on Darwin.Tim Northover2014-09-102-10/+12
| | | | | | | 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-0914-26/+858
| | | | | | | | | | 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-092-2/+22
| | | | | | | | | 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-043-19/+61
| | | | | | | | | | | | | | | | 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] Improve x86_64 reference kind switch statements.Nick Kledzik2014-09-031-46/+57
| | | | | | | | The use of default: was disabling the warning about unused enumerators. Fix that, then fix the one enumerator that was not handled. Add coverage for it in test suite. llvm-svn: 217078
* [mach-o] Add support for using export triesNick Kledzik2014-09-035-14/+317
| | | | | | | | | | | On Darwin at runtime, dyld will prefer to use the export trie of a dylib instead of the traditional symbol table (which is large and requires a binary search). This change enables the linker to generate an export trie and to prefer it if found in a dylib being linked against. This also simples the yaml for dylibs because the yaml form of the trie can be reduced to just a sequence of names. llvm-svn: 217066
* [mach-o] support N_NO_DEAD_STRIP nlist.desc bitNick Kledzik2014-08-214-32/+50
| | | | | | | 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] 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-212-33/+96
| | | | | | | | | | | | | | 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
* [mach-o] Support -filelist option in darwin driverNick Kledzik2014-08-151-2/+2
| | | | | | | | | | | | The darwin linker has an option, heavily used by Xcode, in which, instead of listing all input files on the command line, the input file paths are written to a text file and the path of that text file is passed to the linker with the -filelist option (similar to @file). In order to make test cases for this, I generalized the -test_libresolution option to become -test_file_usage. llvm-svn: 215762
* [mach-o] Support -F and -framework options in darwin driverNick Kledzik2014-08-141-5/+48
| | | | | | | | | | | Darwin has a packaging mechanism for shared libraries and headers called frameworks. A directory Foo.framework contains a shared library binary file "Foo" and a subdirectory "Headers". Most OS frameworks are all in one directory /System/Library/Frameworks/. As a linking convenience, the linker option "-framework Foo" means search the framework directories specified with -F (analogous to -L) looking for a shared library Foo.framework/Foo. llvm-svn: 215680
* [mach-o] Support re-exported dylibsNick Kledzik2014-08-135-42/+202
| | | | | | | | | | | | | | | | | | | | 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] Fix stub generation to work for dylibs and bundlesNick Kledzik2014-08-132-19/+34
| | | | | | | | | | Split up the CRuntimeFile into one part for output types that need an entry point and another part for output types that use stubs. Add file 'test/mach-o/Inputs/libSystem.yaml' for use by test cases that use -dylib and therefore may now need the helper symbol in libSystem.dylib. llvm-svn: 215602
* [mach-o] set ordinal in n_desc for undefined symbolsNick Kledzik2014-08-131-1/+6
| | | | | | | | | | | Mach-o uses "two-level namespace" where each undefined symbols is associated with a specific dylib. This means at runtime the loader (dyld) does need to search all loaded dylibs for that symbol but rather just the one specified. Now that llvm-nm -m prints out that info, properly set that info, and test it in the hello world test cases. llvm-svn: 215598
OpenPOWER on IntegriCloud