From 27cd7a21a3ee8ff2d4f7adc6e16591fd49130abe Mon Sep 17 00:00:00 2001 From: Nikita Smith Date: Sun, 3 Nov 2024 23:43:27 -0800 Subject: [PATCH] coff section definition for big obj --- src/coff/coff.c | 18 ++++++++++-------- src/coff/coff.h | 6 ++++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/coff/coff.c b/src/coff/coff.c index d94c0785..12c83dd1 100644 --- a/src/coff/coff.c +++ b/src/coff/coff.c @@ -97,15 +97,17 @@ coff_header_info_from_data(String8 data) COFF_HeaderInfo info = {0}; if (coff_is_big_obj(data)) { COFF_HeaderBigObj *big_header = (COFF_HeaderBigObj*)data.str; - info.machine = big_header->machine; - info.section_array_off = sizeof(COFF_HeaderBigObj); - info.section_count_no_null = big_header->section_count; - info.string_table_off = big_header->pointer_to_symbol_table + sizeof(COFF_Symbol32) * big_header->number_of_symbols; - info.symbol_size = sizeof(COFF_Symbol32); - info.symbol_off = big_header->pointer_to_symbol_table; - info.symbol_count = big_header->number_of_symbols; + info.type = COFF_DataType_BIG_OBJ; + info.machine = big_header->machine; + info.section_array_off = sizeof(COFF_HeaderBigObj); + info.section_count_no_null = big_header->section_count; + info.string_table_off = big_header->pointer_to_symbol_table + sizeof(COFF_Symbol32) * big_header->number_of_symbols; + info.symbol_size = sizeof(COFF_Symbol32); + info.symbol_off = big_header->pointer_to_symbol_table; + info.symbol_count = big_header->number_of_symbols; } else if (coff_is_obj(data)) { - COFF_Header *header = (COFF_Header*)data.str; + COFF_Header *header = (COFF_Header*)data.str; + info.type = COFF_DataType_OBJ; info.machine = header->machine; info.section_array_off = sizeof(COFF_Header); info.section_count_no_null = header->section_count; diff --git a/src/coff/coff.h b/src/coff/coff.h index 92728f16..f36cd63b 100644 --- a/src/coff/coff.h +++ b/src/coff/coff.h @@ -522,9 +522,10 @@ typedef struct COFF_SymbolSecDef U16 number_of_relocations; U16 number_of_ln; U32 check_sum; - U16 number; // one-based section index + U16 number_lo; // one-based section index U8 selection; - U8 unused[3]; + U8 unused; + U16 number_hi; } COFF_SymbolSecDef; // specifies how section data should be modified when placed in the image file. @@ -682,6 +683,7 @@ typedef U32 COFF_DataType; typedef struct COFF_HeaderInfo { COFF_MachineType machine; + COFF_DataType type; U64 section_array_off; U64 section_count_no_null; U64 string_table_off;