Blame SOURCES/runtime-bigendian-ilasm-pdb.patch

8c3e2c
Index: a/src/coreclr/ilasm/writer.cpp
8c3e2c
===================================================================
8c3e2c
--- a/src/coreclr/ilasm/writer.cpp
8c3e2c
+++ b/src/coreclr/ilasm/writer.cpp
8c3e2c
@@ -212,26 +212,28 @@ HRESULT Assembler::CreateDebugDirectory(
8c3e2c
     param.debugDirData = NULL;
8c3e2c
 
8c3e2c
     // get module ID
8c3e2c
-    DWORD rsds = 0x53445352;
8c3e2c
-    DWORD pdbAge = 0x1;
8c3e2c
+    DWORD rsds = VAL32(0x53445352);
8c3e2c
+    DWORD pdbAge = VAL32(0x1);
8c3e2c
+    GUID pdbGuid = *m_pPortablePdbWriter->GetGuid();
8c3e2c
+    SwapGuid(&pdbGuid);
8c3e2c
     DWORD len = sizeof(rsds) + sizeof(GUID) + sizeof(pdbAge) + (DWORD)strlen(m_szPdbFileName) + 1;
8c3e2c
     BYTE* dbgDirData = new BYTE[len];
8c3e2c
 
8c3e2c
     DWORD offset = 0;
8c3e2c
     memcpy_s(dbgDirData + offset, len, &rsds, sizeof(rsds));                            // RSDS
8c3e2c
     offset += sizeof(rsds);
8c3e2c
-    memcpy_s(dbgDirData + offset, len, m_pPortablePdbWriter->GetGuid(), sizeof(GUID)); // PDB GUID
8c3e2c
+    memcpy_s(dbgDirData + offset, len, &pdbGuid, sizeof(GUID));                         // PDB GUID
8c3e2c
     offset += sizeof(GUID);
8c3e2c
     memcpy_s(dbgDirData + offset, len, &pdbAge, sizeof(pdbAge));                        // PDB AGE
8c3e2c
     offset += sizeof(pdbAge);
8c3e2c
     memcpy_s(dbgDirData + offset, len, m_szPdbFileName, strlen(m_szPdbFileName) + 1);   // PDB PATH
8c3e2c
 
8c3e2c
     debugDirIDD.Characteristics = 0;
8c3e2c
-    debugDirIDD.TimeDateStamp = m_pPortablePdbWriter->GetTimestamp();
8c3e2c
-    debugDirIDD.MajorVersion = 0x100;
8c3e2c
-    debugDirIDD.MinorVersion = 0x504d;
8c3e2c
-    debugDirIDD.Type = IMAGE_DEBUG_TYPE_CODEVIEW;
8c3e2c
-    debugDirIDD.SizeOfData = len;
8c3e2c
+    debugDirIDD.TimeDateStamp = VAL32(m_pPortablePdbWriter->GetTimestamp());
8c3e2c
+    debugDirIDD.MajorVersion = VAL16(0x100);
8c3e2c
+    debugDirIDD.MinorVersion = VAL16(0x504d);
8c3e2c
+    debugDirIDD.Type = VAL32(IMAGE_DEBUG_TYPE_CODEVIEW);
8c3e2c
+    debugDirIDD.SizeOfData = VAL32(len);
8c3e2c
     debugDirIDD.AddressOfRawData = 0; // will be updated bellow
8c3e2c
     debugDirIDD.PointerToRawData = 0; // will be updated bellow
8c3e2c
 
8c3e2c
Index: a/src/coreclr/md/enc/pdbheap.cpp
8c3e2c
===================================================================
8c3e2c
--- a/src/coreclr/md/enc/pdbheap.cpp
8c3e2c
+++ b/src/coreclr/md/enc/pdbheap.cpp
8c3e2c
@@ -26,6 +26,16 @@ HRESULT PdbHeap::SetData(PORT_PDB_STREAM
8c3e2c
         (sizeof(ULONG) * data->typeSystemTableRowsSize);
8c3e2c
     m_data = new BYTE[m_size];
8c3e2c
 
8c3e2c
+#if BIGENDIAN
8c3e2c
+    PORT_PDB_STREAM swappedData = *data;
8c3e2c
+    SwapGuid(&swappedData.id.pdbGuid);
8c3e2c
+    swappedData.id.pdbTimeStamp = VAL32(swappedData.id.pdbTimeStamp);
8c3e2c
+    swappedData.entryPoint = VAL32(swappedData.entryPoint);
8c3e2c
+    swappedData.referencedTypeSystemTables = VAL64(swappedData.referencedTypeSystemTables);
8c3e2c
+    // typeSystemTableRows and typeSystemTableRowsSize handled below
8c3e2c
+    data = &swappedData;
8c3e2c
+#endif
8c3e2c
+
8c3e2c
     ULONG offset = 0;
8c3e2c
     if (memcpy_s(m_data + offset, m_size, &data->id, sizeof(data->id)))
8c3e2c
         return E_FAIL;
8c3e2c
@@ -39,9 +49,17 @@ HRESULT PdbHeap::SetData(PORT_PDB_STREAM
8c3e2c
         return E_FAIL;
8c3e2c
     offset += sizeof(data->referencedTypeSystemTables);
8c3e2c
 
8c3e2c
+#if !BIGENDIAN
8c3e2c
     if (memcpy_s(m_data + offset, m_size, data->typeSystemTableRows, sizeof(ULONG) * data->typeSystemTableRowsSize))
8c3e2c
         return E_FAIL;
8c3e2c
     offset += sizeof(ULONG) * data->typeSystemTableRowsSize;
8c3e2c
+#else
8c3e2c
+    for (int i = 0; i < data->typeSystemTableRowsSize; i++)
8c3e2c
+    {
8c3e2c
+        SET_UNALIGNED_VAL32(m_data + offset, data->typeSystemTableRows[i]);
8c3e2c
+        offset += sizeof(ULONG);
8c3e2c
+    }
8c3e2c
+#endif
8c3e2c
 
8c3e2c
     _ASSERTE(offset == m_size);
8c3e2c