summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/RuntimeDyld/Targets
Commit message (Collapse)AuthorAgeFilesLines
...
* Thread Expected<...> up from libObject’s getName() for symbols to allow ↵Kevin Enderby2016-04-205-21/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | llvm-objdump to produce a good error message. Produce another specific error message for a malformed Mach-O file when a symbol’s string index is past the end of the string table. The existing test case in test/Object/macho-invalid.test for macho-invalid-symbol-name-past-eof now reports the error with the message indicating that a symbol at a specific index has a bad sting index and that bad string index value. Again converting interfaces to Expected<> from ErrorOr<> does involve touching a number of places. Where the existing code reported the error with a string message or an error code it was converted to do the same. There is some code for this that could be factored into a routine but I would like to leave that for the code owners post-commit to do as they want for handling an llvm::Error. An example of how this could be done is shown in the diff in lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h which had a Check() routine already for std::error_code so I added one like it for llvm::Error . Also there some were bugs in the existing code that did not deal with the old ErrorOr<> return values.  So now with Expected<> since they must be checked and the error handled, I added a TODO and a comment: “// TODO: Actually report errors helpfully” and a call something like consumeError(NameOrErr.takeError()) so the buggy code will not crash since needed to deal with the Error. Note there fixes needed to lld that goes along with this that I will commit right after this. So expect lld not to built after this commit and before the next one. llvm-svn: 266919
* [RuntimeDyld][AArch64] Add support for the MachO ARM64_RELOC_SUBTRACTOR reloc.Lang Hames2016-01-211-1/+53
| | | | llvm-svn: 258438
* [RuntimeDyld] Add accessors to `SectionEntry`; NFCSanjoy Das2015-11-236-50/+52
| | | | | | | | | | | | | | | | Summary: Remove naked access to the data members in `SectionEntry` and route accesses through accessor functions. This makes it obvious how the instances of the class are used, and will also facilitate adding bounds checking to `advanceStubOffset` in a later change. Reviewers: lhames, loladiro, andrew.w.kaylor Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14674 llvm-svn: 253918
* RuntimeDyld: fix -Wtype-limitsSaleem Abdulrasool2015-11-051-2/+2
| | | | | | | Adjust the casted type. By casting to the same size rather than just the signed-ness, we were asserting tautological statements. NFC. llvm-svn: 252150
* RuntimeDyld: add COFF i386 supportSaleem Abdulrasool2015-11-011-0/+199
| | | | | | | This adds support for COFF I386. This is sufficient for code execution in a 32-bit JIT, though, imported symbols need to custom lowered for the redirection. llvm-svn: 251761
* [RuntimeDyld][COFF] Fix a think-o in the handling of the IMAGE_REL_AMD64_ADDR64Lang Hames2015-10-231-1/+1
| | | | | | relocation that was introduced in r250733. llvm-svn: 251135
* [RuntimeDyld][COFF] Fix some endianness issues, re-enable the regression test.Lang Hames2015-10-191-10/+7
| | | | llvm-svn: 250733
* [RuntimeDyld] Support non-zero addends for the MachO X86_64 SUBTRACTOR reloc.Lang Hames2015-09-101-2/+6
| | | | | | This functionality was accidentally left out of r247119. llvm-svn: 247336
* [RuntimeDyld] Add support for MachO x86_64 SUBTRACTOR relocation.Lang Hames2015-09-091-1/+50
| | | | llvm-svn: 247119
* [RuntimeDyld][AArch64] Add explicit addends before calling relocationValueRef.Lang Hames2015-08-111-5/+4
| | | | | | relocationValueRef uses the addend, so it has to be set before the call. llvm-svn: 244574
* Convert getSymbolSection to return an ErrorOr.Rafael Espindola2015-08-071-2/+1
| | | | | | | This function can actually fail since the symbol contains an index to the section and that can be invalid. llvm-svn: 244375
* [RuntimeDyld] MachO: Add support for ARM scattered vanilla relocations.Lang Hames2015-07-242-38/+4
| | | | llvm-svn: 243126
* Remove getRelocationAddress.Rafael Espindola2015-07-064-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Originally added in r139314. Back then it didn't actually get the address, it got whatever value the relocation used: address or offset. The values in different object formats are: * MachO: Always an offset. * COFF: Always an address, but when talking about the virtual address of sections it says: "for simplicity, compilers should set this to zero". * ELF: An offset for .o files and and address for .so files. In the case of the .so, the relocation in not linked to any section (sh_info is 0). We can't really compute an offset. Some API mappings would be: * Use getAddress for everything. It would be quite cumbersome. To compute the address elf has to follow sh_info, which can be corrupted and therefore the method has to return an ErrorOr. The address of the section is also the same for every relocation in a section, so we shouldn't have to check the error and fetch the value for every relocation. * Use a getValue and make it up to the user to know what it is getting. * Use a getOffset and: * Assert for dynamic ELF objects. That is a very peculiar case and it is probably fair to ask any tool that wants to support it to use ELF.h. The only tool we have that reads those (llvm-readobj) already does that. The only other use case I can think of is a dynamic linker. * Check that COFF .obj files have sections with zero virtual address spaces. If it turns out that some assembler/compiler produces these, we can change COFFObjectFile::getRelocationOffset to subtract it. Given COFF format, this can be done without the need for ErrorOr. The getRelocationAddress method was never implemented for COFF. It also had exactly one use in a very peculiar case: a shortcut for adding the section value to a pcrel reloc on MachO. Given that, I don't expect that there is any use out there of the C API. If that is not the case, let me know and I will add it back with the implementation inlined and do a proper deprecation. llvm-svn: 241450
* Return ErrorOr from SymbolRef::getName.Rafael Espindola2015-07-022-5/+8
| | | | | | | | | | | | This function can really fail since the string table offset can be out of bounds. Using ErrorOr makes sure the error is checked. Hopefully a lot of the boilerplate code in tools/* can go away once we have a diagnostic manager in Object. llvm-svn: 241297
* Don't return error_code from a function that doesn't fail.Rafael Espindola2015-06-301-2/+1
| | | | llvm-svn: 241033
* Don't return error_code from function that never fails.Rafael Espindola2015-06-293-8/+4
| | | | llvm-svn: 241021
* Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)Alexander Kornienko2015-06-234-4/+4
| | | | | | Apparently, the style needs to be agreed upon first. llvm-svn: 240390
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-194-4/+4
| | | | | | | | | | | | | The patch is generated using this command: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ llvm/lib/ Thanks to Eugene Kosov for the original patch! llvm-svn: 240137
* [RuntimeDyld] Fix MachO i386 SECTDIFF relocation to support non-zero addends.Lang Hames2015-05-271-6/+5
| | | | | | | Previously, relocations of the form 'A - B + C' would fail on i386 when C was non-zero. llvm-svn: 238356
* [RuntimeDyld][COFF] Add external symbol resolution support to RuntimeDyldCOFF.Lang Hames2015-04-221-14/+16
| | | | | | Patch by Andy Ayers. Thanks Andy! llvm-svn: 235554
* [MCJIT][Orc] Refactor RTDyldMemoryManager, weave RuntimeDyld::SymbolInfo throughLang Hames2015-03-305-11/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MCJIT. This patch decouples the two responsibilities of the RTDyldMemoryManager class, memory management and symbol resolution, into two new classes: RuntimeDyld::MemoryManager and RuntimeDyld::SymbolResolver. The symbol resolution interface is modified slightly, from: uint64_t getSymbolAddress(const std::string &Name); to: RuntimeDyld::SymbolInfo findSymbol(const std::string &Name); The latter passes symbol flags along with symbol addresses, allowing RuntimeDyld and others to reason about non-strong/non-exported symbols. The memory management interface removes the following method: void notifyObjectLoaded(ExecutionEngine *EE, const object::ObjectFile &) {} as it is not related to memory management. (Note: Backwards compatibility *is* maintained for this method in MCJIT and OrcMCJITReplacement, see below). The RTDyldMemoryManager class remains in-tree for backwards compatibility. It inherits directly from RuntimeDyld::SymbolResolver, and indirectly from RuntimeDyld::MemoryManager via the new MCJITMemoryManager class, which just subclasses RuntimeDyld::MemoryManager and reintroduces the notifyObjectLoaded method for backwards compatibility). The EngineBuilder class retains the existing method: EngineBuilder& setMCJITMemoryManager(std::unique_ptr<RTDyldMemoryManager> mcjmm); and includes two new methods: EngineBuilder& setMemoryManager(std::unique_ptr<MCJITMemoryManager> MM); EngineBuilder& setSymbolResolver(std::unique_ptr<RuntimeDyld::SymbolResolver> SR); Clients should use EITHER: A single call to setMCJITMemoryManager with an RTDyldMemoryManager. OR (exclusive) One call each to each of setMemoryManager and setSymbolResolver. This patch should be fully compatible with existing uses of RTDyldMemoryManager. If it is not it should be considered a bug, and the patch either fixed or reverted. If clients find the new API to be an improvement the goal will be to deprecate and eventually remove the RTDyldMemoryManager class in favor of the new classes. llvm-svn: 233509
* Fix the autoconf buildDavid Majnemer2015-03-072-194/+160
| | | | | | | | lib/ExecutionEngine/Targets has no Makefile, causing the autoconf build to fail. Solve this by bringing the COFF implementation of RuntimeDyld in line like the Mach-O and ELF implementations. llvm-svn: 231579
* Fix unused variable/function warningsDavid Majnemer2015-03-071-1/+0
| | | | llvm-svn: 231576
* ExecutionEngine: Preliminary support for dynamically loadable coff objectsDavid Majnemer2015-03-072-0/+249
| | | | | | | | | | Provide basic support for dynamically loadable coff objects. Only handles a subset of x64 currently. Patch by Andy Ayers! Differential Revision: http://reviews.llvm.org/D7793 llvm-svn: 231574
* Fix undefined behavior (shift of negative value) in ↵Alexey Samsonov2015-01-101-2/+2
| | | | | | | | | | | | | | RuntimeDyldMachOAArch64::encodeAddend. Test Plan: regression test suite with/without UBSan. Reviewers: lhames, ributzka Subscribers: aemerson, llvm-commits Differential Revision: http://reviews.llvm.org/D6908 llvm-svn: 225568
* [MCJIT] Remove the local symbol table from RuntimeDlyd - it's not needed.Lang Hames2014-11-274-8/+8
| | | | | | | | All symbols have to be stored in the global symbol to enable cross-rtdyld-instance linking, so the local symbol table content is redundant. llvm-svn: 222867
* [MCJIT] Reapply r222828 and r222810-r222812 with fix for MSVC move-op issues.Lang Hames2014-11-264-77/+79
| | | | llvm-svn: 222840
* Reverting r222828 and r222810-r222812 as they broke the build on Windows.Aaron Ballman2014-11-264-79/+77
| | | | | | http://bb.pgr.jp/builders/ninja-clang-i686-msc17-R/builds/11753 llvm-svn: 222833
* [MCJIT] Clean up RuntimeDyld's quirky object-ownership/modification scheme.Lang Hames2014-11-264-77/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, when loading an object file, RuntimeDyld (1) took ownership of the ObjectFile instance (and associated MemoryBuffer), (2) potentially modified the object in-place, and (3) returned an ObjectImage that managed ownership of the now-modified object and provided some convenience methods. This scheme accreted over several years as features were tacked on to RuntimeDyld, and was both unintuitive and unsafe (See e.g. http://llvm.org/PR20722). This patch fixes the issue by removing all ownership and in-place modification of object files from RuntimeDyld. Existing behavior, including debugger registration, is preserved. Noteworthy changes include: (1) ObjectFile instances are now passed to RuntimeDyld by const-ref. (2) The ObjectImage and ObjectBuffer classes have been removed entirely, they existed to model ownership within RuntimeDyld, and so are no longer needed. (3) RuntimeDyld::loadObject now returns an instance of a new class, RuntimeDyld::LoadedObjectInfo, which can be used to construct a modified object suitable for registration with the debugger, following the existing debugger registration scheme. (4) The JITRegistrar class has been removed, and the GDBRegistrar class has been re-written as a JITEventListener. This should fix http://llvm.org/PR20722 . llvm-svn: 222810
* [JIT] Fix more missing endian conversions (opcodes for AArch64, ARM, and ↵Daniel Sanders2014-11-061-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | Mips stub functions, and ARM target in general) Summary: Fixed all of the missing endian conversions that Lang Hames and I identified in RuntimeDyldMachOARM.h. Fixed the opcode emission in RuntimeDyldImpl::createStubFunction() for AArch64, ARM, Mips when the host endian doesn't match the target endian. PowerPC will need changing if it's opcodes are affected by endianness but I've left this for now since I'm unsure if this is the case and it's the only path that specifies the target endian. This patch fixes MachO_ARM_PIC_relocations.s on a big-endian Mips host. This is the last of the known issues on this host. Reviewers: lhames Reviewed By: lhames Subscribers: aemerson, llvm-commits Differential Revision: http://reviews.llvm.org/D6130 llvm-svn: 221446
* [MCJIT] Defer application of AArch64 MachO GOT relocations until resolve time.Lang Hames2014-10-211-5/+5
| | | | | | | | | | On AArch64, GOT references are page relative (ADRP + LDR), so they can't be applied until we know exactly where, within a page, the GOT entry will be in the target address space. Fixes <rdar://problem/18693976>. llvm-svn: 220347
* [MCJIT] Replace memcpy with readBytesUnaligned in RuntimeDyldMachOI386.Lang Hames2014-10-101-4/+2
| | | | | | | This should fix the failures of the MachO_i386_DynNoPIC_relocations.s test case on MIPS hosts. llvm-svn: 219543
* Remove bogus std::error_code returns form SectionRef.Rafael Espindola2014-10-082-16/+8
| | | | | | | | | | | | | | There are two methods in SectionRef that can fail: * getName: The index into the string table can be invalid. * getContents: The section might point to invalid contents. Every other method will always succeed and returning and std::error_code just complicates the code. For example, a section can have an invalid alignment, but if we are able to get to the section structure at all and create a SectionRef, we will always be able to read that invalid alignment. llvm-svn: 219314
* [MCJIT] Add support for ARM HALF_DIFF relocations to MCJIT.Lang Hames2014-09-112-58/+115
| | | | | | Fixes <rdar://problem/18297804>. llvm-svn: 217620
* [MCJIT] Take the relocation addend into account when applying ARM MachO VANILLALang Hames2014-09-111-1/+2
| | | | | | | | and BR24 relocations. <rdar://problem/18296496> llvm-svn: 217605
* [MCJIT] Remove redundant architecture check from RuntimeDyldMachOI386.Lang Hames2014-09-101-1/+1
| | | | llvm-svn: 217470
* [MCJIT] Rewrite RuntimeDyldMachO and its derived classes to use the 'Offset'Lang Hames2014-09-074-9/+9
| | | | | | | | | | field of RelocationValueRef, rather than the 'Addend' field. This is consistent with RuntimeDyldELF's use of RelocationValueRef, and more consistent with the semantics of the data being stored (the offset from the start of a section or symbol). llvm-svn: 217328
* [MCJIT] Make sure eh-frame fixups use the target's pointer type, not the host's.Lang Hames2014-09-044-0/+12
| | | | | | | If the wrong pointer type is used it can cause corruption of the frame description entries. llvm-svn: 217124
* Add override to overriden virtual methods, remove virtual keywords.Benjamin Kramer2014-09-034-4/+4
| | | | | | No functionality change. Changes made by clang-tidy + some manual cleanup. llvm-svn: 217028
* [MCJIT] Move endian-aware read/writes from RuntimeDyldMachO intoLang Hames2014-08-293-4/+4
| | | | | | | | | RuntimeDyldImpl. These are platform independent, and moving them to the base class allows RuntimeDyldChecker to use them too. llvm-svn: 216801
* Canonicalize header guards into a common format.Benjamin Kramer2014-08-134-12/+12
| | | | | | | | | | Add header guards to files that were missing guards. Remove #endif comments as they don't seem common in LLVM (we can easily add them back if we decide they're useful) Changes made by clang-tidy with minor tweaks. llvm-svn: 215558
* [MCJIT] Simplify immediate decoding code in the RuntimeDyldMachO hierarchy.Lang Hames2014-08-084-12/+20
| | | | | | | | | | | Cleanup only: no functional change. This patch makes RuntimeDyldMachO targets directly responsible for decoding immediates, rather than letting them implement catch a callback from generic code. Since this is a very target specific operation, it makes sense to let the target-specific code drive it. llvm-svn: 215255
* [MCJIT] Replace a c-style cast with reinterpret_cast + static_cast.Lang Hames2014-08-071-4/+4
| | | | | | | | | | C-style casts (and reinterpret_casts) result in implementation defined values when a pointer is cast to a larger integer type. On some platforms this was leading to bogus address computations in RuntimeDyldMachOAArch64. This should fix http://llvm.org/PR20501. llvm-svn: 215143
* [MCJIT] Fix an overly-aggressive check in RuntimeDyldMachOARM.Lang Hames2014-08-021-5/+0
| | | | | | | This should fix the MachO_ARM_PIC_relocations.s test failures on some 32-bit testers. llvm-svn: 214613
* [MCJIT] Fix the ARM BR24 relocation in RuntimeDyldMachO.Lang Hames2014-07-304-8/+26
| | | | | | | | | | We now (1) correctly decode the branch immediate, (2) modify the immediate to corretly treat it as PC-rel, and (3) properly populate the stub entry. Previously we had been doing each of these wrong. <rdar://problem/17750739> llvm-svn: 214285
* [RuntimeDyld][AArch64] Make encode/decodeAddend also work on big-endian hosts.Juergen Ributzka2014-07-291-18/+31
| | | | llvm-svn: 214205
* [RuntimeDyld][AArch64] Make encode/decodeAddend more typesafe by using the ↵Juergen Ributzka2014-07-291-6/+8
| | | | | | relocation enum type. NFCI. llvm-svn: 214204
* RuntimeDyldMachOAArch64.h: Fix a warning. [-Wunused-variable]NAKAMURA Takumi2014-07-231-0/+1
| | | | llvm-svn: 213710
* Appease the buildbots.Juergen Ributzka2014-07-221-0/+1
| | | | llvm-svn: 213694
* [RuntimeDyld][MachO][AArch64] Add a helper function for encoding addends in ↵Juergen Ributzka2014-07-221-75/+110
| | | | | | | | | | | | | instructions. Factor out the addend encoding into a helper function and simplify the processRelocationRef. Also add a few simple rtdyld tests. More tests to come once GOTs can be tested too. Related to <rdar://problem/17768539> llvm-svn: 213689
OpenPOWER on IntegriCloud