mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-31 19:30:03 +00:00
pass over COFF layer
- updated naming convention on structs, enums, and macros to conform with code base style - moved related structs closer to each other - moved parser code to separate file
This commit is contained in:
@@ -85,7 +85,7 @@ lnk_make_section_sort_index(Arena *arena, String8 name, COFF_SectionFlags flags,
|
||||
|
||||
// pack sections with run-time data closer
|
||||
String8List sort_index_list = {0};
|
||||
if (flags & COFF_SectionFlag_MEM_DISCARDABLE) {
|
||||
if (flags & COFF_SectionFlag_MemDiscardable) {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "b");
|
||||
} else {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "a");
|
||||
@@ -102,14 +102,14 @@ lnk_make_section_sort_index(Arena *arena, String8 name, COFF_SectionFlags flags,
|
||||
}
|
||||
|
||||
// sort sections based on the contents
|
||||
if (flags & COFF_SectionFlag_CNT_CODE) {
|
||||
if (flags & COFF_SectionFlag_CntCode) {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "a");
|
||||
if (str8_match_lit(".text", name, 0)) {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "a");
|
||||
} else {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "b");
|
||||
}
|
||||
} else if (flags & COFF_SectionFlag_CNT_INITIALIZED_DATA) {
|
||||
} else if (flags & COFF_SectionFlag_CntInitializedData) {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "b");
|
||||
if (str8_match_lit(".data", name, 0)) {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "a");
|
||||
@@ -120,14 +120,14 @@ lnk_make_section_sort_index(Arena *arena, String8 name, COFF_SectionFlags flags,
|
||||
} else {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "d");
|
||||
}
|
||||
} else if (flags & COFF_SectionFlag_CNT_UNINITIALIZED_DATA) {
|
||||
} else if (flags & COFF_SectionFlag_CntUninitializedData) {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "c");
|
||||
} else {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "d");
|
||||
}
|
||||
|
||||
// sort sections based on read/write access so final section layout looks cleaner
|
||||
if (flags & COFF_SectionFlag_MEM_READ && ~flags & COFF_SectionFlag_MEM_WRITE) {
|
||||
if (flags & COFF_SectionFlag_MemRead && ~flags & COFF_SectionFlag_MemWrite) {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "a");
|
||||
} else {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "b");
|
||||
@@ -236,8 +236,8 @@ lnk_code_align_byte_from_machine(COFF_MachineType machine)
|
||||
{
|
||||
U8 align_byte = 0;
|
||||
switch (machine) {
|
||||
case COFF_MachineType_X64:
|
||||
case COFF_MachineType_X86: {
|
||||
case COFF_Machine_X64:
|
||||
case COFF_Machine_X86: {
|
||||
align_byte = 0xCC;
|
||||
} break;
|
||||
default: {
|
||||
@@ -570,7 +570,7 @@ lnk_section_table_assign_file_offsets(LNK_SectionTable *st)
|
||||
U64 cursor = 0;
|
||||
for (LNK_SectionNode *sect_node = st->list.first; sect_node != NULL; sect_node = sect_node->next) {
|
||||
LNK_Section *sect = §_node->data;
|
||||
if (sect->flags & COFF_SectionFlag_CNT_UNINITIALIZED_DATA) {
|
||||
if (sect->flags & COFF_SectionFlag_CntUninitializedData) {
|
||||
continue;
|
||||
}
|
||||
if (!sect->has_layout) continue;
|
||||
@@ -617,7 +617,7 @@ lnk_section_table_serialize(TP_Context *tp, Arena *arena, LNK_SectionTable *st,
|
||||
for (LNK_SectionNode *sect_n = st->list.first; sect_n != 0; sect_n = sect_n->next) {
|
||||
LNK_Section *sect = §_n->data;
|
||||
if (sect->has_layout) {
|
||||
if (sect->flags & COFF_SectionFlag_CNT_UNINITIALIZED_DATA) {
|
||||
if (sect->flags & COFF_SectionFlag_CntUninitializedData) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -625,7 +625,7 @@ lnk_section_table_serialize(TP_Context *tp, Arena *arena, LNK_SectionTable *st,
|
||||
String8 sect_data = str8_substr(image, rng_1u64(image_cursor, image_cursor + sect_size));
|
||||
|
||||
U8 fill_byte = 0;
|
||||
if (sect->flags & COFF_SectionFlag_CNT_CODE) {
|
||||
if (sect->flags & COFF_SectionFlag_CntCode) {
|
||||
fill_byte = lnk_code_align_byte_from_machine(machine);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user