-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[SystemZ][z/OS] yaml2obj GOFF symbols #75971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 12 commits
36be167
ae601e2
e53969c
22c968e
25a8034
2ce0e3b
ddca557
c92c5c2
263bef6
85251f6
975462f
980e0d1
2861f97
97625ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -175,6 +175,7 @@ class GOFFOstream : public raw_ostream { | |||||
class GOFFState { | ||||||
void writeHeader(GOFFYAML::FileHeader &FileHdr); | ||||||
void writeEnd(); | ||||||
void writeSymbol(GOFFYAML::Symbol Sym); | ||||||
|
||||||
void reportError(const Twine &Msg) { | ||||||
ErrHandler(Msg); | ||||||
|
@@ -245,6 +246,53 @@ void GOFFState::writeHeader(GOFFYAML::FileHeader &FileHdr) { | |||||
} | ||||||
} | ||||||
|
||||||
void GOFFState::writeSymbol(GOFFYAML::Symbol Sym) { | ||||||
SmallString<80> SymName; | ||||||
if (std::error_code EC = ConverterEBCDIC::convertToEBCDIC(Sym.Name, SymName)) | ||||||
reportError("conversion error on " + Sym.Name + ": " + EC.message()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coming back to this fresh, I think we can reword this:
Suggested change
You also should have a test case which triggers this error. |
||||||
size_t SymNameLength = SymName.size(); | ||||||
if (SymNameLength > GOFF::MaxDataLength) | ||||||
reportError("symbol name is too long: " + Twine(SymNameLength) + | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test case for this error, please. |
||||||
". Max length is: " + Twine(GOFF::MaxDataLength)); | ||||||
|
||||||
const unsigned NameLengthOffset = 69; | ||||||
GW.makeNewRecord(GOFF::RT_ESD, NameLengthOffset + SymNameLength); | ||||||
GW << binaryBe(Sym.Type) // Symbol type | ||||||
<< binaryBe(Sym.ID) // ESDID | ||||||
<< binaryBe(Sym.OwnerID) // Owner ESDID | ||||||
<< binaryBe(uint32_t(0)) // Reserved | ||||||
<< binaryBe(Sym.Address) // Offset/Address | ||||||
<< binaryBe(uint32_t(0)) // Reserved | ||||||
<< binaryBe(Sym.Length) // Length | ||||||
<< binaryBe(Sym.ExtAttrID) // Extended attributes | ||||||
<< binaryBe(Sym.ExtAttrOffset) // Extended attributes data offset | ||||||
<< binaryBe(uint32_t(0)) // Reserved | ||||||
<< binaryBe(Sym.NameSpace) // Namespace ID | ||||||
<< binaryBe(Sym.Flags) // Flags | ||||||
<< binaryBe(Sym.FillByteValue) // Fill byte value | ||||||
<< binaryBe(uint8_t(0)) // Reserved | ||||||
<< binaryBe(Sym.PSectID) // PSECT ID | ||||||
<< binaryBe(Sym.Priority); // Priority | ||||||
if (Sym.Signature) | ||||||
GW << Sym.Signature; // Signature | ||||||
else | ||||||
GW << zeros(8); | ||||||
#define BIT(E, N) (Sym.BAFlags & GOFF::E ? 1 << (7 - N) : 0) | ||||||
GW << binaryBe(Sym.Amode) // Behavioral attributes - Amode | ||||||
<< binaryBe(Sym.Rmode) // Behavioral attributes - Rmode | ||||||
<< binaryBe(uint8_t(Sym.TextStyle << 4 | Sym.BindingAlgorithm)) | ||||||
<< binaryBe(uint8_t(Sym.TaskingBehavior << 5 | BIT(ESD_BA_Movable, 3) | | ||||||
BIT(ESD_BA_ReadOnly, 4) | Sym.Executable)) | ||||||
<< binaryBe(uint8_t(BIT(ESD_BA_NoPrime, 1) | Sym.BindingStrength)) | ||||||
<< binaryBe(uint8_t(Sym.LoadingBehavior << 6 | BIT(ESD_BA_COMMON, 2) | | ||||||
BIT(ESD_BA_Indirect, 3) | Sym.BindingScope)) | ||||||
<< binaryBe(uint8_t(Sym.LinkageType << 5 | Sym.Alignment)) | ||||||
<< zeros(3) // Behavioral attributes - Reserved | ||||||
<< binaryBe(static_cast<uint16_t>(SymNameLength)) // Name length | ||||||
<< SymName.str(); | ||||||
#undef BIT | ||||||
} | ||||||
|
||||||
void GOFFState::writeEnd() { | ||||||
GW.makeNewRecord(GOFF::RT_END, GOFF::PayloadLength); | ||||||
GW << binaryBe(uint8_t(0)) // No entry point | ||||||
|
@@ -259,6 +307,15 @@ bool GOFFState::writeObject() { | |||||
writeHeader(Doc.Header); | ||||||
if (HasError) | ||||||
return false; | ||||||
// Iterate over all records. | ||||||
unsigned RecordNum = 0; | ||||||
for (const std::unique_ptr<llvm::GOFFYAML::RecordBase> &Rec : Doc.Records) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should look up the |
||||||
if (const auto *Sym = dyn_cast<GOFFYAML::Symbol>(Rec.get())) | ||||||
writeSymbol(*Sym); | ||||||
else | ||||||
reportError("unknown record type on record index" + Twine(RecordNum)); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This is clearer, I think. You should also have a test case for this error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is running in the wrong direction. The
There is no |
||||||
RecordNum++; | ||||||
} | ||||||
writeEnd(); | ||||||
return true; | ||||||
} | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.