summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [mach-o] Extend LC_DATA_IN_CODE support to x86_64Rui Ueyama2019-08-281-8/+42
| | | | | | | | Patch by LemonBoy Differential Revision: https://reviews.llvm.org/D62185 llvm-svn: 370183
* 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
* Fix clang -Wimplicit-fallthrough warnings across llvm, NFCReid Kleckner2018-11-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch should not introduce any behavior changes. It consists of mostly one of two changes: 1. Replacing fall through comments with the LLVM_FALLTHROUGH macro 2. Inserting 'break' before falling through into a case block consisting of only 'break'. We were already using this warning with GCC, but its warning behaves slightly differently. In this patch, the following differences are relevant: 1. GCC recognizes comments that say "fall through" as annotations, clang doesn't 2. GCC doesn't warn on "case N: foo(); default: break;", clang does 3. GCC doesn't warn when the case contains a switch, but falls through the outer case. I will enable the warning separately in a follow-up patch so that it can be cleanly reverted if necessary. Reviewers: alexfh, rsmith, lattner, rtrieu, EricWF, bollu Differential Revision: https://reviews.llvm.org/D53950 llvm-svn: 345882
* [ELF] Fix IsPreemptible comment and typo. NFCFangrui Song2018-02-231-2/+2
| | | | llvm-svn: 325963
* [MACH-O] Fix the ASM code generated for __stub_helpers sectionRui Ueyama2017-08-241-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by Patricio Villalobos. I discovered that lld for darwin is generating the wrong code for lazy bindings in the __stub_helper section (at least for osx 10.12). This is the way i can reproduce this problem, using this program: #include <stdio.h> int main(int argc, char **argv) { printf("C: printf!\n"); puts("C: puts!\n"); return 0; } Then I link it using i have tested it in 3.9, 4.0 and 4.1 versions: $ clang -c hello.c $ lld -flavor darwin hello.o -o h1 -lc When i execute the binary h1 the system gives me the following error: C: printf! dyld: lazy symbol binding failed: BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB has segment 4 which is too large (0..3) dyld: BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB has segment 4 which is too large (0..3) Trace/BPT trap: 5 Investigating the code, it seems that the problem is that the asm code generated in the file StubPass.cpp, specifically in the line 323,when it adds, what it seems an arbitrary number (12) to the offset into the lazy bind opcodes section, but it should be calculated depending on the MachONormalizedFileBinaryWrite::lazyBindingInfo result. I confirmed this bug by patching the code manually in the binary and writing the right offset in the asm code (__stub_helper). This patch fixes the content of the atom that contains the assembly code when the offset is known. Differential Revision: https://reviews.llvm.org/D35387 llvm-svn: 311734
* Fix wrong formatting in lld introduced in r286561 (NFC)Mehdi Amini2016-11-111-1/+1
| | | | | | Pointed out by Davide. llvm-svn: 286649
* Prevent at compile time converting from Error::success() to Expected<T>Mehdi Amini2016-11-111-8/+8
| | | | | | | | This would trigger an assertion at runtime otherwise. Differential Revision: https://reviews.llvm.org/D26482 llvm-svn: 286562
* [lld][MachO] Re-apply r276921 with fix - initialize strings for debug stringLang Hames2016-07-271-1/+4
| | | | | | copies. llvm-svn: 276935
* [lld][MachO] Temporarily revert r276921 - it's causing bot-failures on Linux.Lang Hames2016-07-271-4/+1
| | | | llvm-svn: 276928
* [lld][MachO] Add debug info support for MachO.Lang Hames2016-07-271-1/+4
| | | | | | | | | 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] Add support for x86-64 negDelta64 references and fix negDelta32.Lang Hames2016-06-251-37/+59
| | | | | | | | | | 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
* Change getReferenceInfo/getPairReferenceInfo to use new Error handling. NFC.Pete Cooper2016-03-301-34/+32
| | | | | | | | | | | | Adds a GenericError class to lld/Core which can carry a string. This is analygous to the dynamic_error we currently use in lld/Core. Use this GenericError instead of make_dynamic_error_code. Also, provide an implemention of GenericError::convertToErrorCode which for now converts it in to the dynamic_error_code we used to have. This will go away once all the APIs are converted. llvm-svn: 264910
* Fix more cases of UB from allocating 0 sized data. NFC.Pete Cooper2016-03-231-3/+4
| | | | | | | | | | | | The size of a section can be zero, even when it contains atoms, so long as all of the atoms are also size 0. In this case we were allocating space for a 0 sized buffer. Changed this to only allocate when we need the space, but also cleaned up all the code to use MutableArrayRef instead of uint8_t* so its much much safer as we get bounds checking on all of our section creation logic. llvm-svn: 264204
* Fix EHFrame processing to add implicit references when needed.Pete Cooper2016-03-151-0/+4
| | | | | | | | | | | | | | | | | The current code for processCIE and processFDE returns out if it sees any references. The problem with this is that some references could be explicit in the binary, while others are implicit as they can be inferred from the content of the EHFrame itself. This change walks the references we have against the references we need, and verifies that all explicit references are in the correct place, and generates any missing implicit ones. Reviewed by Lang Hames and Nick Kledzik. Differential Revision: http://reviews.llvm.org/D15439 llvm-svn: 263590
* Use __nl_symbol_ptr instead of __got in the stubs pass on x86 archs.Pete Cooper2016-02-091-0/+3
| | | | | | | | | | The non lazy atoms generated in the stubs pass use an image cache to hold all of the pointers. On arm archs, this is the __got section, but on x86 archs it should be __nl_symbol_ptr. rdar://problem/24572729 llvm-svn: 260271
* Aligned __stub_helper section to 4-bytes.Pete Cooper2016-02-091-0/+2
| | | | | | | | | | | | ld64 aligns most of the stub's to 2 byte alignment, expect for the stub helper common atoms which are 4 byte aligned. This adds a new field to StubInfo which tracks this alignment and ensures that this is the alignment we get in the final image. rdar://problem/24570220 llvm-svn: 260248
* Add pointerKind() method to the MachO ArchHandler's. NFC.Pete Cooper2016-02-021-0/+4
| | | | | | | | The ObjCPass is going to need to create pointer sized relocations in the ObjC sections. This method will be used to give us a target independent way of getting the correct kind for the refererence. llvm-svn: 259441
* Fix x86_64 delta*Anon relocs.Pete Cooper2016-01-041-2/+22
| | | | | | | | | | | | | | | | | | The encoded value should be an offset from the fixup location, which means that it should take in to account the fixup offset in its section. We weren't subtracting the base address of the atom, which meant that when we parsed the file again for a round trip, we had 2x the atom address in our target address. I've also improved comments for these to try and describe what is going on. There's no test case right now, as the bug is only exhibited when __data is at a non-zero address in a -r link. A commit will soon sort the sections differently and move __data to after __text. Then these relocations in test/mach-o/parse-data-relocs-x86_64.yaml will test for this bug. llvm-svn: 256779
* Fix Clang-tidy misc-use-override warnings, other minor fixes.Rui Ueyama2015-09-101-9/+4
| | | | | | Patch from Eugene Zelenko! llvm-svn: 247323
* [lld] Add MachO thread-local storage support.Lang Hames2015-06-231-2/+42
| | | | | | | | This allows LLD to correctly link MachO objects that use thread-local storage. Differential Revision: http://reviews.llvm.org/D10578 llvm-svn: 240454
* [LLD] Add support for MachO ripRel32MinusNAnon relocations.Lang Hames2015-05-131-2/+48
| | | | llvm-svn: 237219
* Define make_dynamic_error_code(const char *).Rui Ueyama2015-04-141-3/+3
| | | | | | | | | | | | The function took either StringRef or Twine. Since string literals are ambiguous when resolving the overloading, many code calls used this function with explicit type conversion. That led awkward code like make_dynamic_error_code(Twine("Error occurred")). This patch adds a function definition for string literals, so that you can directly call the function with literals. llvm-svn: 234841
* [Core,MachO,Test] Remove trailing whitespace.Shankar Easwaran2015-02-221-20/+20
| | | | llvm-svn: 230192
* [Mach-O] Rename enum typename for consistency. NFCJean-Daniel Dupas2015-02-191-4/+4
| | | | | | | Typename shouldn't mix camel case and underscore. Thanks to Rui for the remark. llvm-svn: 229848
* Update ARM and x86 ArchHandler to check switch completeness. NFCJean-Daniel Dupas2015-02-151-2/+5
| | | | | | Define an explicit type for arch specific reference kinds to make sure all cases are covered in switch statements. llvm-svn: 229314
* [cleanup] Re-sort #include lines using llvm/utils/sort_includes.pyChandler Carruth2015-01-141-1/+0
| | | | | | | | 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
* Follow-up to r221913. Fix some -Wcast-qual warning reasons.Simon Atanasyan2014-11-141-12/+12
| | | | llvm-svn: 221974
* [mach-o] Fix lazy binding offsetsNick Kledzik2014-11-111-1/+3
| | | | | | | | | | 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
* Fix warnings about missing override.Rafael Espindola2014-11-031-1/+1
| | | | llvm-svn: 221165
* [mach-o] explicitly cast little_n uses to ints to silence MSVCTim Northover2014-10-311-7/+7
| | | | | | 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
* TMP: fix readN & writeN to not encourage UBTim Northover2014-10-271-47/+51
| | | | llvm-svn: 220730
* [mach-o] Support missing MH_SUBSECTIONS_VIA_SYMBOLSNick Kledzik2014-10-211-1/+2
| | | | | | | | | | | | | 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-2/+0
| | | | llvm-svn: 220131
* [mach-o] avoid overly clever std::find_ifTim Northover2014-10-151-1/+14
| | | | | | | 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-15/+32
| | | | | | | | | | | | 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/+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] Add Pass to create are shim Atoms for ARM interworking.Nick Kledzik2014-10-141-0/+4
| | | | | | | | | | | | | | | 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] create __unwind_info section on x86_64Tim Northover2014-09-301-5/+52
| | | | | | | | | | | 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
* [mach-o] Add support for arm64 (AAarch64)Nick Kledzik2014-09-091-1/+4
| | | | | | | | | | 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] 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] implement more x86 and x86_64 relocation supportNick Kledzik2014-07-171-24/+210
| | | | | | | | | Add support for adding section relocations in -r mode. Enhance the test cases which validate the parsing of .o files to also round trip. They now write out the .o file and then parse that, verifying all relocations survived the round trip. llvm-svn: 213333
* [mach-o] refactor KindHandler into ArchHandler and simplify passes.Nick Kledzik2014-07-161-0/+421
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
OpenPOWER on IntegriCloud