@@ -40,6 +40,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40
40
#endif
41
41
42
42
#include < iostream>
43
+ #include " Probe/Assertion.h"
43
44
44
45
namespace zebin {
45
46
@@ -160,7 +161,7 @@ ZEELFObjectBuilder::addStandardSection(
160
161
std::string name, std::string sectName, const uint8_t * data, uint64_t size,
161
162
unsigned type, uint32_t padding, uint32_t align, StandardSectionListTy& sections)
162
163
{
163
- assert (type != ELF::SHT_NULL);
164
+ IGC_ASSERT (type != ELF::SHT_NULL);
164
165
// calcaulate the required padding to satisfy alignment requirement
165
166
// The orignal data size is (size + padding)
166
167
uint32_t need_padding_for_align = (align == 0 ) ?
232
233
ZEELFObjectBuilder::addSectionZEInfo (zeInfoContainer& zeInfo)
233
234
{
234
235
// every object should have exactly one ze_info section
235
- assert (m_zeInfoSection == nullptr );
236
+ IGC_ASSERT ( nullptr == m_zeInfoSection );
236
237
m_zeInfoSection = new ZEInfoSection (zeInfo, m_sectionId);
237
238
++m_sectionId;
238
239
}
@@ -299,18 +300,20 @@ std::string ZEELFObjectBuilder::getSectionNameBySectionID(SectionID id)
299
300
if (sect.id () == id)
300
301
return sect.m_name ;
301
302
}
302
- assert ( 0 && " getSectionNameBySectionID: invalid SectionID" );
303
+ IGC_ASSERT_MESSAGE ( 0 , " getSectionNameBySectionID: invalid SectionID" );
303
304
return " " ;
304
305
}
305
306
306
307
uint64_t ELFWriter::writeSectionData (const uint8_t * data, uint64_t size, uint32_t padding)
307
308
{
309
+ IGC_ASSERT (nullptr != data);
310
+
308
311
uint64_t start_off = m_W.OS .tell ();
309
312
m_W.OS .write ((const char *)data, size);
310
313
311
314
writePadding (padding);
312
315
313
- assert ((m_W.OS .tell () - start_off) == (size + padding));
316
+ IGC_ASSERT ((m_W.OS .tell () - start_off) == (size + padding));
314
317
return m_W.OS .tell () - start_off;
315
318
}
316
319
@@ -376,7 +379,7 @@ uint64_t ELFWriter::writeRelocTab(const RelocationListTy& relocs)
376
379
377
380
for (const ZEELFObjectBuilder::Relocation& reloc : relocs) {
378
381
// 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 ());
380
383
writeRelocation (
381
384
reloc.offset (), reloc.type (), m_SymNameIdxMap[reloc.symName ()]);
382
385
}
@@ -402,7 +405,7 @@ uint64_t ELFWriter::writeSymTab()
402
405
if (sym.sectionId () >= 0 ) {
403
406
// the given section's index must have been adjusted in
404
407
// createSectionHdrEntries
405
- assert (m_SectionIndex.find (sym.sectionId ()) != m_SectionIndex.end ());
408
+ IGC_ASSERT (m_SectionIndex.find (sym.sectionId ()) != m_SectionIndex.end ());
406
409
sect_idx = m_SectionIndex.at (sym.sectionId ());
407
410
} else {
408
411
sect_idx = ELF::SHN_UNDEF;
@@ -411,7 +414,7 @@ uint64_t ELFWriter::writeSymTab()
411
414
writeSymbol (nameoff, sym.addr (), sym.size (), sym.binding (), sym.type (),
412
415
0 , sect_idx);
413
416
// 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 ());
415
418
m_SymNameIdxMap.insert (std::make_pair (sym.name (), symidx));
416
419
++symidx;
417
420
}
@@ -424,6 +427,7 @@ uint64_t ELFWriter::writeZEInfo()
424
427
uint64_t start_off = m_W.OS .tell ();
425
428
// serialize ze_info contents
426
429
llvm::yaml::Output yout (m_W.OS );
430
+ IGC_ASSERT (nullptr != m_ObjBuilder.m_zeInfoSection );
427
431
yout << m_ObjBuilder.m_zeInfoSection ->getZeInfo ();
428
432
429
433
return m_W.OS .tell () - start_off;
@@ -479,10 +483,11 @@ void ELFWriter::writeSections()
479
483
switch (entry.type ) {
480
484
case ELF::SHT_PROGBITS:
481
485
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 =
485
489
static_cast <const StandardSection*>(entry.section );
490
+ IGC_ASSERT (nullptr != stdsect);
486
491
entry.size = writeSectionData (
487
492
stdsect->m_data , stdsect->m_size , stdsect->m_padding );
488
493
break ;
@@ -497,9 +502,11 @@ void ELFWriter::writeSections()
497
502
entry.info = 1 ;
498
503
break ;
499
504
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 =
502
508
static_cast <const RelocSection*>(entry.section );
509
+ IGC_ASSERT (nullptr != relocSec);
503
510
entry.size = writeRelocTab (relocSec->m_Relocations );
504
511
entry.entsize = getRelocTabEntSize ();
505
512
break ;
@@ -518,8 +525,9 @@ void ELFWriter::writeSections()
518
525
(m_SectionHdrEntries.size () + 1 ) >= ELF::SHN_LORESERVE ?
519
526
(m_SectionHdrEntries.size () + 1 ) : 0 ;
520
527
break ;
528
+
521
529
default :
522
- assert (0 );
530
+ IGC_ASSERT (0 );
523
531
break ;
524
532
}
525
533
}
@@ -699,7 +707,7 @@ void ELFWriter::createSectionHdrEntries()
699
707
// set apply target's section index
700
708
// relocations could only apply to standard sections. At this point,
701
709
// 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 ());
703
711
entry.info = m_SectionIndex.at (sect.m_TargetID );
704
712
entry.link = m_SymTabIndex;
705
713
++index;
@@ -708,12 +716,13 @@ void ELFWriter::createSectionHdrEntries()
708
716
709
717
// .ze_info
710
718
// every object must have exactly one ze_info section
711
- assert (m_ObjBuilder.m_zeInfoSection != nullptr );
712
719
if (m_ObjBuilder.m_zeInfoSection != nullptr ) {
713
720
createSectionHdrEntry (m_ObjBuilder.m_ZEInfoName , SHT_ZEBIN_ZEINFO,
714
721
m_ObjBuilder.m_zeInfoSection );
715
722
++index;
716
723
}
724
+ else
725
+ IGC_ASSERT (0 );
717
726
718
727
// .strtab
719
728
m_StringTableIndex = index;
0 commit comments