tursodatabase/turso · error · SystemExit

{path} has unsupported ELF class {elf_class}

Error message

{path} has unsupported ELF class {elf_class}

What it means

This check script parses an ELF binary to verify its dynamic symbol exports. It only supports ELF32 and ELF64 class values (1 and 2) in the e_ident header; any other class byte means the file is not a recognizable ELF class, so the script exits immediately with this message naming the file and the raw class value.

Source

Thrown at bindings/dotnet/scripts/check_elf_dynsym_exports.py:124

            "endian": endian,
            "section_header_offset": struct.unpack_from(endian + "Q", data, 40)[0],
            "section_header_size": struct.unpack_from(endian + "H", data, 58)[0],
            "section_count": struct.unpack_from(endian + "H", data, 60)[0],
            "string_table_index": struct.unpack_from(endian + "H", data, 62)[0],
            "section_format": endian + "IIQQQQIIQQ",
            "symbol_format": endian + "IBBHQQ",
        }
    if elf_class == 1:
        return {
            "endian": endian,
            "section_header_offset": struct.unpack_from(endian + "I", data, 32)[0],
            "section_header_size": struct.unpack_from(endian + "H", data, 46)[0],
            "section_count": struct.unpack_from(endian + "H", data, 48)[0],
            "string_table_index": struct.unpack_from(endian + "H", data, 50)[0],
            "section_format": endian + "IIIIIIIIII",
            "symbol_format": endian + "IIIBBH",
        }
    raise SystemExit(f"{path} has unsupported ELF class {elf_class}")


def find_dynsym(data: bytes, layout: dict, path: Path):
    string_header = section_header(data, layout, layout["string_table_index"])
    names = slice_bytes(data, string_header[OFFSET], string_header[SIZE])
    named = None
    typed = None
    for index in range(layout["section_count"]):
        header = section_header(data, layout, index)
        name = names[header[NAME] :].split(b"\x00", 1)[0]
        if name == b".dynsym":
            named = header
            break
        if typed is None and header[TYPE] == 11:
            typed = header
    dynsym = named or typed
    if dynsym is None:
        raise SystemExit(f"{path} has no .dynsym section")

View on GitHub (pinned to 492c4a71cd)

Solutions

  1. Verify the file is actually ELF: run `file <path>` and check the reported class matches ELF32/ELF64.
  2. Check for truncation/corruption: compare file size against expected artifact size or re-download/rebuild the binary.
  3. Fix the script/CI to point at the correct .so or binary artifact, not an intermediate file.
  4. If a new ELF class genuinely needs support, extend elf_layout to handle it.

Example fix

// before
python check_elf_dynsym_exports.py build/tmp/output.bin
// after
python check_elf_dynsym_exports.py build/target/release/libturso.so
Defensive patterns

Strategy: validation

Validate before calling

import struct
from pathlib import Path
def is_supported_elf(path: Path) -> bool:
    data = path.read_bytes()
    return len(data) > 4 and data[:4] == b"\x7fELF" and data[4] in (1, 2)

Prevention

When it happens

Trigger: Running check_elf_dynsym_exports.py on a file whose ELF identification bytes at offset 4 are not 1 (ELFCLASS32) or 2 (ELFCLASS64) — e.g. a truncated ELF, a corrupted binary, or a non-ELF file accidentally passed in.

Common situations: CI packaging checks pointing at the wrong artifact (a stub, a text file, or an architecture-specific binary with a mangled header); cross-compilation output that is actually not ELF (e.g. a Windows PE or Mach-O file); a partially downloaded/truncated .so.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of tursodatabase/turso@492c4a71cd (2026-09-13). Data as JSON: /api/errors/5ecb8069155edd58. Report an issue: GitHub.