[PATCH] D75912: Missing Dyld error handling
Aleksandr via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 10 05:48:48 PDT 2020
keder created this revision.
keder added a reviewer: lhames.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
We are using code generation in our module and have encountered the following problem. There is missing error handling in MCJIT::finalizeLoadedModules in lib/ExecutionEngine/MCJIT/MCJIT.cpp. It calls resolveRelocations of dynamic linker which tries to find missing symbols, in case if symbol is missing in both loaded libraries and in executable, dynamic linker sets error, but MCJIT does not handles it in any way and puts nullptr. It leads to jump on zero address further in program execution.
The fix is quite tiny. I have just added error handling like in other functions of MCJIT. I have no commit access to repository by the way.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75912
Files:
llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
Index: llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
===================================================================
--- llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -239,6 +239,9 @@
// Resolve any outstanding relocations.
Dyld.resolveRelocations();
+ if (Dyld.hasError())
+ report_fatal_error(Dyld.getErrorString());
+
OwnedModules.markAllLoadedModulesAsFinalized();
// Register EH frame data for any module we own which has been loaded
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75912.249326.patch
Type: text/x-patch
Size: 501 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200310/af44b6b9/attachment.bin>
More information about the llvm-commits
mailing list