factor out pdata code to PE layer

This commit is contained in:
Nikita Smith
2025-06-25 10:53:23 -07:00
committed by Ryan Fleury
parent f055267e59
commit 578a7ebdee
3 changed files with 31 additions and 24 deletions
+25
View File
@@ -1790,3 +1790,28 @@ pe_has_plus_header(COFF_MachineType machine)
}
return has_plus_header;
}
////////////////////////////////
internal int
pe_pdata_is_before_x86_64(void *raw_a, void *raw_b)
{
PE_IntelPdata *a = raw_a, *b = raw_b;
return a->voff_first < b->voff_first;
}
internal void
pe_pdata_sort(COFF_MachineType machine, String8 raw_pdata)
{
ProfBeginFunction();
switch (machine) {
case COFF_MachineType_Unknown: break;
case COFF_MachineType_X86:
case COFF_MachineType_X64: {
U64 count = raw_pdata.size / sizeof(PE_IntelPdata);
radsort((PE_IntelPdata *)raw_pdata.str, count, pe_pdata_is_before_x86_64);
} break;
default: { NotImplemented; } break;
}
ProfEnd();
}
+4
View File
@@ -1106,4 +1106,8 @@ internal String8 pe_make_debug_header_rdi(Arena *arena, Guid guid, String8 rdi_p
internal U32 pe_compute_checksum(U8 *buffer, U64 buffer_size);
////////////////////////////////
internal void pe_pdata_sort(COFF_MachineType machine, String8 raw_pdata);
#endif // PE_H