[llvm] [SystemZ][z/OS] yaml2obj GOFF sections & symbols (PR #75971)
Yusra Syeda via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 19 13:45:49 PST 2023
https://github.com/ysyeda updated https://github.com/llvm/llvm-project/pull/75971
>From 36be16704a9fd2be6fbb9e79bf5a9f830cfe642e Mon Sep 17 00:00:00 2001
From: Yusra Syeda <yusra.syeda at ibm.com>
Date: Tue, 19 Dec 2023 16:29:40 -0500
Subject: [PATCH 1/3] add sections & symbols
---
llvm/include/llvm/BinaryFormat/GOFF.h | 6 +
llvm/include/llvm/ObjectYAML/GOFFYAML.h | 143 +++++++++++++
llvm/lib/ObjectYAML/GOFFEmitter.cpp | 106 +++++++++-
llvm/lib/ObjectYAML/GOFFYAML.cpp | 254 ++++++++++++++++++++++++
4 files changed, 508 insertions(+), 1 deletion(-)
diff --git a/llvm/include/llvm/BinaryFormat/GOFF.h b/llvm/include/llvm/BinaryFormat/GOFF.h
index 443bcfc9479a8b..be6850216dbe2a 100644
--- a/llvm/include/llvm/BinaryFormat/GOFF.h
+++ b/llvm/include/llvm/BinaryFormat/GOFF.h
@@ -157,6 +157,12 @@ enum ESDAlignment : uint8_t {
ESD_ALIGN_4Kpage = 12,
};
+enum TXTRecordStyle : uint8_t {
+ TXT_RS_Byte = 0,
+ TXT_RS_Structured = 1,
+ TXT_RS_Unstructured = 2,
+};
+
enum ENDEntryPointRequest : uint8_t {
END_EPR_None = 0,
END_EPR_EsdidOffset = 1,
diff --git a/llvm/include/llvm/ObjectYAML/GOFFYAML.h b/llvm/include/llvm/ObjectYAML/GOFFYAML.h
index f9bf45e95bd3a4..c17b4b605e258e 100644
--- a/llvm/include/llvm/ObjectYAML/GOFFYAML.h
+++ b/llvm/include/llvm/ObjectYAML/GOFFYAML.h
@@ -21,10 +21,120 @@
namespace llvm {
+namespace GOFF {
+
+enum ESDFlags {
+ ESD_FillByteValuePresent = 1 << 7,
+ ESD_SymbolDisplayFlag = 1 << 6,
+ ESD_SymbolRenamingFlag = 1 << 5,
+ ESD_RemovableClass = 1 << 4
+};
+
+enum {
+ ESD_Mask_ERST = 0x07,
+ ESD_Mask_RQW = 0x07,
+ ESD_Mask_TextStyle = 0xf0,
+ ESD_Mask_BindingAlgorithm = 0x0f,
+};
+
+enum ESDBAFlags {
+ ESD_BA_Movable = 0x01,
+ ESD_BA_ReadOnly = 0x2,
+ ESD_BA_NoPrime = 0x4,
+ ESD_BA_COMMON = 0x8,
+ ESD_BA_Indirect = 0x10,
+};
+} // end namespace GOFF
+
// The structure of the yaml files is not an exact 1:1 match to GOFF. In order
// to use yaml::IO, we use these structures which are closer to the source.
namespace GOFFYAML {
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_ESDSYMBOLTYPE)
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_ESDNAMESPACEID)
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_ESDFlags)
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_ESDAMODE)
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_ESDRMODE)
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_ESDTEXTSTYLE)
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_ESDBINDINGALGORITHM)
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_ESDTASKINGBEHAVIOR)
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_ESDEXECUTABLE)
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_ESDLINKAGETYPE)
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_ESDBINDINGSTRENGTH)
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_ESDLOADINGBEHAVIOR)
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_ESDBINDINGSCOPE)
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_ESDALIGNMENT)
+LLVM_YAML_STRONG_TYPEDEF(uint64_t, GOFF_BAFLAGS)
+
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_TEXTRECORDSTYLE)
+
+struct RecordBase {
+ enum RecordBaseKind { RBK_Symbol, RBK_Section };
+
+private:
+ const RecordBaseKind Kind;
+
+protected:
+ RecordBase(RecordBaseKind Kind) : Kind(Kind) {}
+
+public:
+ RecordBaseKind getKind() const { return Kind; }
+};
+typedef std::unique_ptr<RecordBase> RecordPtr;
+
+struct Section : public RecordBase {
+ Section() : RecordBase(RBK_Section) {}
+
+ StringRef SymbolName;
+ uint32_t SymbolID;
+ uint32_t Offset;
+ uint32_t TrueLength;
+ uint16_t TextEncoding;
+ uint16_t DataLength;
+ GOFF_TEXTRECORDSTYLE TextStyle;
+
+ std::optional<yaml::BinaryRef> Data;
+
+ static bool classof(const RecordBase *Rec) {
+ return Rec->getKind() == RBK_Section;
+ }
+};
+
+struct Symbol : public RecordBase {
+ Symbol() : RecordBase(RBK_Symbol) {}
+
+ StringRef Name;
+ GOFF_ESDSYMBOLTYPE Type;
+ uint32_t ID;
+ uint32_t OwnerID;
+ uint32_t Address;
+ uint32_t Length;
+ uint32_t ExtAttrID;
+ uint32_t ExtAttrOffset;
+ GOFF_ESDNAMESPACEID NameSpace;
+ GOFF_ESDFlags Flags;
+ uint8_t FillByteValue;
+ uint32_t PSectID;
+ uint32_t Priority;
+ std::optional<llvm::yaml::Hex64> Signature;
+ GOFF_ESDAMODE Amode;
+ GOFF_ESDRMODE Rmode;
+ GOFF_ESDTEXTSTYLE TextStyle;
+ GOFF_ESDBINDINGALGORITHM BindingAlgorithm;
+ GOFF_ESDTASKINGBEHAVIOR TaskingBehavior;
+ GOFF_ESDEXECUTABLE Executable;
+ GOFF_ESDLINKAGETYPE LinkageType;
+ GOFF_ESDBINDINGSTRENGTH BindingStrength;
+ GOFF_ESDLOADINGBEHAVIOR LoadingBehavior;
+ GOFF_ESDBINDINGSCOPE BindingScope;
+ GOFF_ESDALIGNMENT Alignment;
+ GOFF_BAFLAGS BAFlags;
+
+ static bool classof(const RecordBase *Rec) {
+ return Rec->getKind() == RBK_Symbol;
+ }
+};
+
struct FileHeader {
uint32_t TargetEnvironment = 0;
uint32_t TargetOperatingSystem = 0;
@@ -38,12 +148,45 @@ struct FileHeader {
struct Object {
FileHeader Header;
+ std::vector<RecordPtr> Records;
Object();
};
} // end namespace GOFFYAML
} // end namespace llvm
+LLVM_YAML_IS_SEQUENCE_VECTOR(GOFFYAML::RecordPtr)
+
+LLVM_YAML_DECLARE_ENUM_TRAITS(GOFFYAML::GOFF_ESDSYMBOLTYPE)
+LLVM_YAML_DECLARE_ENUM_TRAITS(GOFFYAML::GOFF_ESDNAMESPACEID)
+LLVM_YAML_DECLARE_BITSET_TRAITS(GOFFYAML::GOFF_ESDFlags)
+LLVM_YAML_DECLARE_ENUM_TRAITS(GOFFYAML::GOFF_ESDAMODE)
+LLVM_YAML_DECLARE_ENUM_TRAITS(GOFFYAML::GOFF_ESDRMODE)
+LLVM_YAML_DECLARE_ENUM_TRAITS(GOFFYAML::GOFF_ESDTEXTSTYLE)
+LLVM_YAML_DECLARE_ENUM_TRAITS(GOFFYAML::GOFF_ESDBINDINGALGORITHM)
+LLVM_YAML_DECLARE_ENUM_TRAITS(GOFFYAML::GOFF_ESDTASKINGBEHAVIOR)
+LLVM_YAML_DECLARE_ENUM_TRAITS(GOFFYAML::GOFF_ESDEXECUTABLE)
+LLVM_YAML_DECLARE_ENUM_TRAITS(GOFFYAML::GOFF_ESDLINKAGETYPE)
+LLVM_YAML_DECLARE_ENUM_TRAITS(GOFFYAML::GOFF_ESDBINDINGSTRENGTH)
+LLVM_YAML_DECLARE_ENUM_TRAITS(GOFFYAML::GOFF_ESDLOADINGBEHAVIOR)
+LLVM_YAML_DECLARE_ENUM_TRAITS(GOFFYAML::GOFF_ESDBINDINGSCOPE)
+LLVM_YAML_DECLARE_ENUM_TRAITS(GOFFYAML::GOFF_ESDALIGNMENT)
+LLVM_YAML_DECLARE_BITSET_TRAITS(GOFFYAML::GOFF_BAFLAGS)
+
+LLVM_YAML_DECLARE_ENUM_TRAITS(GOFFYAML::GOFF_TEXTRECORDSTYLE)
+
+LLVM_YAML_DECLARE_MAPPING_TRAITS(GOFFYAML::Section)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(GOFFYAML::Symbol)
LLVM_YAML_DECLARE_MAPPING_TRAITS(GOFFYAML::FileHeader)
LLVM_YAML_DECLARE_MAPPING_TRAITS(GOFFYAML::Object)
+namespace llvm {
+namespace yaml {
+
+template <> struct CustomMappingTraits<GOFFYAML::RecordPtr> {
+ static void inputOne(IO &IO, StringRef Key, GOFFYAML::RecordPtr &Elem);
+ static void output(IO &IO, GOFFYAML::RecordPtr &Elem);
+};
+
+} // end namespace yaml
+} // end namespace llvm
#endif // LLVM_OBJECTYAML_GOFFYAML_H
diff --git a/llvm/lib/ObjectYAML/GOFFEmitter.cpp b/llvm/lib/ObjectYAML/GOFFEmitter.cpp
index 345904407e1d24..e7db0736993444 100644
--- a/llvm/lib/ObjectYAML/GOFFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/GOFFEmitter.cpp
@@ -22,6 +22,8 @@ using namespace llvm;
namespace {
+static const uint8_t TXTMaxDataLength = 56;
+
// Common flag values on records.
enum {
// Flag: This record is continued.
@@ -60,6 +62,11 @@ raw_ostream &operator<<(raw_ostream &OS, const ZerosImpl &Z) {
ZerosImpl zeros(const size_t NumBytes) { return ZerosImpl{NumBytes}; }
+raw_ostream &operator<<(raw_ostream &OS, const yaml::BinaryRef &Data) {
+ Data.writeAsBinary(OS);
+ return OS;
+}
+
// The GOFFOstream is responsible to write the data into the fixed physical
// records of the format. A user of this class announces the start of a new
// logical record and the size of its payload. While writing the payload, the
@@ -175,6 +182,8 @@ class GOFFOstream : public raw_ostream {
class GOFFState {
void writeHeader(GOFFYAML::FileHeader &FileHdr);
void writeEnd();
+ void writeSymbol(GOFFYAML::Symbol Sym);
+ void writeSection(GOFFYAML::Section Sec);
void reportError(const Twine &Msg) {
ErrHandler(Msg);
@@ -183,7 +192,7 @@ class GOFFState {
GOFFState(raw_ostream &OS, GOFFYAML::Object &Doc,
yaml::ErrorHandler ErrHandler)
- : GW(OS), Doc(Doc), ErrHandler(ErrHandler), HasError(false) {}
+ : GW(OS), Doc(Doc), ErrHandler(ErrHandler), SymbolID(0), HasError(false) {}
~GOFFState() { GW.finalize(); }
@@ -197,6 +206,7 @@ class GOFFState {
GOFFOstream GW;
GOFFYAML::Object &Doc;
yaml::ErrorHandler ErrHandler;
+ uint16_t SymbolID;
bool HasError;
};
@@ -245,6 +255,90 @@ void GOFFState::writeHeader(GOFFYAML::FileHeader &FileHdr) {
}
}
+void GOFFState::writeSymbol(GOFFYAML::Symbol Sym) {
+ if (Sym.ID != SymbolID + 1)
+ reportError("symbol IDs not monotonic " + Sym.Name);
+ else
+ ++SymbolID;
+ if (Sym.OwnerID >= SymbolID)
+ reportError("owner ID not defined " + Sym.Name);
+ SmallString<80> SymName;
+ if (std::error_code EC = ConverterEBCDIC::convertToEBCDIC(Sym.Name, SymName))
+ reportError("conversion error on " + Sym.Name);
+ size_t SymLength = SymName.size();
+ if (SymLength > GOFF::MaxDataLength)
+ reportError("symbol name is too long: " + Twine(SymLength));
+
+ GW.makeNewRecord(GOFF::RT_ESD, 69 + SymLength);
+ 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>(SymLength)) // Name length
+ << SymName.str();
+#undef BIT
+}
+
+void GOFFState::writeSection(GOFFYAML::Section Sec) {
+ if (Sec.SymbolID == 0 || Sec.SymbolID > SymbolID)
+ reportError("section symbol not defined: " + Twine(Sec.SymbolID));
+
+ size_t Size = 0;
+ if (Sec.Data) {
+ Size = Sec.Data->binary_size();
+ if (Size > GOFF::MaxDataLength) {
+ reportError("section content is too long: " + Twine(Size));
+ return;
+ }
+ if (Sec.DataLength && Sec.DataLength != Size) {
+ reportError("Section content length " + Twine(Size) +
+ " does not match data length " + Twine(Sec.DataLength));
+ return;
+ }
+ } else
+ Size = Sec.DataLength;
+
+ GW.makeNewRecord(GOFF::RT_TXT, GOFF::PayloadLength - TXTMaxDataLength + Size);
+ GW << binaryBe(Sec.TextStyle) // Text Record Style
+ << binaryBe(Sec.SymbolID) // Element ESDID
+ << binaryBe(uint32_t(0)) // Reserved
+ << binaryBe(Sec.Offset) // Offset
+ << binaryBe(Sec.TrueLength) // Text Field True Length
+ << binaryBe(Sec.TextEncoding) // Text Encoding
+ << binaryBe(static_cast<uint16_t>(Size)); // Data Length
+ if (Sec.Data)
+ GW << *Sec.Data; // Data
+ else
+ GW << zeros(Size);
+}
+
void GOFFState::writeEnd() {
GW.makeNewRecord(GOFF::RT_END, GOFF::PayloadLength);
GW << binaryBe(uint8_t(0)) // No entry point
@@ -259,6 +353,16 @@ bool GOFFState::writeObject() {
writeHeader(Doc.Header);
if (HasError)
return false;
+ // Iterate over all records.
+ for (auto &Rec : Doc.Records) {
+ if (auto *Sec = dyn_cast<GOFFYAML::Section>(Rec.get())) {
+ writeSection(*Sec);
+ } else if (auto *Sym = dyn_cast<GOFFYAML::Symbol>(Rec.get())) {
+ writeSymbol(*Sym);
+ } else {
+ reportError("Unknown record type");
+ }
+ }
writeEnd();
return true;
}
diff --git a/llvm/lib/ObjectYAML/GOFFYAML.cpp b/llvm/lib/ObjectYAML/GOFFYAML.cpp
index ae857980a521b0..4d10c8352219cf 100644
--- a/llvm/lib/ObjectYAML/GOFFYAML.cpp
+++ b/llvm/lib/ObjectYAML/GOFFYAML.cpp
@@ -23,6 +23,235 @@ Object::Object() {}
namespace yaml {
+void ScalarEnumerationTraits<GOFFYAML::GOFF_ESDSYMBOLTYPE>::enumeration(
+ IO &IO, GOFFYAML::GOFF_ESDSYMBOLTYPE &Value) {
+#define ECase(X) IO.enumCase(Value, #X, GOFF::X)
+ ECase(ESD_ST_SectionDefinition);
+ ECase(ESD_ST_ElementDefinition);
+ ECase(ESD_ST_LabelDefinition);
+ ECase(ESD_ST_PartReference);
+ ECase(ESD_ST_ExternalReference);
+#undef ECase
+ IO.enumFallback<Hex8>(Value);
+}
+
+void ScalarEnumerationTraits<GOFFYAML::GOFF_ESDNAMESPACEID>::enumeration(
+ IO &IO, GOFFYAML::GOFF_ESDNAMESPACEID &Value) {
+#define ECase(X) IO.enumCase(Value, #X, GOFF::X)
+ ECase(ESD_NS_ProgramManagementBinder);
+ ECase(ESD_NS_NormalName);
+ ECase(ESD_NS_PseudoRegister);
+ ECase(ESD_NS_Parts);
+#undef ECase
+ IO.enumFallback<Hex8>(Value);
+}
+
+void ScalarBitSetTraits<GOFFYAML::GOFF_ESDFlags>::bitset(
+ IO &IO, GOFFYAML::GOFF_ESDFlags &Value) {
+#define BCase(X) IO.bitSetCase(Value, #X, GOFF::X)
+#define BCaseMask(X, M) IO.maskedBitSetCase(Value, #X, GOFF::X, GOFF::M)
+ BCase(ESD_FillByteValuePresent);
+ BCase(ESD_SymbolDisplayFlag);
+ BCase(ESD_SymbolRenamingFlag);
+ BCase(ESD_RemovableClass);
+ BCaseMask(ESD_RQ_0, ESD_Mask_RQW);
+ BCaseMask(ESD_RQ_1, ESD_Mask_RQW);
+ BCaseMask(ESD_RQ_2, ESD_Mask_RQW);
+ BCaseMask(ESD_RQ_3, ESD_Mask_RQW);
+#undef BCase
+#undef BCaseMask
+}
+
+void ScalarEnumerationTraits<GOFFYAML::GOFF_TEXTRECORDSTYLE>::enumeration(
+ IO &IO, GOFFYAML::GOFF_TEXTRECORDSTYLE &Value) {
+#define ECase(X) IO.enumCase(Value, #X, GOFF::X)
+ ECase(TXT_RS_Byte);
+ ECase(TXT_RS_Structured);
+ ECase(TXT_RS_Unstructured);
+#undef ECase
+ IO.enumFallback<Hex8>(Value);
+}
+
+void ScalarEnumerationTraits<GOFFYAML::GOFF_ESDAMODE>::enumeration(
+ IO &IO, GOFFYAML::GOFF_ESDAMODE &Value) {
+#define ECase(X) IO.enumCase(Value, #X, GOFF::X)
+ ECase(ESD_AMODE_None);
+ ECase(ESD_AMODE_24);
+ ECase(ESD_AMODE_31);
+ ECase(ESD_AMODE_ANY);
+ ECase(ESD_AMODE_64);
+ ECase(ESD_AMODE_MIN);
+#undef ECase
+ IO.enumFallback<Hex8>(Value);
+}
+
+void ScalarEnumerationTraits<GOFFYAML::GOFF_ESDRMODE>::enumeration(
+ IO &IO, GOFFYAML::GOFF_ESDRMODE &Value) {
+#define ECase(X) IO.enumCase(Value, #X, GOFF::X)
+ ECase(ESD_RMODE_None);
+ ECase(ESD_RMODE_24);
+ ECase(ESD_RMODE_31);
+ ECase(ESD_RMODE_64);
+#undef ECase
+ IO.enumFallback<Hex8>(Value);
+}
+
+void ScalarEnumerationTraits<GOFFYAML::GOFF_ESDTEXTSTYLE>::enumeration(
+ IO &IO, GOFFYAML::GOFF_ESDTEXTSTYLE &Value) {
+#define ECase(X) IO.enumCase(Value, #X, GOFF::X)
+ ECase(ESD_TS_ByteOriented);
+ ECase(ESD_TS_Structured);
+ ECase(ESD_TS_Unstructured);
+#undef ECase
+ IO.enumFallback<Hex8>(Value);
+}
+
+void ScalarEnumerationTraits<GOFFYAML::GOFF_ESDBINDINGALGORITHM>::enumeration(
+ IO &IO, GOFFYAML::GOFF_ESDBINDINGALGORITHM &Value) {
+#define ECase(X) IO.enumCase(Value, #X, GOFF::X)
+ ECase(ESD_BA_Concatenate);
+ ECase(ESD_BA_Merge);
+#undef ECase
+ IO.enumFallback<Hex8>(Value);
+}
+
+void ScalarEnumerationTraits<GOFFYAML::GOFF_ESDTASKINGBEHAVIOR>::enumeration(
+ IO &IO, GOFFYAML::GOFF_ESDTASKINGBEHAVIOR &Value) {
+#define ECase(X) IO.enumCase(Value, #X, GOFF::X)
+ ECase(ESD_TA_Unspecified);
+ ECase(ESD_TA_NonReus);
+ ECase(ESD_TA_Reus);
+ ECase(ESD_TA_Rent);
+#undef ECase
+ IO.enumFallback<Hex8>(Value);
+}
+
+void ScalarEnumerationTraits<GOFFYAML::GOFF_ESDEXECUTABLE>::enumeration(
+ IO &IO, GOFFYAML::GOFF_ESDEXECUTABLE &Value) {
+#define ECase(X) IO.enumCase(Value, #X, GOFF::X)
+ ECase(ESD_EXE_Unspecified);
+ ECase(ESD_EXE_DATA);
+ ECase(ESD_EXE_CODE);
+#undef ECase
+ IO.enumFallback<Hex8>(Value);
+}
+
+void ScalarEnumerationTraits<GOFFYAML::GOFF_ESDLINKAGETYPE>::enumeration(
+ IO &IO, GOFFYAML::GOFF_ESDLINKAGETYPE &Value) {
+#define ECase(X) IO.enumCase(Value, #X, GOFF::X)
+ ECase(ESD_LT_OS);
+ ECase(ESD_LT_XPLink);
+#undef ECase
+ IO.enumFallback<Hex8>(Value);
+}
+
+void ScalarEnumerationTraits<GOFFYAML::GOFF_ESDBINDINGSTRENGTH>::enumeration(
+ IO &IO, GOFFYAML::GOFF_ESDBINDINGSTRENGTH &Value) {
+#define ECase(X) IO.enumCase(Value, #X, GOFF::X)
+ ECase(ESD_BST_Strong);
+ ECase(ESD_BST_Weak);
+#undef ECase
+ IO.enumFallback<Hex8>(Value);
+}
+
+void ScalarEnumerationTraits<GOFFYAML::GOFF_ESDLOADINGBEHAVIOR>::enumeration(
+ IO &IO, GOFFYAML::GOFF_ESDLOADINGBEHAVIOR &Value) {
+#define ECase(X) IO.enumCase(Value, #X, GOFF::X)
+ ECase(ESD_LB_Initial);
+ ECase(ESD_LB_Deferred);
+ ECase(ESD_LB_NoLoad);
+ ECase(ESD_LB_Reserved);
+#undef ECase
+ IO.enumFallback<Hex8>(Value);
+}
+
+void ScalarEnumerationTraits<GOFFYAML::GOFF_ESDBINDINGSCOPE>::enumeration(
+ IO &IO, GOFFYAML::GOFF_ESDBINDINGSCOPE &Value) {
+#define ECase(X) IO.enumCase(Value, #X, GOFF::X)
+ ECase(ESD_BSC_Unspecified);
+ ECase(ESD_BSC_Section);
+ ECase(ESD_BSC_Module);
+ ECase(ESD_BSC_Library);
+ ECase(ESD_BSC_ImportExport);
+#undef ECase
+ IO.enumFallback<Hex8>(Value);
+}
+
+void ScalarEnumerationTraits<GOFFYAML::GOFF_ESDALIGNMENT>::enumeration(
+ IO &IO, GOFFYAML::GOFF_ESDALIGNMENT &Value) {
+#define ECase(X) IO.enumCase(Value, #X, GOFF::X)
+ ECase(ESD_ALIGN_Byte);
+ ECase(ESD_ALIGN_Halfword);
+ ECase(ESD_ALIGN_Fullword);
+ ECase(ESD_ALIGN_Doubleword);
+ ECase(ESD_ALIGN_Quadword);
+ ECase(ESD_ALIGN_32byte);
+ ECase(ESD_ALIGN_64byte);
+ ECase(ESD_ALIGN_128byte);
+ ECase(ESD_ALIGN_256byte);
+ ECase(ESD_ALIGN_512byte);
+ ECase(ESD_ALIGN_1024byte);
+ ECase(ESD_ALIGN_2Kpage);
+ ECase(ESD_ALIGN_4Kpage);
+#undef ECase
+ IO.enumFallback<Hex8>(Value);
+}
+
+void ScalarBitSetTraits<GOFFYAML::GOFF_BAFLAGS>::bitset(
+ IO &IO, GOFFYAML::GOFF_BAFLAGS &Value) {
+#define BCase(X) IO.bitSetCase(Value, #X, GOFF::X)
+#define BCaseMask(X, M) IO.maskedBitSetCase(Value, #X, GOFF::X, GOFF::M)
+ BCase(ESD_BA_Movable);
+ BCase(ESD_BA_ReadOnly);
+ BCase(ESD_BA_NoPrime);
+ BCase(ESD_BA_COMMON);
+ BCase(ESD_BA_Indirect);
+#undef BCase
+#undef BCaseMask
+}
+
+void MappingTraits<GOFFYAML::Section>::mapping(IO &IO, GOFFYAML::Section &Sec) {
+ IO.mapRequired("SymbolName", Sec.SymbolName);
+ IO.mapRequired("SymbolID", Sec.SymbolID);
+ IO.mapOptional("Offset", Sec.Offset, 0);
+ IO.mapOptional("TrueLength", Sec.TrueLength, 0);
+ IO.mapOptional("TextEncoding", Sec.TextEncoding, 0);
+ IO.mapOptional("DataLength", Sec.DataLength, 0);
+ IO.mapOptional("TextStyle", Sec.TextStyle, GOFF::TXT_RS_Byte);
+ IO.mapOptional("Data", Sec.Data);
+}
+
+void MappingTraits<GOFFYAML::Symbol>::mapping(IO &IO, GOFFYAML::Symbol &Sym) {
+ IO.mapRequired("Name", Sym.Name);
+ IO.mapRequired("Type", Sym.Type);
+ IO.mapRequired("ID", Sym.ID);
+ IO.mapOptional("OwnerID", Sym.OwnerID, 0);
+ IO.mapOptional("Address", Sym.Address, 0);
+ IO.mapOptional("Length", Sym.Length, 0);
+ IO.mapOptional("ExtAttrID", Sym.ExtAttrID, 0);
+ IO.mapOptional("ExtAttrOffset", Sym.ExtAttrOffset, 0);
+ IO.mapRequired("NameSpace", Sym.NameSpace);
+ IO.mapOptional("Flags", Sym.Flags, GOFFYAML::GOFF_ESDFlags(0));
+ IO.mapOptional("FillByteValue", Sym.FillByteValue, 0);
+ IO.mapOptional("PSectID", Sym.PSectID, 0);
+ IO.mapOptional("Priority", Sym.Priority, 0);
+ IO.mapOptional("Signature", Sym.Signature);
+ IO.mapOptional("Amode", Sym.Amode, GOFF::ESD_AMODE_None);
+ IO.mapOptional("Rmode", Sym.Rmode, GOFF::ESD_RMODE_None);
+ IO.mapOptional("TextStyle", Sym.TextStyle, GOFF::ESD_TS_ByteOriented);
+ IO.mapOptional("BindingAlgorithm", Sym.BindingAlgorithm,
+ GOFF::ESD_BA_Concatenate);
+ IO.mapOptional("TaskingBehavior", Sym.TaskingBehavior,
+ GOFF::ESD_TA_Unspecified);
+ IO.mapOptional("Executable", Sym.Executable, GOFF::ESD_EXE_Unspecified);
+ IO.mapOptional("LinkageType", Sym.LinkageType, GOFF::ESD_LT_OS);
+ IO.mapOptional("BindingStrength", Sym.BindingStrength, GOFF::ESD_BST_Strong);
+ IO.mapOptional("LoadingBehavior", Sym.LoadingBehavior, GOFF::ESD_LB_Initial);
+ IO.mapOptional("BindingScope", Sym.BindingScope, GOFF::ESD_BSC_Unspecified);
+ IO.mapOptional("Alignment", Sym.Alignment, GOFF::ESD_ALIGN_Byte);
+ IO.mapOptional("BAFlags", Sym.BAFlags, 0);
+}
+
void MappingTraits<GOFFYAML::FileHeader>::mapping(
IO &IO, GOFFYAML::FileHeader &FileHdr) {
IO.mapOptional("TargetEnvironment", FileHdr.TargetEnvironment, 0);
@@ -37,9 +266,34 @@ void MappingTraits<GOFFYAML::FileHeader>::mapping(
FileHdr.TargetSoftwareEnvironment);
}
+void CustomMappingTraits<GOFFYAML::RecordPtr>::inputOne(
+ IO &IO, StringRef Key, GOFFYAML::RecordPtr &Elem) {
+ if (Key == "Section") {
+ GOFFYAML::Section Sec;
+ IO.mapRequired("Section", Sec);
+ Elem = std::make_unique<GOFFYAML::Section>(std::move(Sec));
+ } else if (Key == "Symbol") {
+ GOFFYAML::Symbol Sym;
+ IO.mapRequired("Symbol", Sym);
+ Elem = std::make_unique<GOFFYAML::Symbol>(std::move(Sym));
+ }
+}
+
+void CustomMappingTraits<GOFFYAML::RecordPtr>::output(
+ IO &IO, GOFFYAML::RecordPtr &Elem) {
+ if (auto *Sec = dyn_cast<GOFFYAML::Section>(Elem.get())) {
+ IO.mapRequired("Section", *Sec);
+ } else if (auto *Sym = dyn_cast<GOFFYAML::Symbol>(Elem.get())) {
+ IO.mapRequired("Symbol", *Sym);
+ } else {
+ IO.setError("Unknown record type");
+ }
+}
+
void MappingTraits<GOFFYAML::Object>::mapping(IO &IO, GOFFYAML::Object &Obj) {
IO.mapTag("!GOFF", true);
IO.mapRequired("FileHeader", Obj.Header);
+ IO.mapRequired("Records", Obj.Records);
}
} // namespace yaml
>From ae601e2e653b4c030a802c2baa67f9b385905309 Mon Sep 17 00:00:00 2001
From: Yusra Syeda <yusra.syeda at ibm.com>
Date: Tue, 19 Dec 2023 16:39:47 -0500
Subject: [PATCH 2/3] add tests
---
.../tools/yaml2obj/GOFF/GOFF-TXTSection.yaml | 49 ++++++++++
llvm/test/tools/yaml2obj/GOFF/GOFF-basic.yaml | 59 ++++++++++++
.../tools/yaml2obj/GOFF/GOFF-header-end.yaml | 1 +
.../yaml2obj/GOFF/GOFF-header-settings.yaml | 3 +-
.../tools/yaml2obj/GOFF/GOFF-longSymbol.yaml | 91 +++++++++++++++++++
.../tools/yaml2obj/GOFF/GOFF-oneSymb.yaml | 40 ++++++++
6 files changed, 242 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/tools/yaml2obj/GOFF/GOFF-TXTSection.yaml
create mode 100644 llvm/test/tools/yaml2obj/GOFF/GOFF-basic.yaml
create mode 100644 llvm/test/tools/yaml2obj/GOFF/GOFF-longSymbol.yaml
create mode 100644 llvm/test/tools/yaml2obj/GOFF/GOFF-oneSymb.yaml
diff --git a/llvm/test/tools/yaml2obj/GOFF/GOFF-TXTSection.yaml b/llvm/test/tools/yaml2obj/GOFF/GOFF-TXTSection.yaml
new file mode 100644
index 00000000000000..3336c452bcaefd
--- /dev/null
+++ b/llvm/test/tools/yaml2obj/GOFF/GOFF-TXTSection.yaml
@@ -0,0 +1,49 @@
+# RUN: yaml2obj %s | od -v -An -tx1 | FileCheck --ignore-case %s
+
+--- !GOFF
+FileHeader:
+ ArchitectureLevel: 1
+Records:
+ - Symbol:
+ Name: 'var#c'
+ Type: ESD_ST_SectionDefinition
+ ID: 1
+ NameSpace: ESD_NS_ProgramManagementBinder
+ - Symbol:
+ Name: C_CODE64
+ Type: ESD_ST_ElementDefinition
+ ID: 2
+ OwnerID: 1
+ Length: 8
+ NameSpace: ESD_NS_NormalName
+ Flags: [ ESD_FillByteValuePresent ]
+ FillByteValue: 0
+ Amode: ESD_AMODE_64
+ Rmode: ESD_RMODE_64
+ Executable: ESD_EXE_CODE
+ Alignment: ESD_ALIGN_Doubleword
+ BAFlags: [ ESD_BA_ReadOnly ]
+ - Symbol:
+ Name: 'var#c'
+ Type: ESD_ST_LabelDefinition
+ ID: 3
+ OwnerID: 2
+ NameSpace: ESD_NS_ProgramManagementBinder
+# TXT Records' byte 1, bits 0-3 should be 0001.
+# Byte 3, bits 4-7 represent Text Record Style, with 0000
+# for byte-oriented data.
+# Note: DataLength field is 8, so despite Data field being a
+# string of length greater than 8, there are only 8 bytes of
+# data represented.
+# CHECK: 03 10 00 00 00 00 00 02 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 08 12 34 56 78 9a bc de f0
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+ - Section:
+ SymbolName: C_CODE64
+ SymbolID: 2
+ TextStyle: TXT_RS_Byte
+ DataLength: 8
+ Data: "123456789ABCDEF0"
+...
diff --git a/llvm/test/tools/yaml2obj/GOFF/GOFF-basic.yaml b/llvm/test/tools/yaml2obj/GOFF/GOFF-basic.yaml
new file mode 100644
index 00000000000000..1395bb1fdf2641
--- /dev/null
+++ b/llvm/test/tools/yaml2obj/GOFF/GOFF-basic.yaml
@@ -0,0 +1,59 @@
+# RUN: yaml2obj %s | od -v -An -tx1 | FileCheck --ignore-case %s
+
+--- !GOFF
+FileHeader:
+ ArchitectureLevel: 1
+Records:
+# Bytes 80-159
+# CHECK: 03 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 04 88 89 7b c3 00 00 00 00
+ - Symbol:
+ Name: 'hi#C'
+ Type: ESD_ST_SectionDefinition
+ ID: 1
+ OwnerID: 0
+ Address: 0
+ Length: 0
+ NameSpace: ESD_NS_ProgramManagementBinder
+# Bytes 160-239
+# CHECK: 03 00 00 01 00 00 00 02 00 00 00 01 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 03 81 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 04 04 01 01
+# CHECK: 00 40 03 00 00 00 00 07 c3 6d e6 e2 c1 f6 f4 00
+ - Symbol:
+ Name: 'C_WSA64'
+ Type: ESD_ST_ElementDefinition
+ ID: 2
+ OwnerID: 1
+ NameSpace: ESD_NS_Parts
+ Flags: [ ESD_FillByteValuePresent, ESD_RQ_1 ]
+ FillByteValue: 0
+ Amode: ESD_AMODE_64
+ Rmode: ESD_RMODE_64
+ BindingAlgorithm: ESD_BA_Merge
+ Executable: ESD_EXE_DATA
+ LoadingBehavior: ESD_LB_Deferred
+ Alignment: ESD_ALIGN_Doubleword
+# Bytes 240-319
+# CHECK: 03 00 00 03 00 00 00 03 00 00 00 02 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01
+# CHECK: 00 01 24 00 00 00 00 04 88 89 7b e2 00 00 00 00
+ - Symbol:
+ Name: 'hi#S'
+ Type: ESD_ST_PartReference
+ ID: 3
+ OwnerID: 2
+ Address: 0
+ Length: 2
+ NameSpace: ESD_NS_Parts
+ LinkageType: ESD_LT_XPLink
+ Alignment: ESD_ALIGN_Quadword
+ BindingScope: ESD_BSC_Section
+ Executable: ESD_EXE_DATA
+
diff --git a/llvm/test/tools/yaml2obj/GOFF/GOFF-header-end.yaml b/llvm/test/tools/yaml2obj/GOFF/GOFF-header-end.yaml
index a5e99c2da2c491..3c11b2b9b4d3ff 100644
--- a/llvm/test/tools/yaml2obj/GOFF/GOFF-header-end.yaml
+++ b/llvm/test/tools/yaml2obj/GOFF/GOFF-header-end.yaml
@@ -18,3 +18,4 @@
--- !GOFF
FileHeader:
ArchitectureLevel: 1
+Records:
diff --git a/llvm/test/tools/yaml2obj/GOFF/GOFF-header-settings.yaml b/llvm/test/tools/yaml2obj/GOFF/GOFF-header-settings.yaml
index 1971c407199fbe..77833ffbf346d1 100644
--- a/llvm/test/tools/yaml2obj/GOFF/GOFF-header-settings.yaml
+++ b/llvm/test/tools/yaml2obj/GOFF/GOFF-header-settings.yaml
@@ -23,4 +23,5 @@ FileHeader:
LanguageProductIdentifier: ""
ArchitectureLevel: 1
InternalCCSID: 0
- TargetSoftwareEnvironment: 0
+ TargetSoftwareEnvironment: 0
+Records:
diff --git a/llvm/test/tools/yaml2obj/GOFF/GOFF-longSymbol.yaml b/llvm/test/tools/yaml2obj/GOFF/GOFF-longSymbol.yaml
new file mode 100644
index 00000000000000..308deea9117e16
--- /dev/null
+++ b/llvm/test/tools/yaml2obj/GOFF/GOFF-longSymbol.yaml
@@ -0,0 +1,91 @@
+# RUN: yaml2obj %s | od -v -An -tx1 | FileCheck --ignore-case %s
+
+
+--- !GOFF
+FileHeader:
+ ArchitectureLevel: 1
+Records:
+# Bytes 80-159
+# Bits 06-07 of Byte 2 should be set to 01 to indicate that this
+# is an "initial record" and it will be continued on the subsequent
+# record.
+# CHECK: 03 01 00 00 00 00 00 01 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 39 88 89 a3 88 89 a2 89 a2
+# Bytes 160-239
+# Bits 06-07 of Byte 2 are set to 10 to indicate that this is
+# a continuation record, and it is not continued on the next
+# record.
+# CHECK: 03 02 00 81 a5 85 99 a8 a5 85 99 a8 a5 85 99 a8
+# CHECK: a5 85 99 a8 a5 85 99 a8 a5 85 99 a8 a5 85 99 a8
+# CHECK: a5 85 99 a8 93 96 95 87 a2 a8 94 82 96 93 95 81
+# CHECK: 94 85 7b c3 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+ - Symbol:
+ Name: 'hithisisaveryveryveryveryveryveryveryverylongsymbolname#C'
+ Type: ESD_ST_SectionDefinition
+ ID: 1
+ OwnerID: 0
+ Address: 0
+ Length: 0
+ NameSpace: ESD_NS_ProgramManagementBinder
+# CHECK: 03 00 00 01 00 00 00 02 00 00 00 01 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 03 81 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 04 04 01 01
+# CHECK: 00 40 03 00 00 00 00 07 c3 6d e6 e2 c1 f6 f4 00
+ - Symbol:
+ Name: 'C_WSA64'
+ Type: ESD_ST_ElementDefinition
+ ID: 2
+ OwnerID: 1
+ NameSpace: ESD_NS_Parts
+ Flags: [ ESD_FillByteValuePresent, ESD_RQ_1 ]
+ FillByteValue: 0
+ Amode: ESD_AMODE_64
+ Rmode: ESD_RMODE_64
+ BindingAlgorithm: ESD_BA_Merge
+ Executable: ESD_EXE_DATA
+ LoadingBehavior: ESD_LB_Deferred
+ Alignment: ESD_ALIGN_Doubleword
+# Symbol spanning 4 records. First record's second byte
+# ends in 01 indicating that it is continued.
+# CHECK: 03 01 00 03 00 00 00 03 00 00 00 01 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01
+# CHECK: 00 00 02 00 00 00 00 cf 93 96 95 87 a2 a8 94 82
+# Second record's second byte ends in 11 indicating that it
+# is continued, and it itself is a continuation.
+# CHECK: 03 03 00 96 93 95 96 a3 a2 88 96 99 a3 a3 88 89
+# CHECK: a2 89 a2 a5 85 99 a8 a5 85 99 a8 a5 85 99 a8 a5
+# CHECK: 85 99 a8 a5 85 99 a8 a5 85 99 a8 a5 85 99 a8 a5
+# CHECK: 85 99 a8 a5 85 99 a8 a5 85 99 a8 a5 85 99 a8 a5
+# CHECK: 85 99 a8 a5 85 99 a8 a5 85 99 a8 a5 85 99 a8 a5
+# Third record's second byte ends in 11 indicating that it
+# is continued, and it itself is a continuation.
+# CHECK: 03 03 00 85 99 a8 a5 85 99 a8 a5 85 99 a8 a5 85
+# CHECK: 99 a8 a5 85 99 a8 a5 85 99 a8 a5 85 99 a8 a5 85
+# CHECK: 99 a8 a5 85 99 a8 a5 85 99 a8 a5 85 99 a8 a5 85
+# CHECK: 99 a8 a5 85 99 a8 93 96 95 87 89 95 86 81 83 a3
+# CHECK: a3 88 89 a2 89 a2 85 a5 85 95 93 96 95 87 85 99
+# Fourth record's second byte ends in 10 indicating that it
+# is not continued, but the record itself is a continuation.
+# CHECK: 03 02 00 a3 88 81 95 a3 88 85 97 99 85 a5 89 96
+# CHECK: a4 a2 a2 a8 94 82 96 93 a6 88 89 83 88 a6 81 a2
+# CHECK: 98 a4 89 a3 85 93 96 95 87 81 93 99 85 81 84 a8
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+
+ - Symbol:
+ Name: 'longsymbolnotshortthisisveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryverylonginfactthisisevenlongerthantheprevioussymbolwhichwasquitelongalready'
+ Type: ESD_ST_PartReference
+ ID: 3
+ OwnerID: 1
+ Address: 0
+ Length: 4
+ NameSpace: ESD_NS_Parts
+ Alignment: ESD_ALIGN_Fullword
+ Executable: ESD_EXE_DATA
diff --git a/llvm/test/tools/yaml2obj/GOFF/GOFF-oneSymb.yaml b/llvm/test/tools/yaml2obj/GOFF/GOFF-oneSymb.yaml
new file mode 100644
index 00000000000000..c565cba6dc7874
--- /dev/null
+++ b/llvm/test/tools/yaml2obj/GOFF/GOFF-oneSymb.yaml
@@ -0,0 +1,40 @@
+# RUN: yaml2obj %s | od -v -An -tx1 | FileCheck --ignore-case %s
+
+# Verify that GOFF Header is correct.
+# CHECK: 03 f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+
+# Verify that the symbol is written correctly.
+# CHECK: 03 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 01 a7 00 00 00 00 00 00 00
+
+# Verify GOFF Module end.
+# CHECK: 03 40 00 00 00 00 00 00 00 00 00 03 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# CHECK: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+
+
+
+--- !GOFF
+FileHeader:
+ ArchitectureLevel: 1
+Records:
+ - Symbol:
+ Name: 'x'
+ Type: ESD_ST_ElementDefinition
+ ID: 1
+ OwnerID: 0
+ Address: 0
+ Length: 0
+ NameSpace: ESD_NS_NormalName
+ Flags: []
+ FillByteValue: 0
+
>From e53969c0b2ab23ec443a4b6bc16b70e4d68bf4a8 Mon Sep 17 00:00:00 2001
From: Yusra Syeda <yusra.syeda at ibm.com>
Date: Tue, 19 Dec 2023 16:45:36 -0500
Subject: [PATCH 3/3] fix formtting
---
llvm/lib/ObjectYAML/GOFFEmitter.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/ObjectYAML/GOFFEmitter.cpp b/llvm/lib/ObjectYAML/GOFFEmitter.cpp
index e7db0736993444..85612ec584c311 100644
--- a/llvm/lib/ObjectYAML/GOFFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/GOFFEmitter.cpp
@@ -192,7 +192,8 @@ class GOFFState {
GOFFState(raw_ostream &OS, GOFFYAML::Object &Doc,
yaml::ErrorHandler ErrHandler)
- : GW(OS), Doc(Doc), ErrHandler(ErrHandler), SymbolID(0), HasError(false) {}
+ : GW(OS), Doc(Doc), ErrHandler(ErrHandler), SymbolID(0), HasError(false) {
+ }
~GOFFState() { GW.finalize(); }
More information about the llvm-commits
mailing list