Commit Graph

1708 Commits

Author SHA1 Message Date
Lang Hames
458b495075 [MCJIT] Replace memcpy with readBytesUnaligned in RuntimeDyldMachOI386.
This should fix the failures of the MachO_i386_DynNoPIC_relocations.s test case
on MIPS hosts.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219543 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-10 23:07:09 +00:00
Rafael Espindola
8175be535a Remove bogus std::error_code returns form SectionRef.
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219314 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-08 15:28:58 +00:00
Rafael Espindola
1a98f792a5 Fix indentation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219312 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-08 15:12:20 +00:00
Lang Hames
959030a38c [MCJIT] Don't crash in debugging output for sections that aren't emitted.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218836 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 21:57:47 +00:00
Lang Hames
e2ef4419a8 [MCJIT] Turn the getSymbolAddress free function created in r218626 into a static
member of RTDyldMemoryManager (and rename to getSymbolAddressInProcess).

The functionality this provides is very specific to RTDyldMemoryManager, so it
makes sense to keep it in that class to avoid accidental re-use.

No functional change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218741 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 04:11:13 +00:00
David Blaikie
03b4667e14 Unit test r218187, changing RTDyldMemoryManager::getSymbolAddress's behavior favor mangled lookup over unmangled lookup.
The contract of this function seems problematic (fallback in either
direction seems like it could produce bugs in one client or another),
but here's some tests for its current behavior, at least. See the
commit/review thread of r218187 for more discussion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218626 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-29 21:25:13 +00:00
Lang Hames
2bb5b295a4 [MCJIT] Fix some more RuntimeDyld debugging output format specifiers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218328 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-23 19:20:57 +00:00
Lang Hames
e0c253f4e8 [MCJIT] Remove a few more references to JITMemoryManager that survived r218316.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218318 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-23 17:10:24 +00:00
Lang Hames
f718bf7889 [MCJIT] Remove #include of JITMemoryManager that accidentally survived r218316.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218317 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-23 17:02:24 +00:00
Lang Hames
0717be951f [MCJIT] Delete the JTIMemoryManager and associated APIs.
This patch removes the old JIT memory manager (which does not provide any
useful functionality now that the old JIT is gone), and migrates the few
remaining clients over to SectionMemoryManager.

http://llvm.org/PR20848



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218316 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-23 16:56:02 +00:00
Lang Hames
52eebba413 Remove redundant if test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218220 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-21 17:21:56 +00:00
NAKAMURA Takumi
0d61e377a7 RTDyldMemoryManager::getSymbolAddress(): Make sure to return 0 if symbol name is not met. [-Wreturn-type]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218195 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-20 23:58:13 +00:00
Lang Hames
2fd2535b54 [MCJIT] Make RTDyldMemoryManager::getSymbolAddress's behaviour more consistent.
This patch modifies RTDyldMemoryManager::getSymbolAddress(Name)'s behavior to
make it consistent with how clients are using it: Name should be mangled, and
getSymbolAddress should demangle it on the caller's behalf before looking the
name up in the process. This patch also fixes the one client
(MCJIT::getPointerToFunction) that had been passing unmangled names (by having
it pass mangled names instead).

Background:

RTDyldMemoryManager::getSymbolAddress(Name) has always used a re-try mechanism
when looking up symbol names in the current process. Prior to this patch
getSymbolAddress first tried to look up 'Name' exactly as the user passed it in
and then, if that failed, tried to demangle 'Name' and re-try the look up. The
implication of this behavior is that getSymbolAddress expected to be called with
unmangled names, and that handling mangled names was a fallback for convenience.
This is inconsistent with how clients (particularly the RuntimeDyldImpl
subclasses, but also MCJIT) usually use this API. Most clients pass in mangled
names, and succeed only because of the fallback case. For clients passing in
mangled names, getSymbolAddress's old behavior was actually dangerous, as it
could cause unmangled names in the process to shadow mangled names being looked
up.

For example, consider:

foo.c:

int _x = 7;
int x() { return _x; }

foo.o:

000000000000000c D __x
0000000000000000 T _x

