(See test_dlfcn_self for an example.)
On Mon, Apr 27, 2015 at 5:16 PM, Alon Zakai <[email protected]> wrote:
> You can use dlopen on the executable itself ("self") and dlsym to get
> function pointers - this was just merged to incoming. Together with
> EMULATE_FUNCTION_POINTER_CASTS , you can call a function pointer without
> knowing the right type.
>
> - Alon
>
>
> On Sat, Apr 25, 2015 at 1:26 AM, <[email protected]> wrote:
>
>> Hi there,
>>
>> I was wondering what would be a possible solution to dynamically call an
>> Emscripten-compiled function within the same application (no dynamic
>> library).
>> The issue is that during compile-time I do not know the target function's
>> signature and therefore do not have static C caller code that could invoke
>> the required function, but must instead build such code during runtime.
>>
>> For native languages there exists libffi for exactly this purpose and it
>> is using assembler code to put function arguments on the stack.
>> I was wondering what the best approach with emscripten is to link a
>> dynamic function call to its target function.
>> The information I have at a possible caller-site is: (function name,
>> function signature, base stack pointer on the heap of the first argument).
>> I was thinking about dynamically building a small asm.js module which
>> reads the arguments from the heap starting at the base pointer and which
>> then builds an appropriate function call.
>> This script I would then eval() in order to get an asm.js-compiled
>> libffi-like interface.
>>
>> Would this be a viable approach?
>>
>> Thanks!
>>
>> Kind regards,
>> Kai
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "emscripten-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.