summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* For COFF and MachO, compute the gap between to symbols.Rafael Espindola2015-05-311-3/+45
| | | | | | Before r238028 we used to do this in O(N^2), now we do it in O(N log N). llvm-svn: 238698
* Use a range loop. NFC.Rafael Espindola2015-05-311-8/+10
| | | | llvm-svn: 238693
* Add RelocVisitor support for MachOKeno Fischer2015-05-301-2/+7
| | | | | | | | | | | | This commit adds partial support for MachO relocations to RelocVisitor. A simple test case is added to show that relocations are indeed being applied and that using llvm-dwarfdump on MachO files no longer errors. Correctness is not yet tested, due to an unrelated bug in DebugInfo, which will be fixed with appropriate testcase in a followup commit. Differential Revision: http://reviews.llvm.org/D8148 llvm-svn: 238663
* Make it easier to use DwarfContext with MCJITKeno Fischer2015-05-211-14/+43
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This supersedes http://reviews.llvm.org/D4010, hopefully properly dealing with the JIT case and also adds an actual test case. DwarfContext was basically already usable for the JIT (and back when we were overwriting ELF files it actually worked out of the box by accident), but in order to resolve relocations correctly it needs to know the load address of the section. Rather than trying to get this out of the ObjectFile or requiring the user to create a new ObjectFile just to get some debug info, this adds the capability to pass in that info directly. As part of this I separated out part of the LoadedObjectInfo struct from RuntimeDyld, since it is now required at a higher layer. Reviewers: lhames, echristo Reviewed By: echristo Subscribers: vtjnash, friss, rafael, llvm-commits Differential Revision: http://reviews.llvm.org/D6961 llvm-svn: 237961
* Remove 3 includes from MCInstrDesc.h and explicitly include them where neededPete Cooper2015-05-151-0/+1
| | | | llvm-svn: 237481
* Move DIContext.h to common DebugInfo location.Zachary Turner2015-04-231-2/+3
| | | | | | | | | | This will enable us to create a PDBContext so as to expose some amount of debug info functionality through a common interace. Differential Revision: http://reviews.llvm.org/D9205 Reviewed by: Alexey Samsonov llvm-svn: 235612
* [RuntimeDyld] Work around a bug in RuntimeDyldELF exposed by r234839.Lang Hames2015-04-151-0/+12
| | | | | | | Hopefully this will fix the failures on the windows builders that started with r234839. llvm-svn: 235043
* Replace the MCSubtargetInfo parameter with a Triple when creatingEric Christopher2015-03-311-1/+1
| | | | | | | an MCInstPrinter. Update all callers and use where we wanted a Triple previously. llvm-svn: 233648
* [MCJIT][Orc] Refactor RTDyldMemoryManager, weave RuntimeDyld::SymbolInfo throughLang Hames2015-03-301-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [Orc][MCJIT][RuntimeDyld] Re-apply r231726 and r231724 with fix suggested byLang Hames2015-03-111-1/+1
| | | | | | Dave Blaikie. Thanks Dave! llvm-svn: 231896
* Temporarily revert r231726 and r231724 as they're breaking the build.:Eric Christopher2015-03-101-1/+1
| | | | | | | | | | | | | | | | | | | Author: Lang Hames <lhames@gmail.com> Date: Mon Mar 9 23:51:09 2015 +0000 [Orc][MCJIT][RuntimeDyld] Add header that was accidentally left out of r231724. Author: Lang Hames <lhames@gmail.com> Date: Mon Mar 9 23:44:13 2015 +0000 [Orc][MCJIT][RuntimeDyld] Add symbol flags to symbols in RuntimeDyld. Thread the new types through MCJIT and Orc. In particular, add a 'weak' flag. When plumbed through RTDyldMemoryManager, this will allow us to distinguish between weak and strong definitions and find the right ones during symbol resolution. llvm-svn: 231731
* [Orc][MCJIT][RuntimeDyld] Add symbol flags to symbols in RuntimeDyld. Thread theLang Hames2015-03-091-1/+1
| | | | | | | | | | new types through MCJIT and Orc. In particular, add a 'weak' flag. When plumbed through RTDyldMemoryManager, this will allow us to distinguish between weak and strong definitions and find the right ones during symbol resolution. llvm-svn: 231724
* Make helper functions static.Benjamin Kramer2015-03-091-4/+4
| | | | | | Found by -Wmissing-prototypes. NFC. llvm-svn: 231664
* Move DebugInfo to DebugInfo/DWARF.Zachary Turner2015-01-301-1/+1
| | | | | | | | | | | | | In preparation for adding PDB support to LLVM, this moves the DWARF parsing code to its own subdirectory under DebugInfo, and renames LLVMDebugInfo to LLVMDebugInfoDWARF. This is purely a mechanical / build system change. Differential Revision: http://reviews.llvm.org/D7269 Reviewed by: Eric Christopher llvm-svn: 227586
* [cleanup] Re-sort all the #include lines in LLVM usingChandler Carruth2015-01-141-2/+2
| | | | | | | | | | | utils/sort_includes.py. I clearly haven't done this in a while, so more changed than usual. This even uncovered a missing include from the InstrProf library that I've added. No functionality changed here, just mechanical cleanup of the include order. llvm-svn: 225974
* [MCJIT] Reapply r222828 and r222810-r222812 with fix for MSVC move-op issues.Lang Hames2014-11-261-18/+38
| | | | llvm-svn: 222840
* Reverting r222828 and r222810-r222812 as they broke the build on Windows.Aaron Ballman2014-11-261-38/+18
| | | | | | 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-261-18/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [MCJIT] Add command-line argument to llvm-rtdyld to specify target addresses forLang Hames2014-09-041-12/+102
| | | | | | | | | sections. This allows fine-grained control of the memory layout of hypothetical target processes for testing purposes. llvm-svn: 217122
* unique_ptrify a bunch of stuff through RuntimeDyld::loadObjectDavid Blaikie2014-09-031-6/+6
| | | | llvm-svn: 217065
* [MCJIT] Make llvm-rtdyld process eh_frame sections in -verify mode (accidentallyLang Hames2014-09-031-0/+4
| | | | | | | | left out of r217010). Also remove a crufty debugging output statement that was accidentally left in. llvm-svn: 217011
* [MCJIT] Make llvm-rtdyld check RuntimeDyld's error state when running in -verifyLang Hames2014-08-051-1/+8
| | | | | | | | | | mode. This will cause -verify mode to report failure when RuntimeDyld encounters an internal error (e.g. overflows in relocation computations). Previously we had let these errors slip past unreported. llvm-svn: 214925
* Use a reference instead of a pointer.Rafael Espindola2014-07-311-1/+1
| | | | | | This makes using a std::unique_ptr in the caller more convenient. llvm-svn: 214433
* [MCJIT] Actually remap sections based llvm-rtdyld options added in r214255.Lang Hames2014-07-301-0/+3
| | | | | | This line was accidentally left out of that patch. llvm-svn: 214282
* [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-271-3/+118
| | | | | | | | | | | | | | | | | | | | 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
* 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-251-1/+61
| | | | | | 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
OpenPOWER on IntegriCloud