If foo.c becomes part of the process (E.g. via dlopen("libfoo.dylib")) it will
add symbols 'x' (the function) and '_x' (the variable) to the process. However
jit clients looking for the function 'x' will be using the mangled function name
'_x' (note how function 'x' appears in foo.o). When getSymbolAddress goes
looking for '_x' it will find the variable instead, and return its address and
in place of the function, leading to JIT'd code calling the variable and
crashing (if we're lucky).

By requiring that getSymbolAddress be called with mangled names, and demangling
only when we're about to do a lookup in the process, the new behavior
implemented in this patch should eliminate any chance of names being shadowed
during lookup.

There's no good way to test this at the moment: This issue only arrises when
looking up process symbols (not JIT'd symbols). Any test case would have to
generate a platform-appropriate dylib to pass to llvm-rtdyld, and I'm not
aware of any in-tree tool for doing this in a portable way.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218187 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-20 17:44:56 +00:00
Chris Bieneman
73f6823621 Converting the JITDebugLock mutex to a ManagedStatic to avoid the static constructor and destructor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218154 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-19 21:38:20 +00:00
Chris Bieneman
7d1a53b823 Converting FuncNames to a ManagedStatic to avoid static constructors and destructors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218151 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-19 21:07:01 +00:00
Lang Hames
d80c0869ee [MCJIT] Fix a debugging-output formatting bug in RuntimeDyld.
The mismatched mask (7 vs (ColsPerRow-1)) could lead to partial lines being
printed out of place.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218061 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-18 16:43:24 +00:00
Reid Kleckner
15b49e12ac Add a missing return to operator=
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217889 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-16 17:39:46 +00:00
Reid Kleckner
61e184dbe5 Fix move-only type issues in Interpreter with MSVC
MSVC 2012 cannot infer any move special members, but it will call them
if available. MSVC 2013 cannot infer move assignment. Therefore,
explicitly implement the special members for the ExecutionContext class
and its contained types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217887 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-16 17:28:15 +00:00
Benjamin Kramer
8be86aaf82 Spell out a move ctor. Even the 2013 vintage of MSVC cannot synthesize move ctors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217879 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-16 16:16:39 +00:00
Benjamin Kramer
a9478c4a96 Interpreter: Hack around a series of bugs in MSVC 2012 that copies around this
move-only struct.

I feel terrible now, but at least it's shielded away from proper compilers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217875 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-16 15:26:41 +00:00
Benjamin Kramer
46738fc43e Add return that was lost somehow in my last commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217810 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-15 19:25:55 +00:00
Benjamin Kramer
9d38b2f76c Remove ancient hack that was emulating move semantics with reference counting.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217808 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-15 19:20:52 +00:00
Lang Hames
b01c85b421 [MCJIT] Start Stringref-izing the ExecutionEngine interface.
More methods to follow.

Using StringRef allows us the EE interface to work with more string types
without forcing construction of std::strings.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217794 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-15 17:50:22 +00:00
Lang Hames
264a325a90 [MCJIT] Improve the "stub not found" diagnostic in RuntimeDyldChecker.
A "stub found found" diagnostic is emitted when RuntimeDyldChecker's stub lookup
logic fails to find the requested stub. The obvious reason for the failure is
that no such stub has been created, but it can also fail for internal symbols if
the symbol offset is not computed correctly (E.g. due to a mangled relocation
addend). This patch adds a comment about the latter case so that it's not
overlooked.

Inspired by confusion experienced during test case construction for r217635.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217643 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-11 23:09:22 +00:00
Lang Hames
67868b5791 [MCJIT] Add support for ARM HALF_DIFF relocations to MCJIT.
Fixes <rdar://problem/18297804>.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217620 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-11 19:21:14 +00:00
Lang Hames
761ca13991 [MCJIT] Take the relocation addend into account when applying ARM MachO VANILLA
and BR24 relocations.

<rdar://problem/18296496>



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217605 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-11 17:27:01 +00:00
Rafael Espindola
3b670550ad Add doInitialization/doFinalization to DataLayoutPass.
With this a DataLayoutPass can be reused for multiple modules.

Once we have doInitialization/doFinalization, it doesn't seem necessary to pass
a Module to the constructor.

Overall this change seems in line with the idea of making DataLayout a required
part of Module. With it the only way of having a DataLayout used is to add it
to the Module.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217548 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-10 21:27:43 +00:00
Lang Hames
d453c22ddb [MCJIT] Remove redundant architecture check from RuntimeDyldMachOI386.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217470 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-10 00:13:42 +00:00
Lang Hames
e3fc1d8cde [MCJIT] Revert partial RuntimeDyldELF cleanup that was prematurely committed in
r217328.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217329 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-07 04:13:13 +00:00
Lang Hames
f0ad482410 [MCJIT] Rewrite RuntimeDyldMachO and its derived classes to use the 'Offset'
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).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217328 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-07 04:03:32 +00:00
Lang Hames
277bb8dd4d [MCJIT] Fix a bug RuntimeDyldImpl's read/writeBytesUnaligned methods.
The previous implementation was writing to the high-bytes of integers on BE
targets (when run on LE hosts).

http://llvm.org/PR20640



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217325 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-07 02:05:26 +00:00
Lang Hames
9a833c573d [MCJIT] Fix an iterator invalidation bug in MCJIT::finalizeObject.
The finalizeObject method calls generateCodeForModule on each of the currently
'added' objects, but generateCodeForModule moves objects out of the 'added'
set as it's called. To avoid iterator invalidation issues, the added set is
copied out before any calls to generateCodeForModule.

This should fix http://llvm.org/PR20851 .


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217291 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-05 23:38:35 +00:00
Lang Hames
9f1eb4d913 [MCJIT] Const-ify the symbol lookup operations on RuntimeDyld.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217263 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-05 18:00:16 +00:00
David Blaikie
1e57caed15 Fix use-after-move introduced in r217065 and caught in post-commit review by Alexey.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217181 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-04 18:37:31 +00:00
David Blaikie
91c286e4ed unique_ptrify RuntimeDyld::Dyld
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217180 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-04 18:37:29 +00:00
Jan Vesely
d3a511ec07 build/cmake: Fix CMP0023 warning with libffi
Fixes:
CMake Warning (dev) at lib/ExecutionEngine/Interpreter/CMakeLists.txt:16 (target_link_libraries):
  Policy CMP0023 is not set: Plain and keyword target_link_libraries
  signatures cannot be mixed.  Run "cmake --help-policy CMP0023" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  The keyword signature for target_link_libraries has already been used with
  the target "LLVMInterpreter".  All uses of target_link_libraries with a
  target should be either all-keyword or all-plain.

  The uses of the keyword signature are here:

   * cmake/modules/AddLLVM.cmake:345 (target_link_libraries)

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217154 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-04 14:21:10 +00:00
Lang Hames
21797d6cd6 [MCJIT] Make sure eh-frame fixups use the target's pointer type, not the host's.
If the wrong pointer type is used it can cause corruption of the frame
description entries.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217124 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-04 04:53:03 +00:00
Lang Hames
5ade584a96 [MCJIT] Add command-line argument to llvm-rtdyld to specify target addresses for
sections.

This allows fine-grained control of the memory layout of hypothetical target
processes for testing purposes.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217122 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-04 04:19:54 +00:00
David Blaikie
1c71488efc unique_ptrify RuntimeDyldImpl::loadObject
I'm not sure this is a particularly helpful API (to pass ownership and
then return it unconditionally) rather than just pass the underlying
object by non-const reference, but this was the original API so I'll
just make it more safe/stable and anyone else is free to adjust that at
their whim, of course.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217081 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-03 21:34:34 +00:00
Chandler Carruth
e361d518d1 [JIT] Add an out-of-line definition for the virtual destructor in
JITEventListener. This used to be in the old JIT (last line of the file)
and everyone just "happened" to pick it up from there. =/ Doh.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217073 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-03 20:39:10 +00:00
David Blaikie
3693c29d1c unique_ptrify MCJIT::emitObject
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217067 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-03 19:57:35 +00:00
David Blaikie
96a8ccfab7 unique_ptrify a bunch of stuff through RuntimeDyld::loadObject
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217065 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-03 19:48:09 +00:00
Benjamin Kramer
a80ff26688 Add override to overriden virtual methods, remove virtual keywords.
No functionality change. Changes made by clang-tidy + some manual cleanup.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217028 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-03 11:41:21 +00:00
Lang Hames
ef279f96e5 [MCJIT] Make llvm-rtdyld process eh_frame sections in -verify mode (accidentally
left out of r217010).

