diff options
author | Ferenc Wágner <wferi@niif.hu> | 2013-10-13 21:52:53 +0200 |
---|---|---|
committer | Ferenc Wágner <wferi@niif.hu> | 2014-03-01 17:40:34 +0100 |
commit | 351ce48b5a009eb9f3a3a6a21051351a2f0b381b (patch) | |
tree | 2bf5324311d064f0bab28d342b7f79506cda1a52 | |
parent | d75318e4dc8e5c13ce07937bb1708ebcacda4a4c (diff) | |
download | syslinux-351ce48b5a009eb9f3a3a6a21051351a2f0b381b.tar.gz syslinux-351ce48b5a009eb9f3a3a6a21051351a2f0b381b.tar.xz syslinux-351ce48b5a009eb9f3a3a6a21051351a2f0b381b.zip |
lua: enable dynamic module loading
-rw-r--r-- | com32/lua/src/loadlib.c | 45 | ||||
-rw-r--r-- | com32/lua/src/luaconf.h | 3 |
2 files changed, 48 insertions, 0 deletions
diff --git a/com32/lua/src/loadlib.c b/com32/lua/src/loadlib.c index a9959277..39628896 100644 --- a/com32/lua/src/loadlib.c +++ b/com32/lua/src/loadlib.c @@ -212,6 +212,51 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { /* }====================================================== */ +#elif defined(SYSLINUX) +/* +** {========================================================================= +** This is an implementation of loadlib for the Syslinux COM32 module system. +** ========================================================================== +*/ + +#include <sys/module.h> + +static void ll_unloadlib (void *lib) { + module_unload ((struct elf_module *)lib); +} + + +static void *ll_load (lua_State *L, const char *path, int seeglb) { + int err; + struct elf_module *lib = module_alloc (path); + if (lib == NULL) { + lua_pushstring (L, "module not found"); + return NULL; + } + (void)seeglb; /* gcc, ignore it */ + err = module_load (lib); + if (err) { + printf ("module load error: %d\n", err); + lua_pushstring (L, "failed to load module"); + return NULL; + } + return (void *)lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + Elf_Sym *p = module_find_symbol (sym, (struct elf_module *)lib); + if (p == NULL) { + lua_pushstring (L, "symbol not found in module"); + return NULL; + } + return (lua_CFunction)module_get_absolute(p->st_value, (struct elf_module *)lib); +} + +/* }====================================================== */ + + + #else /* ** {====================================================== diff --git a/com32/lua/src/luaconf.h b/com32/lua/src/luaconf.h index fa6546ba..7fd4eaaf 100644 --- a/com32/lua/src/luaconf.h +++ b/com32/lua/src/luaconf.h @@ -97,6 +97,9 @@ #define LUA_CPATH_DEFAULT \ LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll" +#elif defined(SYSLINUX) +#define LUA_PATH_DEFAULT "./?.lua" +#define LUA_CPATH_DEFAULT "./?.c32" #else /* }{ */ #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/" |