From 73413d4ca352cf9653fbfbf1498808c6e08438e8 Mon Sep 17 00:00:00 2001 From: Dmitry Borisov Date: Mon, 16 Mar 2026 18:19:54 +0600 Subject: [PATCH] [OBJ2BIN] Use section flags instead of a hardcoded ".text" name (#5317) A 32-bit ASM file can turn into an empty binary file in certain cases (compiled with MSVC). MASM/ML produces a ".text$mn" section instead of the ".text", which makes obj2bin generate an empty binary file. The problem didn't occur with our 16-bit artifacts (16-bit stubs, bootsectors...), because their object files all have similar sections pattern: the ".text" section and empty ".text$mn" section, which didn't matter since it is empty. On the contrary, the .text$mn section(s) aren't empty for 32-bit stubs. --- sdk/tools/obj2bin/obj2bin.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/tools/obj2bin/obj2bin.c b/sdk/tools/obj2bin/obj2bin.c index 3f49775b1d4..4f6149a4718 100644 --- a/sdk/tools/obj2bin/obj2bin.c +++ b/sdk/tools/obj2bin/obj2bin.c @@ -140,8 +140,9 @@ int main(int argc, char *argv[]) /* Loop all sections */ for (i = 0; i < pFileHeader->NumberOfSections; i++) { - /* Check if this is '.text' section */ - if ((strcmp((char*)pSectionHeader->Name, ".text") == 0) && + /* Check if this is a section with executable code */ + if (((pSectionHeader->Characteristics & (IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE)) == + (IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE)) && (pSectionHeader->SizeOfRawData != 0)) { if (!RelocateSection(pData,