diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-05-05 20:43:10 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-05-05 20:43:10 +0000 |
commit | fa5942bc2c870d63b02a936ab7e2ce5a5bace768 (patch) | |
tree | bad05903cb958bdb729317b41ac7c37888487682 /llvm/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp | |
parent | 78852e91c8e46344600bac984c1f2b37d6af5060 (diff) | |
download | bcm5719-llvm-fa5942bc2c870d63b02a936ab7e2ce5a5bace768.tar.gz bcm5719-llvm-fa5942bc2c870d63b02a936ab7e2ce5a5bace768.zip |
Add EH support to the MCJIT.
This gets exception handling working on ELF and Macho (x86-64 at least).
Other than the EH frame registration, this patch also implements support
for GOT relocations which are used to locate the personality function on
MachO.
llvm-svn: 181167
Diffstat (limited to 'llvm/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp')
-rw-r--r-- | llvm/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp b/llvm/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp index da931247b6c..bac77ce75f4 100644 --- a/llvm/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp +++ b/llvm/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp @@ -146,6 +146,38 @@ bool SectionMemoryManager::applyPermissions(std::string *ErrMsg) return false; } +// Determine whether we can register EH tables. +#if (defined(__GNUC__) && !defined(__ARM_EABI__) && \ + !defined(__USING_SJLJ_EXCEPTIONS__)) +#define HAVE_EHTABLE_SUPPORT 1 +#else +#define HAVE_EHTABLE_SUPPORT 0 +#endif + +#if HAVE_EHTABLE_SUPPORT +extern "C" void __register_frame(void*); + +static const char *processFDE(const char *Entry) { + const char *P = Entry; + uint32_t Length = *((uint32_t*)P); + P += 4; + uint32_t Offset = *((uint32_t*)P); + if (Offset != 0) + __register_frame((void*)Entry); + return P + Length; +} +#endif + +void SectionMemoryManager::registerEHFrames(StringRef SectionData) { +#if HAVE_EHTABLE_SUPPORT + const char *P = SectionData.data(); + const char *End = SectionData.data() + SectionData.size(); + do { + P = processFDE(P); + } while(P != End); +#endif +} + error_code SectionMemoryManager::applyMemoryGroupPermissions(MemoryGroup &MemGroup, unsigned Permissions) { |