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

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