@@ -502,100 +502,3 @@ TEST(GOFFObjectFileTest, InvalidERSymbolType) {
502
502
FailedWithMessage (" ESD record 1 has unknown Executable type 0x03" ));
503
503
}
504
504
}
505
-
506
- TEST (GOFFObjectFileTest, TXTConstruct) {
507
- char GOFFData[GOFF::RecordLength * 6 ] = {};
508
-
509
- // HDR record.
510
- GOFFData[0 ] = 0x03 ;
511
- GOFFData[1 ] = 0xF0 ;
512
- GOFFData[50 ] = 0x01 ;
513
-
514
- // ESD record.
515
- GOFFData[GOFF::RecordLength] = 0x03 ;
516
- GOFFData[GOFF::RecordLength + 7 ] = 0x01 ; // ESDID.
517
- GOFFData[GOFF::RecordLength + 71 ] = 0x05 ; // Size of symbol name.
518
- GOFFData[GOFF::RecordLength + 72 ] = 0xa5 ; // Symbol name is v.
519
- GOFFData[GOFF::RecordLength + 73 ] = 0x81 ; // Symbol name is a.
520
- GOFFData[GOFF::RecordLength + 74 ] = 0x99 ; // Symbol name is r.
521
- GOFFData[GOFF::RecordLength + 75 ] = 0x7b ; // Symbol name is #.
522
- GOFFData[GOFF::RecordLength + 76 ] = 0x83 ; // Symbol name is c.
523
-
524
- // ESD record.
525
- GOFFData[GOFF::RecordLength * 2 ] = 0x03 ;
526
- GOFFData[GOFF::RecordLength * 2 + 3 ] = 0x01 ;
527
- GOFFData[GOFF::RecordLength * 2 + 7 ] = 0x02 ; // ESDID.
528
- GOFFData[GOFF::RecordLength * 2 + 11 ] = 0x01 ; // Parent ESDID.
529
- GOFFData[GOFF::RecordLength * 2 + 27 ] = 0x08 ; // Length.
530
- GOFFData[GOFF::RecordLength * 2 + 40 ] = 0x01 ; // Name Space ID.
531
- GOFFData[GOFF::RecordLength * 2 + 41 ] = 0x80 ;
532
- GOFFData[GOFF::RecordLength * 2 + 60 ] = 0x04 ; // Size of symbol name.
533
- GOFFData[GOFF::RecordLength * 2 + 61 ] = 0x04 ; // Size of symbol name.
534
- GOFFData[GOFF::RecordLength * 2 + 63 ] = 0x0a ; // Size of symbol name.
535
- GOFFData[GOFF::RecordLength * 2 + 66 ] = 0x03 ; // Size of symbol name.
536
- GOFFData[GOFF::RecordLength * 2 + 71 ] = 0x08 ; // Size of symbol name.
537
- GOFFData[GOFF::RecordLength * 2 + 72 ] = 0xc3 ; // Symbol name is c.
538
- GOFFData[GOFF::RecordLength * 2 + 73 ] = 0x6d ; // Symbol name is _.
539
- GOFFData[GOFF::RecordLength * 2 + 74 ] = 0xc3 ; // Symbol name is c.
540
- GOFFData[GOFF::RecordLength * 2 + 75 ] = 0xd6 ; // Symbol name is o.
541
- GOFFData[GOFF::RecordLength * 2 + 76 ] = 0xc4 ; // Symbol name is D.
542
- GOFFData[GOFF::RecordLength * 2 + 77 ] = 0xc5 ; // Symbol name is E.
543
- GOFFData[GOFF::RecordLength * 2 + 78 ] = 0xf6 ; // Symbol name is 6.
544
- GOFFData[GOFF::RecordLength * 2 + 79 ] = 0xf4 ; // Symbol name is 4.
545
-
546
- // ESD record.
547
- GOFFData[GOFF::RecordLength * 3 ] = 0x03 ;
548
- GOFFData[GOFF::RecordLength * 3 + 3 ] = 0x02 ;
549
- GOFFData[GOFF::RecordLength * 3 + 7 ] = 0x03 ; // ESDID.
550
- GOFFData[GOFF::RecordLength * 3 + 11 ] = 0x02 ; // Parent ESDID.
551
- GOFFData[GOFF::RecordLength * 3 + 71 ] = 0x05 ; // Size of symbol name.
552
- GOFFData[GOFF::RecordLength * 3 + 72 ] = 0xa5 ; // Symbol name is v.
553
- GOFFData[GOFF::RecordLength * 3 + 73 ] = 0x81 ; // Symbol name is a.
554
- GOFFData[GOFF::RecordLength * 3 + 74 ] = 0x99 ; // Symbol name is r.
555
- GOFFData[GOFF::RecordLength * 3 + 75 ] = 0x7b ; // Symbol name is #.
556
- GOFFData[GOFF::RecordLength * 3 + 76 ] = 0x83 ; // Symbol name is c.
557
-
558
- // TXT record.
559
- GOFFData[GOFF::RecordLength * 4 ] = 0x03 ;
560
- GOFFData[GOFF::RecordLength * 4 + 1 ] = 0x10 ;
561
- GOFFData[GOFF::RecordLength * 4 + 7 ] = 0x02 ;
562
- GOFFData[GOFF::RecordLength * 4 + 23 ] = 0x08 ; // Data Length.
563
- GOFFData[GOFF::RecordLength * 4 + 24 ] = 0x12 ;
564
- GOFFData[GOFF::RecordLength * 4 + 25 ] = 0x34 ;
565
- GOFFData[GOFF::RecordLength * 4 + 26 ] = 0x56 ;
566
- GOFFData[GOFF::RecordLength * 4 + 27 ] = 0x78 ;
567
- GOFFData[GOFF::RecordLength * 4 + 28 ] = 0x9a ;
568
- GOFFData[GOFF::RecordLength * 4 + 29 ] = 0xbc ;
569
- GOFFData[GOFF::RecordLength * 4 + 30 ] = 0xde ;
570
- GOFFData[GOFF::RecordLength * 4 + 31 ] = 0xf0 ;
571
-
572
- // END record.
573
- GOFFData[GOFF::RecordLength * 5 ] = 0x03 ;
574
- GOFFData[GOFF::RecordLength * 5 + 1 ] = 0x40 ;
575
- GOFFData[GOFF::RecordLength * 5 + 11 ] = 0x06 ;
576
-
577
- StringRef Data (GOFFData, GOFF::RecordLength * 6 );
578
-
579
- Expected<std::unique_ptr<ObjectFile>> GOFFObjOrErr =
580
- object::ObjectFile::createGOFFObjectFile (
581
- MemoryBufferRef (Data, " dummyGOFF" ));
582
-
583
- ASSERT_THAT_EXPECTED (GOFFObjOrErr, Succeeded ());
584
-
585
- GOFFObjectFile *GOFFObj = dyn_cast<GOFFObjectFile>((*GOFFObjOrErr).get ());
586
- auto Symbols = GOFFObj->symbols ();
587
- ASSERT_EQ (std::distance (Symbols.begin (), Symbols.end ()), 1 );
588
- SymbolRef Symbol = *Symbols.begin ();
589
- Expected<StringRef> SymbolNameOrErr = GOFFObj->getSymbolName (Symbol);
590
- ASSERT_THAT_EXPECTED (SymbolNameOrErr, Succeeded ());
591
- StringRef SymbolName = SymbolNameOrErr.get ();
592
- EXPECT_EQ (SymbolName, " var#c" );
593
-
594
- auto Sections = GOFFObj->sections ();
595
- ASSERT_EQ (std::distance (Sections.begin (), Sections.end ()), 1 );
596
- SectionRef Section = *Sections.begin ();
597
- Expected<StringRef> SectionContent = Section.getContents ();
598
- ASSERT_THAT_EXPECTED (SectionContent, Succeeded ());
599
- StringRef Contents = SectionContent.get ();
600
- EXPECT_EQ (Contents, " \x12\x34\x56\x78\x9a\xbc\xde\xf0 " );
601
- }
0 commit comments