/* * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * */ #pragma once #include "shared/source/device_binary_format/device_binary_formats.h" #include "shared/source/device_binary_format/elf/elf_decoder.h" #include "shared/source/device_binary_format/zebin/zebin_elf.h" #include "shared/source/utilities/stackvec.h" #include #include namespace AOT { enum PRODUCT_CONFIG : uint32_t; // NOLINT(readability-identifier-naming) } namespace NEO { namespace Elf { template struct Elf; } struct ProgramInfo; namespace Zebin { template struct ZebinSections { using SectionHeaderData = NEO::Elf::SectionHeaderAndData; StackVec textKernelSections; StackVec gtpinInfoSections; StackVec zeInfoSections; StackVec globalDataSections; StackVec globalZeroInitDataSections; StackVec constDataSections; StackVec constZeroInitDataSections; StackVec constDataStringSections; StackVec symtabSections; StackVec spirvSections; StackVec noteIntelGTSections; StackVec buildOptionsSection; }; template bool isZebin(ArrayRef binary); bool validateTargetDevice(const TargetDevice &targetDevice, Elf::ElfIdentifierClass numBits, PRODUCT_FAMILY productFamily, GFXCORE_FAMILY gfxCore, AOT::PRODUCT_CONFIG productConfig, Zebin::Elf::ZebinTargetFlags targetMetadata); template bool validateTargetDevice(const Elf::Elf &elf, const TargetDevice &targetDevice, std::string &outErrReason, std::string &outWarning, SingleDeviceBinary &singleDeviceBinary); template DecodeError decodeIntelGTNoteSection(ArrayRef intelGTNotesSection, std::vector &intelGTNotes, std::string &outErrReason, std::string &outWarning); template DecodeError getIntelGTNotes(const Elf::Elf &elf, std::vector &intelGTNotes, std::string &outErrReason, std::string &outWarning); template DecodeError extractZebinSections(Elf::Elf &elf, ZebinSections &out, std::string &outErrReason, std::string &outWarning); template DecodeError validateZebinSectionsCount(const ZebinSections §ions, std::string &outErrReason, std::string &outWarning); template DecodeError decodeZebin(ProgramInfo &dst, Elf::Elf &elf, std::string &outErrReason, std::string &outWarning); template ArrayRef getKernelHeap(ConstStringRef &kernelName, Elf::Elf &elf, const ZebinSections &zebinSections); template ArrayRef getKernelGtpinInfo(ConstStringRef &kernelName, Elf::Elf &elf, const ZebinSections &zebinSections); void setKernelMiscInfoPosition(ConstStringRef metadata, ProgramInfo &dst); ConstStringRef getZeInfoFromZebin(const ArrayRef zebin, std::string &outErrReason, std::string &outWarning); } // namespace Zebin } // namespace NEO