[vlc-devel] [PATCH] configure: detect 32/64-bit lua 5.3 bytecode

Andrey Gursky andrey.gursky at e-mail.ua
Fri Apr 8 01:27:09 CEST 2016


The ABI magic bytes in lua 5.3 bytecode are located at a different
offset than in lua 5.1 or lua 5.2 bytecode. This patch fixes the
detection by distinguishing two cases for <5.3 and 5.3 lua versions.

For documentation purposes:

lua version can be obtained at the offset 4 (e.g. 0051, 0053).
ABI magic bytes (32-bit: 0404) can be obtained:
 - lua 5.1 and 5.2: at the offset 8;
 - lua 5.3: at the offset 12.

$ echo | luac -o - - | od -j 0 -N 100 -t x2

luac5.1 32-bit:
0000000 4c1b 6175 0051 0401 0404 0008 0007 0000
0000020 733d 6474 6e69 0000 0000 0000 0000 0000
0000040 0200 0102 0000 1e00 8000 0000 0000 0000
0000060 0000 0100 0000 0100 0000 0000 0000 0000
0000100 0000 0000

luac5.1 64-bit:
0000000 4c1b 6175 0051 0401 0408 0008 0007 0000
0000020 0000 0000 733d 6474 6e69 0000 0000 0000
0000040 0000 0000 0200 0102 0000 1e00 8000 0000
0000060 0000 0000 0000 0100 0000 0100 0000 0000
0000100 0000 0000 0000 0000

luac5.3 32-bit:
0000000 4c1b 6175 0053 9319 0a0d 0a1a 0404 0804
0000020 7808 0056 0000 0000 0000 0000 0000 7728
0000040 0140 3d07 7473 6964 006e 0000 0000 0000
0000060 0000 0201 0001 0000 0026 0080 0000 0000
0000100 0001 0000 0001 0000 0000 0001 0000 0001
0000120 0000 0000 0000 0001 0000 5f05 4e45 0056

luac5.3 64-bit:
0000000 4c1b 6175 0053 9319 0a0d 0a1a 0804 0804
0000020 7808 0056 0000 0000 0000 0000 0000 7728
0000040 0140 3d07 7473 6964 006e 0000 0000 0000
0000060 0000 0201 0001 0000 0026 0080 0000 0000
0000100 0001 0000 0001 0000 0000 0001 0000 0001
0000120 0000 0000 0000 0001 0000 5f05 4e45 0056
---
 configure.ac | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1842021..5eb0a47 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1554,8 +1554,12 @@ then
   AS_IF([test "${LUAC}" = "false"], [
     AC_MSG_ERROR([Could not find the LUA byte compiler.])
   ])
-  AS_IF([test -d "${CONTRIB_DIR}" -a -f "${CONTRIB_DIR}/lib/liblua.a" -a `echo|${LUAC} -o - -|od -j 8 -N 2 -t x2|head -n 1|tr -s ' '|cut -d' ' -f2` != 0404], [
-    AC_MSG_ERROR([You need 32-bits luac when using lua from contrib.])
+  AS_IF([test -d "${CONTRIB_DIR}" -a -f "${CONTRIB_DIR}/lib/liblua.a"], [
+    lua_ver=`echo|${LUAC} -o - -|od -j 4 -N 2 -t x2|head -n 1|tr -s ' '|cut -d' ' -f2`
+    AS_IF([test ${lua_ver} -lt 53], [lua_abi_offset=8], [lua_abi_offset=12])
+    AS_IF([test `echo|${LUAC} -o - -|od -j ${lua_abi_offset} -N 2 -t x2|head -n 1|tr -s ' '|cut -d' ' -f2` != "0404"], [
+      AC_MSG_ERROR([You need 32-bits luac when using lua from contrib.])
+    ])
   ])
 fi
 AM_CONDITIONAL(BUILD_LUA, [test "${have_lua}" = "yes"])
-- 
2.7.4


More information about the vlc-devel mailing list