github/copilot-sdk · error · IOException

Unsupported ELF data encoding: + elfData

Error message

Unsupported ELF data encoding: + elfData

What it means

Byte 5 of the ELF header (EI_DATA) encodes the data encoding: 1 = little-endian, 2 = big-endian. readElfPtInterp needs the endianness to decode multi-byte header fields; any other value is a corrupt or malformed ELF file, so an IOException is thrown.

Solutions

  1. Verify the binary integrity (checksum/signature) and reinstall it from a trusted source.
  2. Confirm the file passes `file <path>` and `readelf -h <path>` without EI_DATA complaints.
  3. If parsing user-supplied files, treat this as expected input rejection and surface a clear message rather than a defect.
  4. Check the probe read logic didn't shift/corrupt offsets (read from offset 0 of the file).

Example fix

// before
String interp = readElfPtInterp(suspectProbe);
// after
int eiData = suspectProbe[5] & 0xFF;
if (eiData != 1 && eiData != 2) {
    throw new IOException("Corrupt ELF at " + path + ": EI_DATA=" + eiData + ", reinstall the binary");
}
String interp = readElfPtInterp(suspectProbe);
Defensive patterns

Strategy: validation

Validate before calling

// EI_DATA must be 1 (LE) or 2 (BE)
byte eiData = probe[5];
if (eiData != 1 && eiData != 2) throw new IOException("Corrupt ELF: EI_DATA=" + eiData);

Try / catch

try {
    String interp = readElfPtInterp(probe);
} catch (IOException e) {
    throw new IOException("ELF file appears corrupt (" + e.getMessage() + "); reinstall the artifact", e);
}

Prevention

When it happens

Trigger: The probe's ELF header byte at offset 5 is neither 1 nor 2 — a corrupted binary, a truncated/mangled download, or memory-mismatched bytes in the probe array.

Common situations: A binary damaged in transit or by a bad build/packaging step; hand-crafted or fuzzed files fed to the parser; a bad copy where bytes were shifted.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09). Data as JSON: /api/errors/5394a939d08ee629. Report an issue: GitHub.

Appendix: source

Thrown at java/sdk/src/main/java/com/github/copilot/ffi/PlatformDetector.java:176

    static Set<String> supportedClassifiers() {
        return SUPPORTED_CLASSIFIERS;
    }

    private static String readElfPtInterp(byte[] probe) throws IOException {
        int size = probe.length;
        if (size < 64) {
            throw new IOException("ELF probe too small: " + size + " bytes");
        }
        if ((probe[0] & 0xFF) != ELF_MAGIC_0 || (probe[1] & 0xFF) != ELF_MAGIC_1 || (probe[2] & 0xFF) != ELF_MAGIC_2
                || (probe[3] & 0xFF) != ELF_MAGIC_3) {
            throw new IOException("Not an ELF executable");
        }

        int elfClass = probe[4] & 0xFF;
        int elfData = probe[5] & 0xFF;
        if (elfData != ELF_DATA_LITTLE_ENDIAN && elfData != ELF_DATA_BIG_ENDIAN) {
            throw new IOException("Unsupported ELF data encoding: " + elfData);
        }
        boolean littleEndian = elfData == ELF_DATA_LITTLE_ENDIAN;

        long phoff;
        int phentsize;
        int phnum;
        int minimumPhentsize;
        if (elfClass == ELF_CLASS_64) {
            phoff = readUInt64(probe, 32, littleEndian);
            phentsize = readUInt16(probe, 54, littleEndian);
            phnum = readUInt16(probe, 56, littleEndian);
            minimumPhentsize = ELF64_PROGRAM_HEADER_SIZE;
        } else if (elfClass == ELF_CLASS_32) {
            phoff = readUInt32(probe, 28, littleEndian);
            phentsize = readUInt16(probe, 42, littleEndian);
            phnum = readUInt16(probe, 44, littleEndian);
            minimumPhentsize = ELF32_PROGRAM_HEADER_SIZE;
        } else {

View on GitHub (pinned to cd8cf15dc3)