diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-03-25 10:29:16 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-03-25 10:53:15 -0700 |
commit | f80db17a78b7194761a717435c0ff015c7d92247 (patch) | |
tree | b49220e46b73251ca2534ab438290789b46c3a04 | |
parent | f30db8229e552345724898e39cd142c2a993ef99 (diff) |
emit output variable for calls to absolute values, even though they segfault, to not break validation
-rw-r--r-- | lib/Target/JSBackend/CallHandlers.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/Target/JSBackend/CallHandlers.h b/lib/Target/JSBackend/CallHandlers.h index ab4bc2e950..7079863904 100644 --- a/lib/Target/JSBackend/CallHandlers.h +++ b/lib/Target/JSBackend/CallHandlers.h @@ -32,7 +32,7 @@ const Value *getActuallyCalledValue(const Instruction *I) { DEF_CALL_HANDLER(__default__, { if (!CI) return ""; // we are just called from a handler that was called from getFunctionIndex, only to ensure the handler was run at least once const Value *CV = getActuallyCalledValue(CI); - bool NeedCasts; + bool NeedCasts = true; FunctionType *FT; bool Invoke = false; if (InvokeState == 1) { @@ -66,14 +66,17 @@ DEF_CALL_HANDLER(__default__, { } } } else { - if (isAbsolute(CV)) return "abort(); /* segfault, call an absolute addr */"; - // function pointer call FT = dyn_cast<FunctionType>(dyn_cast<PointerType>(CV->getType())->getElementType()); - ensureFunctionTable(FT); - if (!Invoke) { - Sig = getFunctionSignature(FT, &Name); - Name = std::string("FUNCTION_TABLE_") + Sig + "[" + Name + " & #FM_" + Sig + "#]"; - NeedCasts = false; // function table call, so stays in asm module + if (isAbsolute(CV->stripPointerCasts())) { + Name = "abort /* segfault, call an absolute addr */ "; + } else { + // function pointer call + ensureFunctionTable(FT); + if (!Invoke) { + Sig = getFunctionSignature(FT, &Name); + Name = std::string("FUNCTION_TABLE_") + Sig + "[" + Name + " & #FM_" + Sig + "#]"; + NeedCasts = false; // function table call, so stays in asm module + } } } if (Invoke) { |