Re: OSx load luajit 64bit from plugin

  • From: Daniel Kolesa <quaker66@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 21 Jan 2014 16:04:00 +0000

If you want to provide a FFI based API rather than Lua C API based API
within your library, you don't need plugins for that (or exported symbols
from executable) - you can use a simple trick instead - cast a function
pointer to the function you want to expose to void*, then push it as light
userdata on the stack, and ffi.cast on lua side back into the respective
function pointer type - the only place Lua C API is needed in this way is
the cast. This is not portable according to the C(++) standard, but it is
according to POSIX and it also works on Windows and pretty much every sane
architecture (or at least all those luajit would run on) :)


2013/12/24 Coda Highland <chighland@xxxxxxxxx>

> On Tue, Dec 24, 2013 at 10:39 AM, ivan starkov <istarkov@xxxxxxxxx> wrote:
> > On MacOs X luaL_newstate() always return NULL if called from dynamically
> > linked plugin (dlopen).
> >
> > No effect if i set -pagezero_size 10000 -image_base 100000000 on main
> > executable, and make plugin rebase
> > rebase -low_address 150000000 libLuaPlugin.so
> >
> > Is it possible on Osx to use luajit from plugins?
> >
>
> Long story short, the answer is "no." I dealt with the same issue a
> year ago or so. I had to fall back to vanilla Lua and rewrite my FFI
> code to use C API functions instead.
>
> I asked what it would take to make it compatible and apparently it's a
> fairly deep set of changes that would be required.
>
> /s/ Adam
>
>

Other related posts: