From b612301b7225951a3821d094901d7d1422a63e61 Mon Sep 17 00:00:00 2001 From: "Chodor, Jaroslaw" Date: Wed, 16 Jul 2025 15:01:46 +0000 Subject: [PATCH] feature: Adding support for empty .text section If .text section is empty then ignore it. Related-To: NEO-12229 Signed-off-by: Chodor, Jaroslaw --- .../zebin/zebin_decoder.cpp | 4 +++- .../zebin_decoder_tests.cpp | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/shared/source/device_binary_format/zebin/zebin_decoder.cpp b/shared/source/device_binary_format/zebin/zebin_decoder.cpp index bc1ef03b6e..be44e24f91 100644 --- a/shared/source/device_binary_format/zebin/zebin_decoder.cpp +++ b/shared/source/device_binary_format/zebin/zebin_decoder.cpp @@ -249,7 +249,9 @@ DecodeError extractZebinSections(NEO::Elf::Elf &elf, ZebinSectionsheader->name); } +TEST(ExtractZebinSections, GivenEmptyTextSectionThenIgnoresIt) { + NEO::Elf::ElfEncoder<> elfEncoder; + elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Zebin::Elf::SectionNames::text, ArrayRef{}); + + auto encodedElf = elfEncoder.encode(); + std::string elferrors; + std::string elfwarnings; + auto decodedElf = NEO::Elf::decodeElf(encodedElf, elferrors, elfwarnings); + + ZebinSections sections; + std::string errors; + std::string warnings; + auto decodeError = extractZebinSections(decodedElf, sections, errors, warnings); + EXPECT_EQ(NEO::DecodeError::success, decodeError); + EXPECT_TRUE(warnings.empty()) << warnings; + EXPECT_TRUE(errors.empty()) << errors; + + EXPECT_EQ(0U, sections.textSections.size()); +} + TEST(ExtractZebinSections, GivenMispelledConstDataSectionThenAllowItButEmitWarning) { NEO::Elf::ElfEncoder<> elfEncoder; elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, ".data.global_const", std::string{});