extend COFF obj writer with ability to produce linker directive section

This commit is contained in:
Nikita Smith
2025-06-25 10:53:22 -07:00
committed by Ryan Fleury
parent 45ca147579
commit 0f81aae985
2 changed files with 19 additions and 8 deletions
+12
View File
@@ -190,6 +190,18 @@ coff_obj_writer_section_push_reloc(COFF_ObjWriter *obj_writer, COFF_ObjSection *
return reloc; return reloc;
} }
internal void
coff_obj_writer_push_directive(COFF_ObjWriter *obj_writer, String8 directive)
{
if (obj_writer->drectve_sect == 0) {
local_persist const U8 bom_sig[] = { 0xEF, 0xBB, 0xBF };
obj_writer->drectve_sect = coff_obj_writer_push_section(obj_writer, str8_lit(".drectve"), COFF_SectionFlag_LnkInfo|COFF_SectionFlag_LnkRemove|COFF_SectionFlag_Align1Bytes, str8_array_fixed(bom_sig));
}
String8List *data = &obj_writer->drectve_sect->data;
str8_list_push(obj_writer->arena, data, directive);
str8_list_pushf(obj_writer->arena, data, " ");
}
internal int internal int
coff_obj_section_is_before(void *raw_a, void *raw_b) coff_obj_section_is_before(void *raw_a, void *raw_b)
{ {
+7 -8
View File
@@ -80,17 +80,16 @@ typedef struct COFF_ObjSectionNode
typedef struct COFF_ObjWriter typedef struct COFF_ObjWriter
{ {
Arena *arena; Arena *arena;
COFF_TimeStamp time_stamp; COFF_TimeStamp time_stamp;
COFF_MachineType machine; COFF_MachineType machine;
U64 symbol_count;
U64 symbol_count; COFF_ObjSymbolNode *symbol_first;
COFF_ObjSymbolNode *symbol_first; COFF_ObjSymbolNode *symbol_last;
COFF_ObjSymbolNode *symbol_last;
U64 sect_count; U64 sect_count;
COFF_ObjSectionNode *sect_first; COFF_ObjSectionNode *sect_first;
COFF_ObjSectionNode *sect_last; COFF_ObjSectionNode *sect_last;
COFF_ObjSection *drectve_sect;
} COFF_ObjWriter; } COFF_ObjWriter;
//////////////////////////////// ////////////////////////////////