[llvm] [yaml2obj][XOFF] Update yaml2obj for XCOFF to create valid XCOFF files in more cases. (PR #77620)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 01:04:02 PST 2024


================
@@ -98,11 +98,26 @@ bool XCOFFWriter::nameShouldBeInStringTable(StringRef SymbolName) {
 bool XCOFFWriter::initRelocations(uint64_t &CurrentOffset) {
   for (XCOFFYAML::Section &InitSection : InitSections) {
     if (!InitSection.Relocations.empty()) {
-      InitSection.NumberOfRelocations = InitSection.Relocations.size();
-      InitSection.FileOffsetToRelocations = CurrentOffset;
       uint64_t RelSize = Is64Bit ? XCOFF::RelocationSerializationSize64
                                  : XCOFF::RelocationSerializationSize32;
-      CurrentOffset += InitSection.NumberOfRelocations * RelSize;
+      const uint64_t UsedSize = RelSize * InitSection.Relocations.size();
+
+      // If NumberOfRelocations was specified, we use it, even if it's
+      // not consistent with the number of provided relocations
----------------
jh7370 wrote:

Nit: comment style (misisng full stop).

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


More information about the llvm-commits mailing list