From e6707738bfe64acba7b59a6a2027162abc196419 Mon Sep 17 00:00:00 2001 From: Karl Zylinski Date: Mon, 12 Oct 2026 16:56:33 +0200 Subject: [PATCH] radlink: For non-debug sections, propagate /RAD_REMOVE_SECTION to the section flags. This fixes issues where .gfids sections contain relocation data. In that case radlink dropped the section, but still applied them at for example `.text + 0`. --- src/linker/lnk_obj.c | 11 +++++++++++ src/linker/lnk_obj.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/linker/lnk_obj.c b/src/linker/lnk_obj.c index 15520252..1adf3cfe 100644 --- a/src/linker/lnk_obj.c +++ b/src/linker/lnk_obj.c @@ -122,6 +122,16 @@ THREAD_POOL_TASK_FUNC(lnk_obj_initer) str8_ends_with(sect_name, str8_lit("$fo_bdd$"), 0)) { *section_flags |= COFF_SectionFlag_LnkInfo; } + if (~*section_flags & LNK_SECTION_FLAG_DEBUG) { + String8 sect_base_name, sect_postfix; + coff_parse_section_name(sect_name, §_base_name, §_postfix); + for EachNode(name_n, String8Node, task->remove_sections.first) { + if (str8_match(sect_base_name, name_n->string, 0)) { + *section_flags |= COFF_SectionFlag_LnkRemove; + break; + } + } + } if (str8_match(sect_name, str8_lit(".debug$T"), 0)) { debug_t_section_number = section_number; @@ -421,6 +431,7 @@ lnk_obj_from_input_many(TP_Context *tp, TP_Arena *arena, LNK_Config *config, U64 .inputs = inputs, .objs = objs, .machine = config->machine, + .remove_sections = config->remove_sections, }; tp_for_parallel(tp, arena, inputs_count, lnk_obj_initer, &task); } diff --git a/src/linker/lnk_obj.h b/src/linker/lnk_obj.h index e3d50cdb..d4ddbd6f 100644 --- a/src/linker/lnk_obj.h +++ b/src/linker/lnk_obj.h @@ -211,6 +211,7 @@ typedef struct LNK_ObjNode *objs; U64 obj_id_base; U32 machine; + String8List remove_sections; } LNK_ObjIniter; typedef struct