internal static ElfInfo GetElfInfo()

in JetBrains.HabitatDetector/src/Impl/Linux/LinuxHelper.cs [23:34]


    internal static ElfInfo GetElfInfo(Stream stream)
    {
      var elfFile = ElfFile.Parse(stream);
      if (elfFile.EiOsAbi is not (ELFOSABI.ELFOSABI_NONE or ELFOSABI.ELFOSABI_LINUX))
        throw new FormatException($"Invalid ELF OS ABI identification {elfFile.EiOsAbi}");
      if (elfFile.EType is not (ET.ET_DYN or ET.ET_EXEC))
        throw new FormatException($"Invalid ELF object file type {elfFile.EType}");
      return new ElfInfo(
        ConvertToLibC(elfFile.Interpreter ?? throw new FormatException("Can't find ELF program interpreter")) ?? JetLinuxLibC.Glibc, // Note(ww898): Fallback to GLibC because OpenSUSE and other.
        ConvertToArchitecture(elfFile.EiClass, elfFile.EiData, elfFile.EMachine),
        elfFile.Interpreter);
    }