viruscamp / luadec

Lua Decompiler for lua 5.1 , 5.2 and 5.3
1.14k stars 343 forks source link

luadec-5.1 fails to compile undefined luaS_new #46

Closed Vigeant closed 8 years ago

Vigeant commented 8 years ago

followinfg the installation instructions for luadec 5.1 on a kali rolling box:

make LUAVER=5.1

gcc -o luadec guess.o luadec.o decompile.o disassemble.o proto.o StringBuffer.o structs.o statement.o macro-array.o expression.o ../lua-5.1/src/liblua.a -lm guess.o: In function luaU_guess_locals': guess.c:(.text+0x8eb): undefined reference toluaS_new' luadec.o: In function strip': luadec.c:(.text+0x87): undefined reference toluaS_new' luadec.c:(.text+0x9c): undefined reference to luaS_new' luadec.o: In functionInject': luadec.c:(.text+0x30c): undefined reference to luaS_new' luadec.o: In functionmain': luadec.c:(.text.startup+0xe6): undefined reference to luaL_loadfilex' decompile.o: In functionFixLocalNames': decompile.c:(.text+0x2637): undefined reference to luaS_new' decompile.c:(.text+0x26c9): undefined reference toluaS_new' decompile.o: In function ProcessSubFunction': decompile.c:(.text+0x3f21): undefined reference toluaS_new' decompile.c:(.text+0x4042): undefined reference to luaS_new' decompile.o: In functionProcessCode': decompile.c:(.text+0x5e37): undefined reference to luaS_new' /usr/bin/ld: luadec: hidden symbolluaS_new' isn't defined /usr/bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit status Makefile:52: recipe for target 'luadec' failed make: *\ [luadec] Error 1

viruscamp commented 8 years ago

The lua source code you used was not official lua-5.1.x code . Maybe you used lua-5.2 or 5.3 code , or a modified 5.1 code.

I think you use 5.2/5.3 header files mixed with 5.1 lib

// lua-5.2
LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, const char *mode);
#define luaL_loadfile(L,f)  luaL_loadfilex(L,f,NULL)

LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
LUAI_FUNC TString *luaS_new (lua_State *L, const char *str);

// lua-5.1
LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename);

#define luaS_new(L, s)  (luaS_newlstr(L, s, strlen(s)))
LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
viruscamp commented 8 years ago

Did you make a 5.2 version before make 5.1 without make clean ?

make LUAVER=5.2
make clean
make LUAVER=5.1