diff options
| author | ruki <[email protected]> | 2026-01-30 22:41:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-01-30 22:41:30 +0800 |
| commit | 8a9d19e08aea07be760882d629fa90f4ab7c2da3 (patch) | |
| tree | 511a6dedd30c12e0a1b9da4b9f6d0b95ec52a06d /core | |
| parent | 9b87a6b6885d004d445f021b9536d08a18225351 (diff) | |
detect ape format
Diffstat (limited to 'core')
| -rw-r--r-- | core/src/xmake/binutils/format.c | 12 | ||||
| -rw-r--r-- | core/src/xmake/binutils/prefix.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/core/src/xmake/binutils/format.c b/core/src/xmake/binutils/format.c index 670dec46b..240449f85 100644 --- a/core/src/xmake/binutils/format.c +++ b/core/src/xmake/binutils/format.c @@ -88,6 +88,12 @@ static __tb_inline__ tb_bool_t xm_binutils_format_is_shebang(tb_byte_t const* fi return first2[0] == '#' && first2[1] == '!'; } +static __tb_inline__ tb_bool_t xm_binutils_format_is_ape(tb_byte_t const* first8) { + return first8[0] == 'M' && first8[1] == 'Z' && + first8[2] == 'q' && first8[3] == 'F' && + first8[4] == 'p' && first8[5] == 'D'; +} + static __tb_inline__ tb_bool_t xm_binutils_format_is_elf(tb_byte_t const* first8) { return first8[0] == 0x7f && first8[1] == 'E' && first8[2] == 'L' && first8[3] == 'F'; } @@ -156,6 +162,11 @@ tb_int_t xm_binutils_format_detect(tb_stream_ref_t istream) { break; } + if (xm_binutils_format_is_ape(p)) { + format = XM_BINUTILS_FORMAT_APE; + break; + } + if (xm_binutils_format_is_elf(p)) { format = XM_BINUTILS_FORMAT_ELF; break; @@ -228,6 +239,7 @@ tb_int_t xm_binutils_format(lua_State *lua) { case XM_BINUTILS_FORMAT_AR: lua_pushliteral(lua, "ar"); break; case XM_BINUTILS_FORMAT_PE: lua_pushliteral(lua, "pe"); break; case XM_BINUTILS_FORMAT_SHEBANG: lua_pushliteral(lua, "shebang"); break; + case XM_BINUTILS_FORMAT_APE: lua_pushliteral(lua, "ape"); break; default: lua_pushliteral(lua, "unknown"); break; } diff --git a/core/src/xmake/binutils/prefix.h b/core/src/xmake/binutils/prefix.h index 482895c22..b3ffd8c27 100644 --- a/core/src/xmake/binutils/prefix.h +++ b/core/src/xmake/binutils/prefix.h @@ -35,6 +35,7 @@ #define XM_BINUTILS_FORMAT_AR 4 #define XM_BINUTILS_FORMAT_PE 5 #define XM_BINUTILS_FORMAT_SHEBANG 6 +#define XM_BINUTILS_FORMAT_APE 7 #define XM_BINUTILS_FORMAT_UNKNOWN 0 // COFF machine types (for format detection) |
