{"record":{"id":"5ecb8069155edd58","repo":"tursodatabase/turso","slug":"path-has-unsupported-elf-class-elf-class","errorCode":null,"errorMessage":"{path} has unsupported ELF class {elf_class}","messagePattern":"(.+?) has unsupported ELF class (.+?)","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/scripts/check_elf_dynsym_exports.py","lineNumber":124,"sourceCode":"            \"endian\": endian,\n            \"section_header_offset\": struct.unpack_from(endian + \"Q\", data, 40)[0],\n            \"section_header_size\": struct.unpack_from(endian + \"H\", data, 58)[0],\n            \"section_count\": struct.unpack_from(endian + \"H\", data, 60)[0],\n            \"string_table_index\": struct.unpack_from(endian + \"H\", data, 62)[0],\n            \"section_format\": endian + \"IIQQQQIIQQ\",\n            \"symbol_format\": endian + \"IBBHQQ\",\n        }\n    if elf_class == 1:\n        return {\n            \"endian\": endian,\n            \"section_header_offset\": struct.unpack_from(endian + \"I\", data, 32)[0],\n            \"section_header_size\": struct.unpack_from(endian + \"H\", data, 46)[0],\n            \"section_count\": struct.unpack_from(endian + \"H\", data, 48)[0],\n            \"string_table_index\": struct.unpack_from(endian + \"H\", data, 50)[0],\n            \"section_format\": endian + \"IIIIIIIIII\",\n            \"symbol_format\": endian + \"IIIBBH\",\n        }\n    raise SystemExit(f\"{path} has unsupported ELF class {elf_class}\")\n\n\ndef find_dynsym(data: bytes, layout: dict, path: Path):\n    string_header = section_header(data, layout, layout[\"string_table_index\"])\n    names = slice_bytes(data, string_header[OFFSET], string_header[SIZE])\n    named = None\n    typed = None\n    for index in range(layout[\"section_count\"]):\n        header = section_header(data, layout, index)\n        name = names[header[NAME] :].split(b\"\\x00\", 1)[0]\n        if name == b\".dynsym\":\n            named = header\n            break\n        if typed is None and header[TYPE] == 11:\n            typed = header\n    dynsym = named or typed\n    if dynsym is None:\n        raise SystemExit(f\"{path} has no .dynsym section\")","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/tursodatabase/turso/blob/492c4a71cd7c2649e7df83da1471b74f4b1c7aa9/bindings/dotnet/scripts/check_elf_dynsym_exports.py#L106-L142","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the file is actually ELF: run `file <path>` and check the reported class matches ELF32/ELF64.","Check for truncation/corruption: compare file size against expected artifact size or re-download/rebuild the binary.","Fix the script/CI to point at the correct .so or binary artifact, not an intermediate file.","If a new ELF class genuinely needs support, extend elf_layout to handle it."],"exampleFix":"// before\npython check_elf_dynsym_exports.py build/tmp/output.bin\n// after\npython check_elf_dynsym_exports.py build/target/release/libturso.so","handlingStrategy":"validation","validationCode":"import struct\nfrom pathlib import Path\ndef is_supported_elf(path: Path) -> bool:\n    data = path.read_bytes()\n    return len(data) > 4 and data[:4] == b\"\\x7fELF\" and data[4] in (1, 2)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `file <artifact>` on binaries before feeding them to ELF-parsing scripts","Verify artifact integrity (size/checksum) after downloads or builds","Point CI checks at known .so outputs, not intermediate files"],"tags":["elf","python","binary-parsing","ci"],"backgroundTag":"unsupported-platform","analyzedSha":"492c4a71cd7c2649e7df83da1471b74f4b1c7aa9","analyzedAt":"2026-09-13T18:13:59.796Z","contentChangedAt":"2026-09-13T18:13:59.796Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}