Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/coreclr/ilasm/writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 18 additions & 0 deletions src/coreclr/md/enc/pdbheap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ HRESULT PdbHeap::SetData(PORT_PDB_STREAM* data)
(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;
Expand All @@ -39,9 +49,17 @@ HRESULT PdbHeap::SetData(PORT_PDB_STREAM* data)
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);

Expand Down