diff options
Diffstat (limited to 'core/src/xmake/binutils/prefix.h')
| -rw-r--r-- | core/src/xmake/binutils/prefix.h | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/core/src/xmake/binutils/prefix.h b/core/src/xmake/binutils/prefix.h index 608424958..ba7b06f12 100644 --- a/core/src/xmake/binutils/prefix.h +++ b/core/src/xmake/binutils/prefix.h @@ -205,8 +205,8 @@ static __tb_inline__ tb_bool_t xm_binutils_arch_is_64bit(tb_char_t const *arch) else if (tb_strcmp(arch, "s390x") == 0) { return tb_true; } - // LoongArch64 - else if (tb_strncmp(arch, "loongarch64", 11) == 0) { + // LoongArch64 (xmake uses "loong64" as the canonical arch name) + else if (tb_strncmp(arch, "loongarch64", 11) == 0 || tb_strcmp(arch, "loong64") == 0) { return tb_true; } // WebAssembly 64 @@ -220,5 +220,44 @@ static __tb_inline__ tb_bool_t xm_binutils_arch_is_64bit(tb_char_t const *arch) return tb_false; } +/* check if architecture is big-endian + * + * @param arch the architecture string + * @return tb_true if big-endian, tb_false otherwise + */ +static __tb_inline__ tb_bool_t xm_binutils_arch_is_bigendian(tb_char_t const *arch) { + if (!arch) { + return tb_false; + } + // s390/s390x are always big-endian + if (tb_strcmp(arch, "s390x") == 0 || tb_strcmp(arch, "s390") == 0) { + return tb_true; + } + // SPARC is big-endian + else if (tb_strncmp(arch, "sparc", 5) == 0) { + return tb_true; + } + // MIPS big-endian variants (mips, mips64), the little-endian ones end with "el" (mipsel, mips64el) + else if (tb_strncmp(arch, "mips", 4) == 0) { + return tb_strstr(arch, "el") == tb_null; + } + /* PowerPC endianness: + * - an explicit "le"/"be" suffix always wins (ppc64le/powerpc64le, ppc64be) + * - otherwise 64-bit ppc64/powerpc64 defaults to little-endian: xmake has no separate + * ppc64le arch (find_platform maps powerpc64le -> ppc64) and ppc64le is the dominant + * modern target, so a plain "ppc64" is treated as ppc64le (LE + OpenPOWER ELFv2) + * - 32-bit ppc stays traditional big-endian + */ + else if (tb_strncmp(arch, "ppc", 3) == 0 || tb_strncmp(arch, "powerpc", 7) == 0) { + if (tb_strstr(arch, "le")) { + return tb_false; + } else if (tb_strstr(arch, "be")) { + return tb_true; + } + return !xm_binutils_arch_is_64bit(arch); + } + return tb_false; +} + #endif |
