@@ -40,6 +40,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4040#endif
4141
4242#include < iostream>
43+ #include " Probe/Assertion.h"
4344
4445namespace zebin {
4546
@@ -160,7 +161,7 @@ ZEELFObjectBuilder::addStandardSection(
160161 std::string name, std::string sectName, const uint8_t * data, uint64_t size,
161162 unsigned type, uint32_t padding, uint32_t align, StandardSectionListTy& sections)
162163{
163- assert (type != ELF::SHT_NULL);
164+ IGC_ASSERT (type != ELF::SHT_NULL);
164165 // calcaulate the required padding to satisfy alignment requirement
165166 // The orignal data size is (size + padding)
166167 uint32_t need_padding_for_align = (align == 0 ) ?
232233ZEELFObjectBuilder::addSectionZEInfo (zeInfoContainer& zeInfo)
233234{
234235 // every object should have exactly one ze_info section
235- assert (m_zeInfoSection == nullptr );
236+ IGC_ASSERT ( nullptr == m_zeInfoSection );
236237 m_zeInfoSection = new ZEInfoSection (zeInfo, m_sectionId);
237238 ++m_sectionId;
238239}
@@ -299,18 +300,20 @@ std::string ZEELFObjectBuilder::getSectionNameBySectionID(SectionID id)
299300 if (sect.id () == id)
300301 return sect.m_name ;
301302 }
302- assert ( 0 && " getSectionNameBySectionID: invalid SectionID" );
303+ IGC_ASSERT_MESSAGE ( 0 , " getSectionNameBySectionID: invalid SectionID" );
303304 return " " ;
304305}
305306
306307uint64_t ELFWriter::writeSectionData (const uint8_t * data, uint64_t size, uint32_t padding)
307308{
309+ IGC_ASSERT (nullptr != data);
310+
308311 uint64_t start_off = m_W.OS .tell ();
309312 m_W.OS .write ((const char *)data, size);
310313
311314 writePadding (padding);
312315
313- assert ((m_W.OS .tell () - start_off) == (size + padding));
316+ IGC_ASSERT ((m_W.OS .tell () - start_off) == (size + padding));
314317 return m_W.OS .tell () - start_off;
315318}
316319
@@ -376,7 +379,7 @@ uint64_t ELFWriter::writeRelocTab(const RelocationListTy& relocs)
376379
377380 for (const ZEELFObjectBuilder::Relocation& reloc : relocs) {
378381 // the target symbol's name must have been added into symbol table
379- assert (m_SymNameIdxMap.find (reloc.symName ()) != m_SymNameIdxMap.end ());
382+ IGC_ASSERT (m_SymNameIdxMap.find (reloc.symName ()) != m_SymNameIdxMap.end ());
380383 writeRelocation (
381384 reloc.offset (), reloc.type (), m_SymNameIdxMap[reloc.symName ()]);
382385 }
@@ -402,7 +405,7 @@ uint64_t ELFWriter::writeSymTab()
402405 if (sym.sectionId () >= 0 ) {
403406 // the given section's index must have been adjusted in
404407 // createSectionHdrEntries
405- assert (m_SectionIndex.find (sym.sectionId ()) != m_SectionIndex.end ());
408+ IGC_ASSERT (m_SectionIndex.find (sym.sectionId ()) != m_SectionIndex.end ());
406409 sect_idx = m_SectionIndex.at (sym.sectionId ());
407410 } else {
408411 sect_idx = ELF::SHN_UNDEF;
@@ -411,7 +414,7 @@ uint64_t ELFWriter::writeSymTab()
411414 writeSymbol (nameoff, sym.addr (), sym.size (), sym.binding (), sym.type (),
412415 0 , sect_idx);
413416 // symbol name must be unique
414- assert (m_SymNameIdxMap.find (sym.name ()) == m_SymNameIdxMap.end ());
417+ IGC_ASSERT (m_SymNameIdxMap.find (sym.name ()) == m_SymNameIdxMap.end ());
415418 m_SymNameIdxMap.insert (std::make_pair (sym.name (), symidx));
416419 ++symidx;
417420 }
@@ -424,6 +427,7 @@ uint64_t ELFWriter::writeZEInfo()
424427 uint64_t start_off = m_W.OS .tell ();
425428 // serialize ze_info contents
426429 llvm::yaml::Output yout (m_W.OS );
430+ IGC_ASSERT (nullptr != m_ObjBuilder.m_zeInfoSection );
427431 yout << m_ObjBuilder.m_zeInfoSection ->getZeInfo ();
428432
429433 return m_W.OS .tell () - start_off;
@@ -479,10 +483,11 @@ void ELFWriter::writeSections()
479483 switch (entry.type ) {
480484 case ELF::SHT_PROGBITS:
481485 case SHT_ZEBIN_SPIRV: {
482- assert (entry. section != nullptr );
483- assert (entry.section ->getKind () == Section::STANDARD);
484- const StandardSection* stdsect =
486+ IGC_ASSERT ( nullptr != entry. section );
487+ IGC_ASSERT (entry.section ->getKind () == Section::STANDARD);
488+ const StandardSection* const stdsect =
485489 static_cast <const StandardSection*>(entry.section );
490+ IGC_ASSERT (nullptr != stdsect);
486491 entry.size = writeSectionData (
487492 stdsect->m_data , stdsect->m_size , stdsect->m_padding );
488493 break ;
@@ -497,9 +502,11 @@ void ELFWriter::writeSections()
497502 entry.info = 1 ;
498503 break ;
499504 case ELF::SHT_REL: {
500- assert (entry.section ->getKind () == Section::RELOC);
501- const RelocSection* relocSec =
505+ IGC_ASSERT (nullptr != entry.section );
506+ IGC_ASSERT (entry.section ->getKind () == Section::RELOC);
507+ const RelocSection* const relocSec =
502508 static_cast <const RelocSection*>(entry.section );
509+ IGC_ASSERT (nullptr != relocSec);
503510 entry.size = writeRelocTab (relocSec->m_Relocations );
504511 entry.entsize = getRelocTabEntSize ();
505512 break ;
@@ -518,8 +525,9 @@ void ELFWriter::writeSections()
518525 (m_SectionHdrEntries.size () + 1 ) >= ELF::SHN_LORESERVE ?
519526 (m_SectionHdrEntries.size () + 1 ) : 0 ;
520527 break ;
528+
521529 default :
522- assert (0 );
530+ IGC_ASSERT (0 );
523531 break ;
524532 }
525533 }
@@ -699,7 +707,7 @@ void ELFWriter::createSectionHdrEntries()
699707 // set apply target's section index
700708 // relocations could only apply to standard sections. At this point,
701709 // all standard section's section index should be adjusted
702- assert (m_SectionIndex.find (sect.m_TargetID ) != m_SectionIndex.end ());
710+ IGC_ASSERT (m_SectionIndex.find (sect.m_TargetID ) != m_SectionIndex.end ());
703711 entry.info = m_SectionIndex.at (sect.m_TargetID );
704712 entry.link = m_SymTabIndex;
705713 ++index;
@@ -708,12 +716,13 @@ void ELFWriter::createSectionHdrEntries()
708716
709717 // .ze_info
710718 // every object must have exactly one ze_info section
711- assert (m_ObjBuilder.m_zeInfoSection != nullptr );
712719 if (m_ObjBuilder.m_zeInfoSection != nullptr ) {
713720 createSectionHdrEntry (m_ObjBuilder.m_ZEInfoName , SHT_ZEBIN_ZEINFO,
714721 m_ObjBuilder.m_zeInfoSection );
715722 ++index;
716723 }
724+ else
725+ IGC_ASSERT (0 );
717726
718727 // .strtab
719728 m_StringTableIndex = index;
0 commit comments