From f80db17a78b7194761a717435c0ff015c7d92247 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 25 Mar 2014 10:29:16 -0700 Subject: emit output variable for calls to absolute values, even though they segfault, to not break validation --- lib/Target/JSBackend/CallHandlers.h | 19 +++++++++++-------- 1 file 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(dyn_cast(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) { -- cgit v1.2.3-18-g5258