Also remove a crufty debugging output statement that was accidentally left in.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217011 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-03 05:42:52 +00:00
Lang Hames
5ae2647405 [MCJIT] Add a 'section_addr' builtin function to RuntimeDyldChecker.
The syntax of the new builtin is 'section_addr(<filename>, <section-name>)'
(similar to the stub_addr builtin, but without a symbol name). It returns the
base address of the given section in the given object file. This builtin makes
it possible to refer to the contents of sections that cannot contain symbols,
e.g. sections added by the linker itself, like __eh_frame.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217010 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-03 05:01:46 +00:00
David Blaikie
4becee113c unique_ptrify passing the TargetMachine to ExecutionEngine::MCJITCtor
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216988 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-02 22:41:07 +00:00
Eric Christopher
d5dd8ce2a5 Reinstate "Nuke the old JIT."
Approved by Jim Grosbach, Lang Hames, Rafael Espindola.

This reinstates commits r215111, 215115, 215116, 215117, 215136.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216982 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-02 22:28:02 +00:00
Lang Hames
361153e264 [MCJIT] Move endian-aware read/writes from RuntimeDyldMachO into
RuntimeDyldImpl.

These are platform independent, and moving them to the base class allows
RuntimeDyldChecker to use them too.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216801 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-29 23:17:47 +00:00
Robin Morisset
217b38e19a Fix typos in comments, NFC
Summary: Just fixing comments, no functional change.

Test Plan: N/A

Reviewers: jfb

Subscribers: mcrosier, llvm-commits

Differential Revision: http://reviews.llvm.org/D5130

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216784 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-29 21:53:01 +00:00
Lang Hames
41db8128a2 [MCJIT] Fix format specifiers for debug output in RuntimeDyld.
More work on http://llvm.org/PR20640



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216648 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-28 04:25:17 +00:00