summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* TMP: fix readN & writeN to not encourage UBTim Northover2014-10-271-19/+17
| | | | llvm-svn: 220730
* [mach-o] Support missing MH_SUBSECTIONS_VIA_SYMBOLSNick Kledzik2014-10-211-14/+37
| | | | | | | | | | | | | 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
* Sort include files according to convention.Shankar Easwaran2014-10-181-4/+1
| | | | llvm-svn: 220131
* [mach-o] update __eh_frame handling for Nick's suggestionsTim Northover2014-10-161-1/+3
| | | | | | | 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] avoid overly clever std::find_ifTim Northover2014-10-151-4/+19
| | | | | | | 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-151-12/+1
| | | | | | | | | | | | 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-151-0/+91
| | | | | | | | | | | | | 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] preserve custom section names on coalesable stringsNick Kledzik2014-10-021-5/+23
| | | | llvm-svn: 218894
* [mach-o] Add support for arm64 (AAarch64)Nick Kledzik2014-09-091-2/+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 using export triesNick Kledzik2014-09-031-5/+14
| | | | | | | | | | | 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-211-6/+7
| | | | | | | 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-3/+11
| | | | | | | | | | | | | | | | | | | | 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 support for LC_DATA_IN_CODENick Kledzik2014-07-241-10/+58
| | | | | | | | | | | | | | Sometimes compilers emit data into code sections (e.g. constant pools or jump tables). These runs of data can throw off disassemblers. The solution in mach-o is that ranges of data-in-code are encoded into a table pointed to by the LC_DATA_IN_CODE load command. The way the data-in-code information is encoded into lld's Atom model is that that start and end of each data run is marked with a Reference whose offset is the start/end of the data run. For arm, the switch back to code also marks whether it is thumb or arm code. llvm-svn: 213901
* [mach-o] add initial support for modes in arm code.Nick Kledzik2014-07-231-0/+6
| | | | | | | | | 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] add support for old x86 __eh_frame sectionsNick Kledzik2014-07-211-3/+2
| | | | | | | Over time the symbols and relocations have changed for dwarf unwind info in the __eh_frame section. Add test cases for older and new style. llvm-svn: 213585
* [mach-o] refactor KindHandler into ArchHandler and simplify passes.Nick Kledzik2014-07-161-30/+12
| | | | | | | | | | | 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-10/+5
| | | | | | | | | | 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
* [mach-o] Fix warning on enumeration cases not handledNick Kledzik2014-07-031-0/+10
| | | | llvm-svn: 212241
* [mach-o] add parsing of x86 relocationsNick Kledzik2014-07-021-6/+32
| | | | llvm-svn: 212239
* [mach-o] add representation for LC_ID_DYLIB to MachONormalizedFileTim Northover2014-07-011-1/+2
| | | | | | | It still needs to be tied into BinaryReader, but this allows reasonably sensible creation of SharedLibrary atoms on MachO. llvm-svn: 212093
* [mach-o] x86_64 relocation code review fixesNick Kledzik2014-06-301-3/+2
| | | | llvm-svn: 212068
* MachO: support atomization of dylibs.Tim Northover2014-06-301-0/+16
| | | | | | | For .dylib files, we refrain from actually creating any atoms until they're requested via the "exports" method. llvm-svn: 212027
* [mach-o] refactor x86_64 relocation handling.Nick Kledzik2014-06-271-25/+197
| | | | | | | | | | | | | | 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
* [mach-o]: make sure custom sort method is irreflexive.Tim Northover2014-06-251-2/+2
| | | | | | | | | | | The previous function returned true for "s < s", which could completely mess up the sorting of symbols within a section. Unfortunately, I don't think there's a robust way to write a test for this. Anything I come up with will be making assumptions about the particular implementation of std::sort. llvm-svn: 211704
* [mach-o]: atomize zero-terminated literals correctly.Tim Northover2014-06-251-5/+5
| | | | | | | | | When looking through sections with zero-terminated string-literals (__cstring or __ustring) we were constantly rechecking the first few bytes of the string for '\0' rather than advancing along. This obviously failed unless all strings within the section had the same length as that first one. llvm-svn: 211682
* [mach-o] don't assume all sections have symbolsTim Northover2014-06-251-4/+6
| | | | | | | | We were trying to examine the first symbol in a section that we wanted to atomize by symbols, even when there wasn't one. Instead, we should make the initial anonymous symbol cover the entire section in that situation. llvm-svn: 211681
* Don't import error_code into the lld namespace.Rafael Espindola2014-06-121-13/+13
| | | | llvm-svn: 210785
* [mach-o] add support for parsing resolver functionsNick Kledzik2014-06-111-7/+10
| | | | llvm-svn: 210612
* [mach-o] refactor mach-o output section selection to be table driven.Nick Kledzik2014-06-101-37/+63
| | | | | | | In -r mode the sections use the table used to parse .o files. Otherwise use final exectuable table. No functionality change. llvm-svn: 210506
* [mach-o] parse multiple symbols on same address into aliasesNick Kledzik2014-06-091-2/+11
| | | | llvm-svn: 210502
* [mach-o] Make anonymous atom out of section content before any symbolNick Kledzik2014-06-041-16/+20
| | | | | | | | In sections that are broken into atoms at symbols, if the first symbol in the section is not at the start of the section, then make an anonymous atom for the section content that is before the first symbol. llvm-svn: 210142
* [mach-o] Refactor sections -> atoms to be table driven.Nick Kledzik2014-06-031-373/+312
| | | | | | | | | | | | Previously each section kind had its own code to loop over the section and parse it into atoms. This refactoring has two tables. The first maps sections to ContentType. The second maps ContentType to information on how to find the atom boundaries. A few bugs in test cases were discovered as part of the refactoring. No change in functionality intended. llvm-svn: 210138
* Use error_code() instead of error_code::succes()Rafael Espindola2014-05-311-7/+7
| | | | | | | There is no std::error_code::success, so this removes much of the noise in transitioning to std::error_code. llvm-svn: 209948
* [mach-o] Add support for custom sectionsNick Kledzik2014-05-301-4/+32
| | | | llvm-svn: 209928
* [mach-0] Add support for parsing compact unwind info sectionNick Kledzik2014-05-291-0/+25
| | | | llvm-svn: 209865
* [mach-o] Add support for parsing __eh_frame section. Generalize support for ↵Nick Kledzik2014-05-291-21/+104
| | | | | | whether symbols in a section are ignored or illegal llvm-svn: 209858
* [mach-o] Add support for parsing CFString sectionsNick Kledzik2014-05-291-25/+64
| | | | llvm-svn: 209844
* [mach-o] Add support for parsing of weak-def symbolsNick Kledzik2014-05-281-2/+4
| | | | llvm-svn: 209707
* [mach-o] Support parsing of non-lazy-pointer sectionsNick Kledzik2014-05-281-10/+37
| | | | llvm-svn: 209704
* [mach-o] Add support for initializers and terminators in object filesNick Kledzik2014-05-271-2/+38
| | | | llvm-svn: 209700
* [mach-o] Add checks that string literals in object files are zero terminatedNick Kledzik2014-05-271-0/+15
| | | | llvm-svn: 209685
* [mach-o] Add support for reading utf16 string literal sectionsNick Kledzik2014-05-271-0/+17
| | | | llvm-svn: 209684
* Add make_dynamic_error_code().Nick Kledzik2014-05-271-3/+16
| | | | | | | | | | | This is a short-term fix to allow lld Readers to return error messages with dynamic content. The long term fix will be to enhance ErrorOr<> to work with errors other than error_code. Or to change the interface to Readers to pass down a diagnostics object through which all error messages are written. llvm-svn: 209681
* [mach-o] Fix so that mach-o semantic errors return an error rather than assertNick Kledzik2014-05-221-7/+12
| | | | llvm-svn: 209469
* [mach-o] parse literal sections into atomsNick Kledzik2014-05-221-3/+60
| | | | llvm-svn: 209379
* [mach-o] Add support for zero-fill sections.Nick Kledzik2014-05-151-2/+12
| | | | llvm-svn: 208928
* [mach-o] Add support and test cases for parsing tentative definitionsNick Kledzik2014-05-151-1/+14
| | | | llvm-svn: 208919
* [MachO] Add undefined atoms.Joey Gouly2014-02-021-2/+3
| | | | llvm-svn: 200649
* [MachO] Add basic support for local symbols.Joey Gouly2014-01-131-3/+26
| | | | llvm-svn: 199155
* Factor the symbol handling in normalizedToAtoms into a separate function.Joey Gouly2014-01-121-7/+12
| | | | | | No functionality change. llvm-svn: 199066
OpenPOWER on IntegriCloud