[COFF] Fix endianness of .llvm.call-graph-profile section data
authorZequan Wu <zequanwu@google.com>
Sun, 12 Jul 2020 03:49:26 +0000 (20:49 -0700)
committerZequan Wu <zequanwu@google.com>
Sun, 12 Jul 2020 03:49:26 +0000 (20:49 -0700)
llvm/lib/MC/WinCOFFObjectWriter.cpp

index 94a8d56..4796ef5 100644 (file)
@@ -1116,9 +1116,9 @@ uint64_t WinCOFFObjectWriter::writeObject(MCAssembler &Asm,
     for (const MCAssembler::CGProfileEntry &CGPE : Asm.CGProfile) {
       uint32_t FromIndex = CGPE.From->getSymbol().getIndex();
       uint32_t ToIndex = CGPE.To->getSymbol().getIndex();
-      OS.write((const char *)&FromIndex, sizeof(uint32_t));
-      OS.write((const char *)&ToIndex, sizeof(uint32_t));
-      OS.write((const char *)&CGPE.Count, sizeof(uint64_t));
+      support::endian::write(OS, FromIndex, W.Endian);
+      support::endian::write(OS, ToIndex, W.Endian);
+      support::endian::write(OS, CGPE.Count, W.Endian);
     }
   }