Skip to content

Commit aeb8628

Browse files
committed
Revert "[SystemZ][z/OS] TXT records in the GOFF reader (#74526)"
This reverts commit 009f88f. Reverting PR due to test failure.
1 parent c2bdbed commit aeb8628

File tree

4 files changed

+14
-178
lines changed

4 files changed

+14
-178
lines changed

llvm/include/llvm/Object/GOFF.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,6 @@ class Record {
7373
}
7474
};
7575

76-
class TXTRecord : public Record {
77-
public:
78-
/// \brief Maximum length of data; any more must go in continuation.
79-
static const uint8_t TXTMaxDataLength = 56;
80-
81-
static Error getData(const uint8_t *Record, SmallString<256> &CompleteData);
82-
83-
static void getElementEsdId(const uint8_t *Record, uint32_t &EsdId) {
84-
get<uint32_t>(Record, 4, EsdId);
85-
}
86-
87-
static void getOffset(const uint8_t *Record, uint32_t &Offset) {
88-
get<uint32_t>(Record, 12, Offset);
89-
}
90-
91-
static void getDataLength(const uint8_t *Record, uint16_t &Length) {
92-
get<uint16_t>(Record, 22, Length);
93-
}
94-
};
95-
9676
class HDRRecord : public Record {
9777
public:
9878
static Error getData(const uint8_t *Record, SmallString<256> &CompleteData);

llvm/include/llvm/Object/GOFFObjectFile.h

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ namespace llvm {
2929
namespace object {
3030

3131
class GOFFObjectFile : public ObjectFile {
32-
friend class GOFFSymbolRef;
33-
3432
IndexedMap<const uint8_t *> EsdPtrs; // Indexed by EsdId.
35-
SmallVector<const uint8_t *, 256> TextPtrs;
3633

3734
mutable DenseMap<uint32_t, std::pair<size_t, std::unique_ptr<char[]>>>
3835
EsdNamesCache;
@@ -41,7 +38,7 @@ class GOFFObjectFile : public ObjectFile {
4138
// (EDID, 0) code, r/o data section
4239
// (EDID,PRID) r/w data section
4340
SmallVector<SectionEntryImpl, 256> SectionList;
44-
mutable DenseMap<uint32_t, SmallVector<uint8_t>> SectionDataCache;
41+
mutable DenseMap<uint32_t, std::string> SectionDataCache;
4542

4643
public:
4744
Expected<StringRef> getSymbolName(SymbolRef Symbol) const;
@@ -69,10 +66,6 @@ class GOFFObjectFile : public ObjectFile {
6966
return true;
7067
}
7168

72-
bool isSectionNoLoad(DataRefImpl Sec) const;
73-
bool isSectionReadOnlyData(DataRefImpl Sec) const;
74-
bool isSectionZeroInit(DataRefImpl Sec) const;
75-
7669
private:
7770
// SymbolRef.
7871
Expected<StringRef> getSymbolName(DataRefImpl Symb) const override;
@@ -82,24 +75,27 @@ class GOFFObjectFile : public ObjectFile {
8275
Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override;
8376
Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const override;
8477
Expected<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
85-
uint64_t getSymbolSize(DataRefImpl Symb) const;
8678

8779
const uint8_t *getSymbolEsdRecord(DataRefImpl Symb) const;
8880
bool isSymbolUnresolved(DataRefImpl Symb) const;
8981
bool isSymbolIndirect(DataRefImpl Symb) const;
9082

9183
// SectionRef.
92-
void moveSectionNext(DataRefImpl &Sec) const override;
93-
virtual Expected<StringRef> getSectionName(DataRefImpl Sec) const override;
94-
uint64_t getSectionAddress(DataRefImpl Sec) const override;
95-
uint64_t getSectionSize(DataRefImpl Sec) const override;
84+
void moveSectionNext(DataRefImpl &Sec) const override {}
85+
virtual Expected<StringRef> getSectionName(DataRefImpl Sec) const override {
86+
return StringRef();
87+
}
88+
uint64_t getSectionAddress(DataRefImpl Sec) const override { return 0; }
89+
uint64_t getSectionSize(DataRefImpl Sec) const override { return 0; }
9690
virtual Expected<ArrayRef<uint8_t>>
97-
getSectionContents(DataRefImpl Sec) const override;
98-
uint64_t getSectionIndex(DataRefImpl Sec) const override { return Sec.d.a; }
99-
uint64_t getSectionAlignment(DataRefImpl Sec) const override;
91+
getSectionContents(DataRefImpl Sec) const override {
92+
return ArrayRef<uint8_t>();
93+
}
94+
uint64_t getSectionIndex(DataRefImpl Sec) const override { return 0; }
95+
uint64_t getSectionAlignment(DataRefImpl Sec) const override { return 0; }
10096
bool isSectionCompressed(DataRefImpl Sec) const override { return false; }
101-
bool isSectionText(DataRefImpl Sec) const override;
102-
bool isSectionData(DataRefImpl Sec) const override;
97+
bool isSectionText(DataRefImpl Sec) const override { return false; }
98+
bool isSectionData(DataRefImpl Sec) const override { return false; }
10399
bool isSectionBSS(DataRefImpl Sec) const override { return false; }
104100
bool isSectionVirtual(DataRefImpl Sec) const override { return false; }
105101
relocation_iterator section_rel_begin(DataRefImpl Sec) const override {
@@ -113,7 +109,6 @@ class GOFFObjectFile : public ObjectFile {
113109
const uint8_t *getSectionPrEsdRecord(DataRefImpl &Sec) const;
114110
const uint8_t *getSectionEdEsdRecord(uint32_t SectionIndex) const;
115111
const uint8_t *getSectionPrEsdRecord(uint32_t SectionIndex) const;
116-
uint32_t getSectionDefEsdId(DataRefImpl &Sec) const;
117112

118113
// RelocationRef.
119114
void moveRelocationNext(DataRefImpl &Rel) const override {}
@@ -127,29 +122,6 @@ class GOFFObjectFile : public ObjectFile {
127122
SmallVectorImpl<char> &Result) const override {}
128123
};
129124

130-
class GOFFSymbolRef : public SymbolRef {
131-
public:
132-
GOFFSymbolRef(const SymbolRef &B) : SymbolRef(B) {
133-
assert(isa<GOFFObjectFile>(SymbolRef::getObject()));
134-
}
135-
136-
const GOFFObjectFile *getObject() const {
137-
return cast<GOFFObjectFile>(BasicSymbolRef::getObject());
138-
}
139-
140-
Expected<uint32_t> getSymbolGOFFFlags() const {
141-
return getObject()->getSymbolFlags(getRawDataRefImpl());
142-
}
143-
144-
Expected<SymbolRef::Type> getSymbolGOFFType() const {
145-
return getObject()->getSymbolType(getRawDataRefImpl());
146-
}
147-
148-
uint64_t getSize() const {
149-
return getObject()->getSymbolSize(getRawDataRefImpl());
150-
}
151-
};
152-
153125
} // namespace object
154126

155127
} // namespace llvm

llvm/lib/Object/GOFFObjectFile.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,6 @@ GOFFObjectFile::GOFFObjectFile(MemoryBufferRef Object, Error &Err)
168168
LLVM_DEBUG(dbgs() << " -- ESD " << EsdId << "\n");
169169
break;
170170
}
171-
case GOFF::RT_TXT:
172-
// Save TXT records.
173-
TextPtrs.emplace_back(I);
174-
LLVM_DEBUG(dbgs() << " -- TXT\n");
175-
break;
176171
case GOFF::RT_END:
177172
LLVM_DEBUG(dbgs() << " -- END (GOFF record type) unhandled\n");
178173
break;
@@ -369,13 +364,6 @@ GOFFObjectFile::getSymbolSection(DataRefImpl Symb) const {
369364
std::to_string(SymEdId));
370365
}
371366

372-
uint64_t GOFFObjectFile::getSymbolSize(DataRefImpl Symb) const {
373-
const uint8_t *Record = getSymbolEsdRecord(Symb);
374-
uint32_t Length;
375-
ESDRecord::getLength(Record, Length);
376-
return Length;
377-
}
378-
379367
const uint8_t *GOFFObjectFile::getSectionEdEsdRecord(DataRefImpl &Sec) const {
380368
SectionEntryImpl EsdIds = SectionList[Sec.d.a];
381369
const uint8_t *EsdRecord = EsdPtrs[EsdIds.d.a];
@@ -636,13 +624,6 @@ Error ESDRecord::getData(const uint8_t *Record,
636624
return getContinuousData(Record, DataSize, 72, CompleteData);
637625
}
638626

639-
Error TXTRecord::getData(const uint8_t *Record,
640-
SmallString<256> &CompleteData) {
641-
uint16_t Length;
642-
getDataLength(Record, Length);
643-
return getContinuousData(Record, Length, 24, CompleteData);
644-
}
645-
646627
Error ENDRecord::getData(const uint8_t *Record,
647628
SmallString<256> &CompleteData) {
648629
uint16_t Length = getNameLength(Record);

llvm/unittests/Object/GOFFObjectFileTest.cpp

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -502,100 +502,3 @@ TEST(GOFFObjectFileTest, InvalidERSymbolType) {
502502
FailedWithMessage("ESD record 1 has unknown Executable type 0x03"));
503503
}
504504
}
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

Comments
 (0)