add support for associative COMDAT symbols

This commit is contained in:
Nikita Smith
2025-05-23 14:44:03 -07:00
committed by Ryan Fleury
parent 889b1807f2
commit 8fad6da751
2 changed files with 14 additions and 4 deletions
+12 -4
View File
@@ -112,7 +112,7 @@ coff_obj_writer_serialize(Arena *arena, COFF_ObjWriter *obj_writer)
d_sd->length = safe_cast_u32(sect->data.total_size);
d_sd->number_of_relocations = (U16)sect->reloc_count;
d_sd->check_sum = 0;
d_sd->number_lo = (U16)sect->section_number;
d_sd->number_lo = s_sd->selection == COFF_ComdatSelect_Associative ? safe_cast_u16(s_sd->associate->section_number) : 0;
d_sd->selection = s_sd->selection;
str8_list_push(scratch.arena, &symbol_table, str8_struct(d_sd));
@@ -300,12 +300,20 @@ internal COFF_ObjSymbol *
coff_obj_writer_push_symbol_secdef(COFF_ObjWriter *obj_writer, COFF_ObjSection *section, COFF_ComdatSelectType selection)
{
COFF_ObjSymbol *s = coff_obj_writer_push_symbol_static(obj_writer, section->name, 0, section);
COFF_ObjSymbolSecDef *sd = push_array(obj_writer->arena, COFF_ObjSymbolSecDef, 1);
sd->selection = selection;
sd->selection = selection;
str8_list_push(obj_writer->arena, &s->aux_symbols, str8_struct(sd));
return s;
}
internal COFF_ObjSymbol *
coff_obj_writer_push_symbol_associative(COFF_ObjWriter *obj_writer, COFF_ObjSection *head, COFF_ObjSection *associate)
{
COFF_ObjSymbol *s = coff_obj_writer_push_symbol_static(obj_writer, head->name, 0, head);
COFF_ObjSymbolSecDef *sd = push_array(obj_writer->arena, COFF_ObjSymbolSecDef, 1);
sd->selection = COFF_ComdatSelect_Associative;
sd->associate = associate;
str8_list_push(obj_writer->arena, &s->aux_symbols, str8_struct(sd));
return s;
}
+2
View File
@@ -27,6 +27,7 @@ typedef struct COFF_ObjSymbolWeak
typedef struct COFF_ObjSymbolSecDef
{
COFF_ComdatSelectType selection;
struct COFF_ObjSection *associate;
} COFF_ObjSymbolSecDef;
typedef struct COFF_ObjSymbol
@@ -104,6 +105,7 @@ internal COFF_ObjSymbol* coff_obj_writer_push_symbol(COFF_ObjWriter *obj_writer
internal COFF_ObjSymbol * coff_obj_writer_push_symbol_extern(COFF_ObjWriter *obj_writer, String8 name, U32 value, COFF_ObjSection *section);
internal COFF_ObjSymbol * coff_obj_writer_push_symbol_static(COFF_ObjWriter *obj_writer, String8 name, U32 off, COFF_ObjSection *section);
internal COFF_ObjSymbol * coff_obj_writer_push_symbol_secdef(COFF_ObjWriter *obj_writer, COFF_ObjSection *section, COFF_ComdatSelectType selection);
internal COFF_ObjSymbol * coff_obj_writer_push_symbol_associative(COFF_ObjWriter *obj_writer, COFF_ObjSection *head, COFF_ObjSection *associate);
internal COFF_ObjSymbol * coff_obj_writer_push_symbol_weak(COFF_ObjWriter *obj_writer, String8 name, COFF_WeakExtType characteristics, COFF_ObjSymbol *tag);
internal COFF_ObjSymbol * coff_obj_writer_push_symbol_abs(COFF_ObjWriter *obj_writer, String8 name, U32 value, COFF_SymStorageClass storage_class);
internal COFF_ObjSymbol * coff_obj_writer_push_symbol_undef(COFF_ObjWriter *obj_writer, String8 name);