mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-05 05:18:40 +00:00
move directive section gather logic to obj layer
This commit is contained in:
+3
-33
@@ -1488,41 +1488,11 @@ lnk_build_link_context(TP_Context *tp, TP_Arena *tp_arena, LNK_Config *config)
|
||||
}
|
||||
|
||||
ProfBegin("Handle Directives");
|
||||
for (U64 obj_idx = 0; obj_idx < obj_node_arr.count; obj_idx += 1) {
|
||||
for EachIndex(obj_idx, obj_node_arr.count) {
|
||||
LNK_Obj *obj = &obj_node_arr.v[obj_idx].data;
|
||||
|
||||
LNK_DirectiveInfo directive_info = {0};
|
||||
{
|
||||
COFF_SectionHeader *section_table = (COFF_SectionHeader *)str8_substr(obj->data, obj->header.section_table_range).str;
|
||||
|
||||
String8List drectve_data = {0};
|
||||
for (U64 sect_idx = 0; sect_idx < obj->header.section_count_no_null; sect_idx += 1) {
|
||||
COFF_SectionHeader *sect_header = §ion_table[sect_idx];
|
||||
if (sect_header->flags & COFF_SectionFlag_LnkInfo) {
|
||||
String8 sect_name = str8_cstring_capped(sect_header->name, sect_header->name + sizeof(sect_header->name));
|
||||
if (str8_match(sect_name, str8_lit(".drectve"), 0)) {
|
||||
if (sect_header->flags & COFF_SectionFlag_CntUninitializedData) {
|
||||
lnk_error_obj(LNK_Error_IllData, obj, ".drectve section header has flag COFF_SectionFlag_CntUninitializedData");
|
||||
break;
|
||||
}
|
||||
if (sect_header->fsize < 3) {
|
||||
lnk_error_obj(LNK_Error_IllData, obj, "not enough bytes to parse .drectve");
|
||||
break;
|
||||
}
|
||||
if (sect_header->reloc_count > 0) {
|
||||
lnk_error_obj(LNK_Error_IllData, obj, ".drectve must not have relocations");
|
||||
break;
|
||||
}
|
||||
Rng1U64 sect_range = rng_1u64(sect_header->foff, sect_header->foff + sect_header->fsize);
|
||||
str8_list_push(scratch.arena, &drectve_data, str8_substr(obj->data, sect_range));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String8Node *drectve_n = drectve_data.first; drectve_n != 0; drectve_n = drectve_n->next) {
|
||||
lnk_parse_msvc_linker_directive(scratch.arena, obj, &directive_info, drectve_n->string);
|
||||
}
|
||||
}
|
||||
String8List raw_directives = lnk_raw_directives_from_obj(scratch.arena, obj);
|
||||
LNK_DirectiveInfo directive_info = lnk_directive_info_from_raw_directives(scratch.arena, obj, raw_directives);
|
||||
|
||||
// /EXPORT
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user