@@ -394,154 +394,6 @@ GOFFObjectFile::getSectionPrEsdRecord(uint32_t SectionIndex) const {
394
394
return EsdRecord;
395
395
}
396
396
397
- uint32_t GOFFObjectFile::getSectionDefEsdId (DataRefImpl &Sec) const {
398
- const uint8_t *EsdRecord = getSectionEdEsdRecord (Sec);
399
- uint32_t Length;
400
- ESDRecord::getLength (EsdRecord, Length);
401
- if (Length == 0 ) {
402
- const uint8_t *PrEsdRecord = getSectionPrEsdRecord (Sec);
403
- if (PrEsdRecord)
404
- EsdRecord = PrEsdRecord;
405
- }
406
-
407
- uint32_t DefEsdId;
408
- ESDRecord::getEsdId (EsdRecord, DefEsdId);
409
- LLVM_DEBUG (dbgs () << " Got def EsdId: " << DefEsdId << ' \n ' );
410
- return DefEsdId;
411
- }
412
-
413
- void GOFFObjectFile::moveSectionNext (DataRefImpl &Sec) const {
414
- Sec.d .a ++;
415
- if ((Sec.d .a ) >= SectionList.size ())
416
- Sec.d .a = 0 ;
417
- }
418
-
419
- Expected<StringRef> GOFFObjectFile::getSectionName (DataRefImpl Sec) const {
420
- DataRefImpl EdSym;
421
- SectionEntryImpl EsdIds = SectionList[Sec.d .a ];
422
- EdSym.d .a = EsdIds.d .a ;
423
- Expected<StringRef> Name = getSymbolName (EdSym);
424
- if (Name) {
425
- StringRef Res = *Name;
426
- LLVM_DEBUG (dbgs () << " Got section: " << Res << ' \n ' );
427
- LLVM_DEBUG (dbgs () << " Final section name: " << Res << ' \n ' );
428
- Name = Res;
429
- }
430
- return Name;
431
- }
432
-
433
- uint64_t GOFFObjectFile::getSectionAddress (DataRefImpl Sec) const {
434
- uint32_t Offset;
435
- const uint8_t *EsdRecord = getSectionEdEsdRecord (Sec);
436
- ESDRecord::getOffset (EsdRecord, Offset);
437
- return Offset;
438
- }
439
-
440
- uint64_t GOFFObjectFile::getSectionSize (DataRefImpl Sec) const {
441
- uint32_t Length;
442
- uint32_t DefEsdId = getSectionDefEsdId (Sec);
443
- const uint8_t *EsdRecord = EsdPtrs[DefEsdId];
444
- ESDRecord::getLength (EsdRecord, Length);
445
- LLVM_DEBUG (dbgs () << " Got section size: " << Length << ' \n ' );
446
- return static_cast <uint64_t >(Length);
447
- }
448
-
449
- // Unravel TXT records and expand fill characters to produce
450
- // a contiguous sequence of bytes.
451
- Expected<ArrayRef<uint8_t >>
452
- GOFFObjectFile::getSectionContents (DataRefImpl Sec) const {
453
- if (SectionDataCache.count (Sec.d .a )) {
454
- auto &Buf = SectionDataCache[Sec.d .a ];
455
- return ArrayRef<uint8_t >(Buf);
456
- }
457
- uint64_t SectionSize = getSectionSize (Sec);
458
- uint32_t DefEsdId = getSectionDefEsdId (Sec);
459
-
460
- const uint8_t *EdEsdRecord = getSectionEdEsdRecord (Sec);
461
- bool FillBytePresent;
462
- ESDRecord::getFillBytePresent (EdEsdRecord, FillBytePresent);
463
- uint8_t FillByte = ' \0 ' ;
464
- if (FillBytePresent)
465
- ESDRecord::getFillByteValue (EdEsdRecord, FillByte);
466
-
467
- // Initialize section with fill byte.
468
- SmallVector<uint8_t > Data (SectionSize, FillByte);
469
-
470
- // Replace section with content from text records.
471
- for (const uint8_t *TxtRecordInt : TextPtrs) {
472
- const uint8_t *TxtRecordPtr = TxtRecordInt;
473
- uint32_t TxtEsdId;
474
- TXTRecord::getElementEsdId (TxtRecordPtr, TxtEsdId);
475
- LLVM_DEBUG (dbgs () << " Got txt EsdId: " << TxtEsdId << ' \n ' );
476
-
477
- if (TxtEsdId != DefEsdId)
478
- continue ;
479
-
480
- uint32_t TxtDataOffset;
481
- TXTRecord::getOffset (TxtRecordPtr, TxtDataOffset);
482
-
483
- uint16_t TxtDataSize;
484
- TXTRecord::getDataLength (TxtRecordPtr, TxtDataSize);
485
-
486
- LLVM_DEBUG (dbgs () << " Record offset " << TxtDataOffset << " , data size "
487
- << TxtDataSize << " \n " );
488
-
489
- SmallString<256 > CompleteData;
490
- CompleteData.reserve (TxtDataSize);
491
- if (Error Err = TXTRecord::getData (TxtRecordPtr, CompleteData))
492
- return std::move (Err);
493
- assert (CompleteData.size () == TxtDataSize && " Wrong length of data" );
494
- std::copy (CompleteData.data (), CompleteData.data () + TxtDataSize,
495
- Data.begin () + TxtDataOffset);
496
- }
497
- SectionDataCache[Sec.d .a ] = Data;
498
- return ArrayRef<uint8_t >(Data);
499
- }
500
-
501
- uint64_t GOFFObjectFile::getSectionAlignment (DataRefImpl Sec) const {
502
- const uint8_t *EsdRecord = getSectionEdEsdRecord (Sec);
503
- GOFF::ESDAlignment Pow2Alignment;
504
- ESDRecord::getAlignment (EsdRecord, Pow2Alignment);
505
- return 1ULL << static_cast <uint64_t >(Pow2Alignment);
506
- }
507
-
508
- bool GOFFObjectFile::isSectionText (DataRefImpl Sec) const {
509
- const uint8_t *EsdRecord = getSectionEdEsdRecord (Sec);
510
- GOFF::ESDExecutable Executable;
511
- ESDRecord::getExecutable (EsdRecord, Executable);
512
- return Executable == GOFF::ESD_EXE_CODE;
513
- }
514
-
515
- bool GOFFObjectFile::isSectionData (DataRefImpl Sec) const {
516
- const uint8_t *EsdRecord = getSectionEdEsdRecord (Sec);
517
- GOFF::ESDExecutable Executable;
518
- ESDRecord::getExecutable (EsdRecord, Executable);
519
- return Executable == GOFF::ESD_EXE_DATA;
520
- }
521
-
522
- bool GOFFObjectFile::isSectionNoLoad (DataRefImpl Sec) const {
523
- const uint8_t *EsdRecord = getSectionEdEsdRecord (Sec);
524
- GOFF::ESDLoadingBehavior LoadingBehavior;
525
- ESDRecord::getLoadingBehavior (EsdRecord, LoadingBehavior);
526
- return LoadingBehavior == GOFF::ESD_LB_NoLoad;
527
- }
528
-
529
- bool GOFFObjectFile::isSectionReadOnlyData (DataRefImpl Sec) const {
530
- if (!isSectionData (Sec))
531
- return false ;
532
-
533
- const uint8_t *EsdRecord = getSectionEdEsdRecord (Sec);
534
- GOFF::ESDLoadingBehavior LoadingBehavior;
535
- ESDRecord::getLoadingBehavior (EsdRecord, LoadingBehavior);
536
- return LoadingBehavior == GOFF::ESD_LB_Initial;
537
- }
538
-
539
- bool GOFFObjectFile::isSectionZeroInit (DataRefImpl Sec) const {
540
- // GOFF uses fill characters and fill characters are applied
541
- // on getSectionContents() - so we say false to zero init.
542
- return false ;
543
- }
544
-
545
397
section_iterator GOFFObjectFile::section_begin () const {
546
398
DataRefImpl Sec;
547
399
moveSectionNext (Sec);
0 commit comments