summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-rtdyld
Commit message (Collapse)AuthorAgeFilesLines
...
* [MCJIT] Add options to llvm-rtdyld to describe a phony target address space forLang Hames2014-07-291-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | use in -verify mode. This patch adds three hidden command line options to llvm-rtdyld: -target-addr-start <start-addr> : Specify the start of the virtual address space on the phony target. -target-addr-end <end-addr> : Specify the end of the virtual address space on the phony target. -target-section-sep <sep> : Specify the separation (in bytes) between the end of one section and the start of the next. These options automatically default to sane values for the target platform. In particular, they allow narrow (e.g. 32-bit, 16-bit) targets to be tested from wider (e.g. 64-bit, 32-bit) hosts without overflowing pointers. The section separation option defaults to zero, but can be set to a large number (e.g. 1 << 32) to force large separations between sections in order to stress-test large-code-model code. llvm-svn: 214255
* [MCJIT] Refactor and add stub inspection to the RuntimeDyldChecker framework.Lang Hames2014-07-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces a 'stub_addr' builtin that can be used to find the address of the stub for a given (<file>, <section>, <symbol>) tuple. This address can be used both to verify the contents of stubs (by loading from the returned address) and to verify references to stubs (by comparing against the returned address). Example (1) - Verifying stub contents: Load 8 bytes (assuming a 64-bit target) from the stub for 'x' in the __text section of f.o, and compare that value against the addres of 'x'. # rtdyld-check: *{8}(stub_addr(f.o, __text, x) = x Example (2) - Verifying references to stubs: Decode the immediate of the instruction at label 'l', and verify that it's equal to the offset from the next instruction's PC to the stub for 'y' in the __text section of f.o (i.e. it's the correct PC-rel difference). # rtdyld-check: decode_operand(l, 4) = stub_addr(f.o, __text, y) - next_pc(l) l: movq y@GOTPCREL(%rip), %rax Since stub inspection requires cooperation with RuntimeDyldImpl this patch pimpl-ifies RuntimeDyldChecker. Its implementation is moved in to a new class, RuntimeDyldCheckerImpl, that has access to the definition of RuntimeDyldImpl. llvm-svn: 213698
* Update the MemoryBuffer API to use ErrorOr.Rafael Espindola2014-07-061-22/+25
| | | | llvm-svn: 212405
* [RuntimeDyld] Add a framework for testing relocation logic in RuntimeDyld.Lang Hames2014-06-272-3/+120
| | | | | | | | | | | | | | | | | | | | This patch adds a "-verify" mode to the llvm-rtdyld utility. In verify mode, llvm-rtdyld will test supplied expressions against the linked program images that it creates in memory. This scheme can be used to verify the correctness of the relocation logic applied by RuntimeDyld. The expressions to test will be read out of files passed via the -check option (there may be more than one of these). Expressions to check are extracted from lines of the form: # rtdyld-check: <expression> This system is designed to fit the llvm-lit regression test workflow. It is format and target agnostic, and supports verification of images linked for remote targets. The expression language is defined in llvm/include/llvm/RuntimeDyldChecker.h . Examples can be found in test/ExecutionEngine/RuntimeDyld. llvm-svn: 211956
* Remove 'using std::error_code' from tools.Rafael Espindola2014-06-131-5/+4
| | | | llvm-svn: 210876
* Don't use 'using std::error_code' in include/llvm.Rafael Espindola2014-06-121-0/+1
| | | | | | This should make sure that most new uses use the std prefix. llvm-svn: 210835
* Remove system_error.h.Rafael Espindola2014-06-121-1/+1
| | | | | | | This is a minimal change to remove the header. I will remove the occurrences of "using std::error_code" in a followup patch. llvm-svn: 210803
* [tools][llvm-rtdyld] Add a '-dylib <file>' option to llvm-rtdyld to load sharedLang Hames2014-05-131-0/+25
| | | | | | | | | libraries before linking and executing the target objects. This allows programs that use external calls (e.g. to libc) to be run under llvm-rtdyld. llvm-svn: 208739
* [C++] Use 'nullptr'. Tools edition.Craig Topper2014-04-251-5/+5
| | | | llvm-svn: 207176
* [DWARF parser] Turn DILineInfo into a struct.Alexey Samsonov2014-04-181-2/+1
| | | | | | | | | | Immutable DILineInfo doesn't bring any benefits and complicates code. Also, use std::string instead of SmallString<16> for file and function names - their length can vary significantly. No functionality change. llvm-svn: 206654
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-081-5/+6
| | | | | | class. llvm-svn: 203345
* Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles2014-03-061-6/+6
| | | | | | | | | | This compiles with no changes to clang/lld/lldb with MSVC and includes overloads to various functions which are used by those projects and llvm which have OwningPtr's as parameters. This should allow out of tree projects some time to move. There are also no changes to libs/Target, which should help out of tree targets have time to move, if necessary. llvm-svn: 203083
* [C++11] Replace OwningPtr::take() with OwningPtr::release().Ahmed Charles2014-03-051-2/+2
| | | | llvm-svn: 202957
* Simplify the handling of iterators in ObjectFile.Rafael Espindola2014-01-301-3/+1
| | | | | | | | | | | | None of the object file formats reported error on iterator increment. In retrospect, that is not too surprising: no object format stores symbols or sections in a linked list or other structure that requires chasing pointers. As a consequence, all error checking can be done on begin() and end(). This reduces the text segment of bin/llvm-readobj in my machine from 521233 to 518526 bytes. llvm-svn: 200442
* [CMake] Update LLVM_LINK_COMPONENTS for each CMakeLists.txt.NAKAMURA Takumi2013-12-101-1/+6
| | | | llvm-svn: 196908
* Suppress OS crash dialog in llvm-rtdyldAlp Toker2013-11-051-0/+5
| | | | | | | All other tools have this -- it's needed to avoid hanging lit on Windows in case of a crash. llvm-svn: 194060
* This threads SectionName through the allocateCodeSection/allocateDataSection ↵Filip Pizlo2013-10-021-3/+6
| | | | | | | | | | | | | | | | | | APIs, both in C++ and C land. It's useful for the memory managers that are allocating a section to know what the name of the section is. At a minimum, this is useful for low-level debugging - it's customary for JITs to be able to tell you what memory they allocated, and as part of any such dump, they should be able to tell you some meta-data about what each allocation is for. This allows clients that supply their own memory managers to do this. Additionally, we also envision the SectionName being useful for passing meta-data from within LLVM to an LLVM client. This changes both the C and C++ APIs, and all of the clients of those APIs within LLVM. I'm assuming that it's safe to change the C++ API because that API is allowed to change. I'm assuming that it's safe to change the C API because we haven't shipped the API in a release yet (LLVM 3.3 doesn't include the MCJIT memory management C API). llvm-svn: 191804
* Unbreak llvm-rtdyld build.Benjamin Kramer2013-08-031-3/+3
| | | | llvm-svn: 187699
* llvm-rtdyld: Don't leak memory managers.Benjamin Kramer2013-08-031-4/+4
| | | | | | Dyld never outlives MemMgr, just put both on the stack. llvm-svn: 187697
* Minor changes to the MCJITTest unittests to use the correct API for finalizingDavid Tweed2013-05-171-1/+1
| | | | | | | the JIT object (including XFAIL an ARM test that now needs fixing). Also renames internal function for consistency. llvm-svn: 182085
* Use llvm/Object/MachO.h in macho-dumper. Drop the old macho parser.Rafael Espindola2013-04-261-1/+1
| | | | | | | | | | | | | | | | | | | | | For Mach-O there were 2 implementations for parsing object files. A standalone llvm/Object/MachOObject.h and llvm/Object/MachO.h which implements the generic interface in llvm/Object/ObjectFile.h. This patch adds the missing features to MachO.h, moves macho-dump to use MachO.h and removes ObjectFile.h. In addition to making sure that check-all is clean, I checked that the new version produces exactly the same output in all Mach-O files in a llvm+clang build directory (including executables and shared libraries). To test the performance, I ran macho-dump over all the files in a llvm+clang build directory again, but this time redirecting the output to /dev/null. Both the old and new versions take about 4.6 seconds (2.5 user) to finish. llvm-svn: 180624
* Add DIContext::getLineInfoForAddressRange() function and test. This ↵Andrew Kaylor2013-01-261-2/+8
| | | | | | function allows a caller to obtain a table of line information for a function using the function's address and size. llvm-svn: 173537
* Add support for applying in-memory relocations to the .debug_line section ↵Andrew Kaylor2013-01-253-3/+63
| | | | | | and, in the case of ELF files, using symbol addresses when available for relocations to the .debug_info section. Also extending the llvm-rtdyld tool to add the ability to dump line number information for testing purposes. llvm-svn: 173517
* Sort the #include lines for tools/...Chandler Carruth2012-12-041-3/+3
| | | | | | | | Again, tools are trickier to pick the main module header for than library source files. I've started to follow the pattern of using LLVMContext.h when it is included as a stub for program source files. llvm-svn: 169252
* Interface changes to allow RuntimeDyld memory managers to set memory ↵Andrew Kaylor2012-11-151-2/+5
| | | | | | permissions after an object has been loaded. llvm-svn: 168114
* Clean-up of memory buffer and object ownership model in MCJITAndrew Kaylor2012-10-021-2/+6
| | | | llvm-svn: 165053
* Added LLIMCJITMemoryManager to the lli. This manager will be used for MCJIT ↵Danil Malyshev2012-05-161-2/+23
| | | | | | | | instead of DefaultJIMMemoryManager. It's more flexible for MCJIT tasks, in addition it's provides a invalidation instruction cache for code sections which will be used before JIT code will be executed. llvm-svn: 156933
* Re-factored RuntimeDyLd:Danil Malyshev2012-03-301-16/+0
| | | | | | | | | | | | | | | 1. The main works will made in the RuntimeDyLdImpl with uses the ObjectFile class. RuntimeDyLdMachO and RuntimeDyLdELF now only parses relocations and resolve it. This is allows to make improvements of the RuntimeDyLd more easily. In addition the support for COFF can be easily added. 2. Added ARM relocations to RuntimeDyLdELF. 3. Added support for stub functions for the ARM, allowing to do a long branch. 4. Added support for external functions that are not loaded from the object files, but can be loaded from external libraries. Now MCJIT can correctly execute the code containing the printf, putc, and etc. 5. The sections emitted instead functions, thanks Jim Grosbach. MemoryManager.startFunctionBody() and MemoryManager.endFunctionBody() have been removed. 6. MCJITMemoryManager.allocateDataSection() and MCJITMemoryManager. allocateCodeSection() used JMM->allocateSpace() instead of JMM->allocateCodeSection() and JMM->allocateDataSection(), because I got an error: "Cannot allocate an allocated block!" with object file contains more than one code or data sections. llvm-svn: 153754
* Revert r153694. It was causing failures in the buildbots.Bill Wendling2012-03-291-0/+16
| | | | llvm-svn: 153701
* Re-factored RuntimeDyld.Danil Malyshev2012-03-291-16/+0
| | | | | | Added ExecutionEngine/MCJIT tests. llvm-svn: 153694
* Move getPointerToNamedFunction() from JIT/MCJIT to JITMemoryManager.Danil Malyshev2012-03-281-0/+6
| | | | llvm-svn: 153607
* Revert a series of commits to MCJIT to get the build working in CMakeChandler Carruth2012-03-221-5/+15
| | | | | | | | | | | | | | | (and hopefully on Windows). The bots have been down most of the day because of this, and it's not clear to me what all will be required to fix it. The commits started with r153205, then r153207, r153208, and r153221. The first commit seems to be the real culprit, but I couldn't revert a smaller number of patches. When resubmitting, r153207 and r153208 should be folded into r153205, they were simple build fixes. llvm-svn: 153241
* Re-factored RuntimeDyld.Danil Malyshev2012-03-211-16/+0
| | | | | | Added ExecutionEngine/MCJIT tests. llvm-svn: 153221
* (no commit message)Danil Malyshev2012-03-211-0/+6
| | | | llvm-svn: 153208
* Remove unreachable code. (replace with llvm_unreachable to help GCC where ↵David Blaikie2012-01-171-2/+0
| | | | | | necessary) llvm-svn: 148284
* MCJIT support for non-function sections.Jim Grosbach2012-01-161-0/+18
| | | | | | | | | | | | | | | | Move to a by-section allocation and relocation scheme. This allows better support for sections which do not contain externally visible symbols. Flesh out the relocation address vs. local storage address separation a bit more as well. Remote process JITs use this to tell the relocation resolution code where the code will live when it executes. The startFunctionBody/endFunctionBody interfaces to the JIT and the memory manager are deprecated. They'll stick around for as long as the old JIT does, but the MCJIT doesn't use them anymore. llvm-svn: 148258
* Remove unnecessary default cases in switches that cover all enum values.David Blaikie2012-01-101-1/+0
| | | | llvm-svn: 147855
* LLVMBuild: Remove trailing newline, which irked me.Daniel Dunbar2011-12-121-1/+0
| | | | llvm-svn: 146409
* LLVMBuild: Add description files for the LLVM tools.Daniel Dunbar2011-11-111-0/+23
| | | | llvm-svn: 144417
* build: Tidy up a bunch of tool Makefiles, and simplify where possible using theDaniel Dunbar2011-10-181-11/+5
| | | | | | new all-targets pseudo-component. llvm-svn: 142401
* Load multiple object files and link them via RuntimeDyld in llvm-rtdyld.Jim Grosbach2011-04-131-13/+23
| | | | | | | | | | | | | | | | | | | | | | Relocations between the object modules are properly resolved, as in the following trivial example: $ cat t.c int foo(); int main() { return foo(); } $ cat foo.c int foo() { return 65; } $ clang -c t.c -fno-asynchronous-unwind-tables $ clang -c foo.c -fno-asynchronous-unwind-tables $ llvm-rtdyld t.o foo.o ; echo $? loaded '_main' at: 0x10015c000 65 llvm-svn: 129448
* Allow user-specified program entry point for llvm-rtdyld.Jim Grosbach2011-04-131-3/+8
| | | | llvm-svn: 129446
* MCJIT lazy relocation resolution and symbol address re-assignment.Jim Grosbach2011-04-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add handling for tracking the relocations on symbols and resolving them. Keep track of the relocations even after they are resolved so that if the RuntimeDyld client moves the object, it can update the address and any relocations to that object will be updated. For our trival object file load/run test harness (llvm-rtdyld), this enables relocations between functions located in the same object module. It should be trivially extendable to load multiple objects with mutual references. As a simple example, the following now works (running on x86_64 Darwin 10.6): $ cat t.c int bar() { return 65; } int main() { return bar(); } $ clang t.c -fno-asynchronous-unwind-tables -o t.o -c $ otool -vt t.o t.o: (__TEXT,__text) section _bar: 0000000000000000 pushq %rbp 0000000000000001 movq %rsp,%rbp 0000000000000004 movl $0x00000041,%eax 0000000000000009 popq %rbp 000000000000000a ret 000000000000000b nopl 0x00(%rax,%rax) _main: 0000000000000010 pushq %rbp 0000000000000011 movq %rsp,%rbp 0000000000000014 subq $0x10,%rsp 0000000000000018 movl $0x00000000,0xfc(%rbp) 000000000000001f callq 0x00000024 0000000000000024 addq $0x10,%rsp 0000000000000028 popq %rbp 0000000000000029 ret $ llvm-rtdyld t.o -debug-only=dyld ; echo $? Function sym: '_bar' @ 0 Function sym: '_main' @ 16 Extracting function: _bar from [0, 15] allocated to 0x100153000 Extracting function: _main from [16, 41] allocated to 0x100154000 Relocation at '_main' + 16 from '_bar(Word1: 0x2d000000) Resolving relocation at '_main' + 16 (0x100154010) from '_bar (0x100153000)(pcrel, type: 2, Size: 4). loaded '_main' at: 0x100154000 65 $ llvm-svn: 129388
* Tidy up a bit now that we're using the MemoryManager interface.Jim Grosbach2011-04-121-9/+21
| | | | llvm-svn: 129328
* Refactor MCJIT 32-bit section loading.Jim Grosbach2011-04-081-1/+1
| | | | | | | Teach 32-bit section loading to use the Memory Manager interface, just like the 64-bit loading does. Tidy up a few other things here and there. llvm-svn: 129138
* RuntimeDyld should use the memory manager API.Jim Grosbach2011-04-061-5/+5
| | | | | | | | | | Start teaching the runtime Dyld interface to use the memory manager API for allocating space. Rather than mapping directly into the MachO object, we extract the payload for each object and copy it into a dedicated buffer allocated via the memory manager. For now, just do Segment64, so this works on x86_64, but not yet on ARM. llvm-svn: 128973
* Layer the memory manager between the JIT and the runtime Dyld.Jim Grosbach2011-04-041-4/+17
| | | | | | | | | | | The JITMemory manager references LLVM IR constructs directly, while the runtime Dyld works at a lower level and can handle objects which may not originate from LLVM IR. Introduce a new layer for the memory manager to handle the interface between them. For the MCJIT, this layer will be almost entirely simply a call-through w/ translation between the IR objects and symbol names. llvm-svn: 128851
* Update CMake link dependency.Francois Pichet2011-03-291-1/+1
| | | | llvm-svn: 128503
* Instantiate a JITMemoryManager for MCJIT DyldJim Grosbach2011-03-292-2/+3
| | | | llvm-svn: 128485
* Propogate the error message, not just the error state.Jim Grosbach2011-03-221-2/+3
| | | | llvm-svn: 128094
OpenPOWER on IntegriCloud