[llvm] [SystemZ][z/OS] yaml2obj GOFF symbols (PR #75971)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 11 00:59:24 PST 2024


================
@@ -245,6 +248,57 @@ 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);
----------------
jh7370 wrote:

It seems like you could just default `Signature` to 0 and then you don't need it to be stored as a `std::optional`?

https://github.com/llvm/llvm-project/pull/75971


More information about the llvm-commits mailing list