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