Commit Graph

35 Commits

Author SHA1 Message Date
Andrew Kaylor 9a8ff813f3 Add DIContext::getLineInfoForAddressRange() function and test. This function allows a caller to obtain a table of line information for a function using the function's address and size.
llvm-svn: 173537
2013-01-26 00:28:05 +00:00
Andrew Kaylor d55d7019fc Add support for applying in-memory relocations to the .debug_line section 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
2013-01-25 22:50:58 +00:00
Chandler Carruth 4d88a1c233 Sort the #include lines for tools/...
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
2012-12-04 10:44:52 +00:00
Andrew Kaylor a342cb9613 Interface changes to allow RuntimeDyld memory managers to set memory permissions after an object has been loaded.
llvm-svn: 168114
2012-11-15 23:50:01 +00:00
Andrew Kaylor adc70568f9 Clean-up of memory buffer and object ownership model in MCJIT
llvm-svn: 165053
2012-10-02 21:18:39 +00:00
Danil Malyshev 8c17fbd6c1 Added LLIMCJITMemoryManager to the lli. This manager will be used for MCJIT 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
2012-05-16 18:50:11 +00:00
Danil Malyshev 70d22ccb22 Re-factored RuntimeDyLd:
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
2012-03-30 16:45:19 +00:00
Bill Wendling 76fdc4b885 Revert r153694. It was causing failures in the buildbots.
llvm-svn: 153701
2012-03-29 23:23:59 +00:00
Danil Malyshev 3548eaf896 Re-factored RuntimeDyld.
Added ExecutionEngine/MCJIT tests.

llvm-svn: 153694
2012-03-29 21:46:18 +00:00
Danil Malyshev bfee542cce Move getPointerToNamedFunction() from JIT/MCJIT to JITMemoryManager.
llvm-svn: 153607
2012-03-28 21:46:36 +00:00
Chandler Carruth e26dafeb79 Revert a series of commits to MCJIT to get the build working in CMake
(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
2012-03-22 05:44:06 +00:00
Danil Malyshev 70186bef8b Re-factored RuntimeDyld.
Added ExecutionEngine/MCJIT tests.

llvm-svn: 153221
2012-03-21 21:06:29 +00:00
Danil Malyshev 25753cd972 (no commit message)
llvm-svn: 153208
2012-03-21 19:13:08 +00:00
David Blaikie b48ed1a4cb Remove unreachable code. (replace with llvm_unreachable to help GCC where necessary)
llvm-svn: 148284
2012-01-17 04:43:56 +00:00
Jim Grosbach eff0a40d7e MCJIT support for non-function sections.
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
2012-01-16 22:26:39 +00:00
David Blaikie edbb58c577 Remove unnecessary default cases in switches that cover all enum values.
llvm-svn: 147855
2012-01-10 16:47:17 +00:00
Daniel Dunbar 27a7489a03 LLVMBuild: Remove trailing newline, which irked me.
llvm-svn: 146409
2011-12-12 19:48:00 +00:00
Daniel Dunbar 57fb3ae997 LLVMBuild: Add description files for the LLVM tools.
llvm-svn: 144417
2011-11-11 22:59:39 +00:00
Daniel Dunbar 96d812a68d build: Tidy up a bunch of tool Makefiles, and simplify where possible using the
new all-targets pseudo-component.

llvm-svn: 142401
2011-10-18 19:27:24 +00:00
Jim Grosbach 7cb41d787d Load multiple object files and link them via RuntimeDyld in llvm-rtdyld.
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
2011-04-13 15:49:40 +00:00
Jim Grosbach d35159a177 Allow user-specified program entry point for llvm-rtdyld.
llvm-svn: 129446
2011-04-13 15:38:30 +00:00
Jim Grosbach 733d305fee MCJIT lazy relocation resolution and symbol address re-assignment.
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
2011-04-12 21:20:41 +00:00
Jim Grosbach 3ed03f18d1 Tidy up a bit now that we're using the MemoryManager interface.
llvm-svn: 129328
2011-04-12 00:23:32 +00:00
Jim Grosbach 18b81c52bb Refactor MCJIT 32-bit section loading.
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
2011-04-08 17:31:24 +00:00
Jim Grosbach 23de2437bd RuntimeDyld should use the memory manager API.
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
2011-04-06 01:11:05 +00:00
Jim Grosbach 2dcef0505f Layer the memory manager between the JIT and the runtime Dyld.
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
2011-04-04 23:04:39 +00:00
Francois Pichet c68476480e Update CMake link dependency.
llvm-svn: 128503
2011-03-29 23:18:51 +00:00
Jim Grosbach 6cfbcc8954 Instantiate a JITMemoryManager for MCJIT Dyld
llvm-svn: 128485
2011-03-29 21:03:05 +00:00
Jim Grosbach 40411cc409 Propogate the error message, not just the error state.
llvm-svn: 128094
2011-03-22 18:19:42 +00:00
Oscar Fuentes e4840e2918 Build the new RuntimeDyld library.
llvm-svn: 128035
2011-03-21 23:07:53 +00:00
Jim Grosbach f016b0a359 Library-ize the dyld components of llvm-rtdyld.
Move the dynamic linking functionality of the llvm-rtdyld program into an
ExecutionEngine support library. Update llvm-rtdyld to just load an object
file into memory, use the library to process it, then run the _main()
function, if one is found.

llvm-svn: 128031
2011-03-21 22:15:52 +00:00
Jim Grosbach 486e57f694 Add llvm-rtdyld support for loading 32-bit code.
Factor out the 64-bit specific bits into a helper function and add an
equivalent that loads the 32-bit sections. This allows using llvm-rtdyld on ARM.

llvm-svn: 127892
2011-03-18 18:54:32 +00:00
Oscar Fuentes 9d8ffa9dba Update list of link components for llvm-rtdyld.
llvm-svn: 127887
2011-03-18 17:27:04 +00:00
Jim Grosbach 4d5284b44b Naming conventional tidy up.
llvm-svn: 127886
2011-03-18 17:24:21 +00:00
Jim Grosbach 0072cdbc50 MachO file loader and execution utility.
Add a bone-simple utility to load a MachO object into memory, look for
a function (main) in it, and run that function directly. This will be used
as a test and development platform for MC-JIT work regarding symbol resolution,
dynamic lookup, etc..

Code by Daniel Dunbar.

llvm-svn: 127885
2011-03-18 17:11:39 +00:00