From patchwork Wed Sep 30 09:33:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Bacci X-Patchwork-Id: 144993 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F38BD4BB1C2A for ; Wed, 30 Sep 2026 09:35:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F38BD4BB1C2A Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=outlook.com header.i=@outlook.com header.a=rsa-sha256 header.s=selector1 header.b=YUxjfo84 X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from AM0PR02CU008.outbound.protection.outlook.com (mail-westeuropeazolkn19013086.outbound.protection.outlook.com [52.103.33.86]) by sourceware.org (Postfix) with ESMTPS id 30DAE4BB24F1 for ; Wed, 30 Sep 2026 09:34:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 30DAE4BB24F1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=outlook.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=outlook.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 30DAE4BB24F1 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=52.103.33.86 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1790760852; cv=pass; b=v0NiJeFvIG+br2FPzy+g6i0/Y5NfgApWsOew5g9bv0++CYYzC8H1sSuXDzA5qDo8S6ySTjwrkaniCPzRDow5cVmSSQiIadKZ3uZF3GlD0sKH+xwtR9rkBNNbhepzfseIOKGcVD4uk7QZaRvqAMG0FK9DylJoAIsjpqkhuZhuqIg= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1790760852; c=relaxed/simple; bh=NBUce5SjgEnrR19UpMy+K9txMVSfJPQLwtob/EyCi+A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=srHXbgQeuGgq/CLcXjV6N4Th7RiDZloMwanAuaDjDr9zs52mAFAo0EkPpLoajOXfaSmxsVqAvlliiF0zA0FAKmh5D67fpxPI9k7gp3ii2yzTBDvUHVVoaVc8ifhIHbWIjjtJ2vtomMA/HG1gDKG0Mdy5KaxFFGPVhyPRvhlOLIs= ARC-Authentication-Results: i=2; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=outlook.com header.i=@outlook.com header.a=rsa-sha256 header.s=selector1 header.b=YUxjfo84 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 30DAE4BB24F1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TVyT7/gOIqvha6D2mVcW7TQq96uXbjf9hs0pdPq5hz6+OHNwSK0TSRoxP6pxtBt2d7882LZHD0sU68sbXuQhNfuFPjyUk8Qveb21I1Z8hqrgZ204egzM7fhy9Tox4sd9gzEgC5PeuyuqqsRAhPwmuJYY7bOIwO79fLN3qq4gGaulXtvahfPwybjZCGuCnWKGQDyeC3XNPTithCHt+8Ra4+rEc5oVhwVpMPMppngjDZVOtvjjUO4OVlqKvcGfzbOOqV+wsjUazJRzqu7p7WNxl0+hks4bJUty57VRHGiRl9M+0AyIm8pbeoKDStA9ryW+YImU+yUSWVwMVX+7lCkSyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Gl4IA/RViIGpWKXjq+LZT2sGdpYNNloxUO3A774vHwg=; b=ltVZNtoOoR1ep92MBBdhBf6gL/F7j4YE/KHtuoqsVADcFbgOZId905snrGViK579wCRZFGnXB6n6wtpXh9AqTbcVIoEhdX2TZxwksW16T6iL48pGD7FKaktgRxtljx7AVqffKElFmSG9x9y8pngvatw9QMwTPVjA/xgcNSZWEk+bRJIRm3wtHBnYYro6beGObPP9boGfvtA7qRbUWLxLsxDBODoAv11LPJdsv/zdKMQBaGFswCVhvlmjAu/wMoys4fKo9Y9fIxLpU3e2max3uYy20yNHMIHaB+WOcUlWO0IQnN+sqn3lF47m6ikDXnzLCYgo+uYm0mqvWEuqYuGZMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Gl4IA/RViIGpWKXjq+LZT2sGdpYNNloxUO3A774vHwg=; b=YUxjfo841q6fJ8H7Lsom+LmTtxY5wrRXEFv4vnpe6J94V0a0IHDe4VWjJGXhk5he1nWvvl2CGLclT6ABIwxAcpei0v4Tc4d/g09+sCfeJ4ROlJ0RYB6tqglU3/1rGUZ1l0t6wTPfaiae3HcE4RBl59S6QRJeX0PRc8QcdkOpJ/W2XsqdwOyd04Rt5pFeLtctVzziqgO8ZiGGrljYhAtAI1ULT2x+jY33kFSuq5VBOXVhWVqDCj4cG4j0mLExI+3+CmTl7lQMltI6Rbch4AKPJ3qdy0htfi/FBxsZTYO7BUN3YaVtr7zAXYBIHkzWfT8b3zt0PljypvJar6Yg2Oks0A== Received: from AS4PR02MB7902.eurprd02.prod.outlook.com (2603:10a6:20b:4b2::9) by PAVPR02MB9521.eurprd02.prod.outlook.com (2603:10a6:102:305::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.23; Wed, 30 Sep 2026 09:34:07 +0000 Received: from AS4PR02MB7902.eurprd02.prod.outlook.com ([fe80::2a24:bc25:8b55:3de8]) by AS4PR02MB7902.eurprd02.prod.outlook.com ([fe80::2a24:bc25:8b55:3de8%5]) with mapi id 15.21.0451.022; Wed, 30 Sep 2026 09:34:07 +0000 From: Luca Bacci To: binutils@sourceware.org Cc: mingw-w64-public@lists.sourceforge.net Subject: [PATCH 2/2] ld-pe: Add support for -undefined, -include directives Date: Wed, 30 Sep 2026 11:33:52 +0200 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930093352.378-1-luca.bacci@outlook.com> References: <20260930093352.378-1-luca.bacci@outlook.com> X-ClientProxiedBy: MI2PEPF00000B7B.ITAP293.PROD.OUTLOOK.COM (2603:10a6:298:1::411) To AS4PR02MB7902.eurprd02.prod.outlook.com (2603:10a6:20b:4b2::9) X-Microsoft-Original-Message-ID: <20260930093352.378-2-luca.bacci@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS4PR02MB7902:EE_|PAVPR02MB9521:EE_ X-MS-Office365-Filtering-Correlation-Id: 4179f76f-1684-46a6-7474-08df1ed5f93c X-Microsoft-Antispam: BCL:0; ARA:14566002|51005399006|19110799012|8060799015|12121999013|25010399006|24021099003|23021999003|5072599009|15080799012|260925184616899003|40105399003|12091999003|10035399007|2607281247196008|440099028|3412199025; X-Microsoft-Antispam-Message-Info: tyqvEblRaNsSTHtZHy8GE5gwgBn84TgT0PHK3lFlgqfFrNjQJeBdxqkO9cXRJN741ZCV0x3IunLwMe1ltB6CWTkdrIKey9u+pr7MzBu/+Tm06Eo4F0eO21i1fyU+bipaDLiYT/VKgwG1JbihGVEn/GydWdBtSCqZdRYjcetaXELuHD1Kiti0XfdybOcZRG8EhS+i/LbcuIVqT+AcKDUX2UiKDsy7HK09Wg0SQau0VMGFnmL9UdNzWEwshEPUIqGfjQZaauxiXNpB1m3JaGWthzd3ErhdEc78XOunXbAhksAUkuki1LQPIZPpdH1lTXK5PF2JNywB56UCleNcXoZgn/miIkHy+z+7FjpqpS76qKBgfsEm6meistWvpGn1Vm0/fekn98mKd/FLodRabegtG+IlHAz4rokV+8RL7/a64W3T5+AQYRHo1G3OrV3i9YOI9AZ40e+Us9N+zG0t/Cce/QF69ULAGqI60Ch5Ki4hYMAq12SvLBMURNvBsF1kevIfBLsalEN/lAQYEoXwwKbiZEzwJwxMGG3k18ng4NFFm2V+slh4CckLsTB9Jo93ts+/6YToEg4WpUVi9RmjcmKdybv5p1tGQuQ/InuupBD0AeD765IYbFgKyqHFq3Cfoz/Z0zNrhyw1hZVLPSZFK+XJ97hZMHOSNh2C8rWS4s5eH26pDPLlZ65nh6sa/sUWKc+YracGO1BERaXGOxlGlBDHHOz7ek9m/5uh5kzvsIeSoF+EMPgqQNI2H74klULjAYk8LSKJ/g+ZWqroTQ2YRVf6rB9BonN2u7vBcWfqMk1uHjUCC4xyeyXfQmjt1DfU46rtb4VWm9LMRDoGncBll5Z9oxAKkQJkJ0nloOxSIvYm8+FANFc1TVNDWSFlhv8rdLfgt/eoTEFd7paFOqDqwBBKi8lVN+/YZ/nocZMQrIHr3wruo5/5WZPn7Fs8+Z+kPMW/1IaWtljmbU6ZYX5oHNUlf1dShPZ/bzg2UDRbVNFe+a8= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: znU1GeOBn+H3LK+cyBt43O1LzrYukex3IkxMJtL7IiLy8RmErzoFd+bfJc3FQOOhvUiDsMwnDb8RXXJy0m3WZkYJzbz2OHOzrOph8WG9TuJ4HGuhqVrREHqy3VKP2yN0X4vosll7/DCMw5G+EZn/z0tT9hsucWcsYpcfNxsJlm+Aw00dKMH+RHygi6/ediwnyGZLg1BUc0pmNO/vd5K6sJfFwDxObBcFX9J91ssJjnLNTbbkv4HIKi7OHULLkQDflUUjgS0cxtIzBIipPfFGL79NdNoO/3wJHVxjpHk4BrqLMAhslFOBqxZKDeoofhTbh0/Mi+oURzSbIAbcwxvYJ8tFJt1KMdtRRTlhcf3RNfN2oCaA/e85ToCGMW0XZc3CO4L1+J73+ImW0vRcu+S8kPNtLK5YVIswgM5ba73elTgvmJHSg4d7B7Z8IKwe5zs9qhErYml3OqauFfT02yoh1kzvLoxkiqzi1Q7i3xyllR6H5t/wYBWwOVAHHrWVJ33+jXtAusAWLnSXQXFFzoQZOf84Mxs6dFtfcwv9ewlEVncmwQsRO1svHcP25uKH9o1CMvdC+beVoIIsNhlTybgYyNBk4lSL9s+eiNk0w+ZzlH2nm/4RiMDc79E4m5X1auPIfZ0f9pOiCffjtE1sXgi5334gMlWNrymLy9E7DDEjnJypLuDtpBzBji/fM2Vy9XteDLJjG65RKCkUtudar7mJQkucZl8YpsFh9brIFPxaTXeDxvq8zX9KDh6T6eKRCWgLC7iR/zQjcsfqKSqhXf02GzjUNzlpr1hwjgGe2JWhwOm2erg3DPfnyPCwAbuDjPJNDKIjjO/UGTaUlSI/UcnvDguAo6RmNebuEImjgZJj51SoOZoBEob9IZWrCGyxKDPaWTS+89G50/jfePj1doRw/slxx9Tmchi/CKjtRsZS3MOLuZFIlCx6hDwr30vN7zaEk9aQizrPxaS0mRweydP5HrQ9DQIko7WqZIp86Zpumt0t7WBs81YgJ6yFidKefy/pTDvxWhfE1rULvNsC7nUCD26d7dwTqnSWwxy6vgv2o/FBD+G0L1ICpFY15r6pSJjC5XfHQN235MEV5LJHEYZ/4tdJxQxXd90+/A+7pHWVPj66MskwpvuHvEQl/S2okv7+g+exrVLJQoaOzGrZAa7EYEVcsle70rmf0N0RlXwIkvik41GmBy21YEXQnFtyytYoB9LbtNot9MK2l/CffgIWv8InVUjgkQhjfmhvJEZYjrydGkwhBLMtoW5RKp3OHPbY4WksUpU+G9acy9RVghHr8ZfJfWdLwVFqwS/+ghhr/UqiWnpcEU6yBbzdMiXtuMsjzncnnA5eduK/uznbUe/mkMA/8DbHPYAgC+Z/JVrIGJoIil3JYc00CxPOzPRpCKRX X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4179f76f-1684-46a6-7474-08df1ed5f93c X-MS-Exchange-CrossTenant-AuthSource: AS4PR02MB7902.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2026 09:34:07.1353 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR02MB9521 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GB_MSAUTHSOURCE_EUROPE, GIT_PATCH_0, PROLO_LEO1, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org Add support for specifying undefined symbol names: * As linker directives in COFF object files (.drectve section) * As statements in DEF module-definition files See git commit 37513c1e for a similar change. This enables support for retaining attribute `used' symbols. Note that attribute `retain' is ELF-specific. The consensus is that attribute `used' on PE, MACH-O should keep both the compiler and the linker from discarding the symbol [1] [2]. References: 1. https://reviews.llvm.org/D96838 2. https://clang.llvm.org/docs/AttributeReference.html#retain --- ld/deffile.h | 3 ++ ld/deffilep.y | 45 ++++++++++++++++++- ld/pe-dll.c | 3 ++ ld/testsuite/ld-pe/pe.exp | 4 ++ ld/testsuite/ld-pe/undefined-def-i386.d | 16 +++++++ ld/testsuite/ld-pe/undefined-def-i386.def | 4 ++ ld/testsuite/ld-pe/undefined-def-i386.s | 19 ++++++++ ld/testsuite/ld-pe/undefined-def-x86_64.d | 16 +++++++ ld/testsuite/ld-pe/undefined-def-x86_64.def | 4 ++ ld/testsuite/ld-pe/undefined-def-x86_64.s | 19 ++++++++ ld/testsuite/ld-pe/undefined-embedded-i386.d | 16 +++++++ ld/testsuite/ld-pe/undefined-embedded-i386.s | 21 +++++++++ .../ld-pe/undefined-embedded-x86_64.d | 16 +++++++ .../ld-pe/undefined-embedded-x86_64.s | 21 +++++++++ 14 files changed, 206 insertions(+), 1 deletion(-) create mode 100755 ld/testsuite/ld-pe/undefined-def-i386.d create mode 100755 ld/testsuite/ld-pe/undefined-def-i386.def create mode 100755 ld/testsuite/ld-pe/undefined-def-i386.s create mode 100755 ld/testsuite/ld-pe/undefined-def-x86_64.d create mode 100755 ld/testsuite/ld-pe/undefined-def-x86_64.def create mode 100755 ld/testsuite/ld-pe/undefined-def-x86_64.s create mode 100755 ld/testsuite/ld-pe/undefined-embedded-i386.d create mode 100755 ld/testsuite/ld-pe/undefined-embedded-i386.s create mode 100755 ld/testsuite/ld-pe/undefined-embedded-x86_64.d create mode 100755 ld/testsuite/ld-pe/undefined-embedded-x86_64.s diff --git a/ld/deffile.h b/ld/deffile.h index 9269d488..a7d7bd67 100644 --- a/ld/deffile.h +++ b/ld/deffile.h @@ -105,6 +105,9 @@ typedef struct def_file { /* From EXCLUDE_SYMBOLS or embedded directives. */ def_file_symbol_list exclude_symbols; + + /* From UNDEFINED, INCLUDE or embedded directives. */ + def_file_symbol_list undefined_symbols; } def_file; extern def_file *def_file_empty (void); diff --git a/ld/deffilep.y b/ld/deffilep.y index bac19249..547fb4d1 100644 --- a/ld/deffilep.y +++ b/ld/deffilep.y @@ -104,6 +104,8 @@ static void def_version (int, int); static void def_directive (char *); static void def_aligncomm (char *str, int align); static void def_exclude_symbols (char *str); +static void def_undefined (char *str); +static void def_include (char *str); static int def_parse (void); static void def_error (const char *); static int def_lex (void); @@ -124,7 +126,7 @@ static const char *lex_parse_string_end = 0; %token NAME LIBRARY DESCRIPTION STACKSIZE_K HEAPSIZE CODE DATAU DATAL %token SECTIONS EXPORTS IMPORTS VERSIONK BASE CONSTANTU CONSTANTL -%token PRIVATEU PRIVATEL ALIGNCOMM EXCLUDE_SYMBOLS +%token PRIVATEU PRIVATEL ALIGNCOMM EXCLUDE_SYMBOLS INCLUDE UNDEFINED %token READ WRITE EXECUTE SHARED_K NONAMEU NONAMEL DIRECTIVE EQUAL %token ID %token DIGITS @@ -159,6 +161,8 @@ command: | DIRECTIVE ID { def_directive ($2);} | ALIGNCOMM anylang_id ',' NUMBER { def_aligncomm ($2, $4);} | EXCLUDE_SYMBOLS symbol_list + | INCLUDE inclist + | UNDEFINED undlist ; @@ -256,6 +260,7 @@ keyword_as_name: BASE { $$ = "BASE"; } | EXPORTS { $$ = "EXPORTS"; } | HEAPSIZE { $$ = "HEAPSIZE"; } | IMPORTS { $$ = "IMPORTS"; } + | INCLUDE { $$ = "INCLUDE"; } /* Disable LIBRARY keyword as valid symbol-name. This is necessary for libtool, which places this command after EXPORTS command. This behavior is illegal by specification, but sadly required by @@ -270,6 +275,7 @@ keyword_as_name: BASE { $$ = "BASE"; } | READ { $$ = "READ"; } | SHARED_K { $$ = "SHARED"; } | STACKSIZE_K { $$ = "STACKSIZE"; } + | UNDEFINED { $$ = "UNDEFINED"; } | VERSIONK { $$ = "VERSION"; } | WRITE { $$ = "WRITE"; } ; @@ -344,6 +350,18 @@ symbol_list: | symbol_list ',' anylang_id { def_exclude_symbols ($3); } ; +undlist: + anylang_id { def_undefined ($1); } + | undlist anylang_id { def_undefined ($2); } + | undlist ',' anylang_id { def_undefined ($3); } + ; + +inclist: + anylang_id { def_include ($1); } + | inclist anylang_id { def_include ($2); } + | inclist ',' anylang_id { def_include ($3); } + ; + opt_digits: DIGITS { $$ = $1; } | { $$ = ""; } ; @@ -496,6 +514,7 @@ def_file_free (def_file *fdef) } symbol_list_clear (&fdef->exclude_symbols); + symbol_list_clear (&fdef->undefined_symbols); free (fdef); } @@ -1056,6 +1075,13 @@ def_file_add_exclude_symbol (def_file *fdef, symbol_list_add (&fdef->exclude_symbols, name); } +static void +def_file_add_undefined_symbol (def_file *fdef, + const char *name) +{ + symbol_list_add (&fdef->undefined_symbols, name); +} + struct { char *param; @@ -1069,6 +1095,8 @@ diropts[] = { "-export", EXPORTS }, { "-aligncomm", ALIGNCOMM }, { "-exclude-symbols", EXCLUDE_SYMBOLS }, + { "-include", INCLUDE }, + { "-undefined", UNDEFINED }, { 0, 0 } }; @@ -1387,6 +1415,19 @@ def_exclude_symbols (char *str) def_file_add_exclude_symbol (def, str); } +static void +def_undefined (char *str) +{ + def_file_add_undefined_symbol (def, str); +} + +static void +def_include (char *str) +{ + /* include is an alias for undefined */ + def_undefined (str); +} + static void def_error (const char *err) { @@ -1437,6 +1478,7 @@ tokens[] = { "EXPORTS", EXPORTS }, { "HEAPSIZE", HEAPSIZE }, { "IMPORTS", IMPORTS }, + { "INCLUDE", INCLUDE }, { "LIBRARY", LIBRARY }, { "NAME", NAME }, { "NONAME", NONAMEU }, @@ -1448,6 +1490,7 @@ tokens[] = { "SEGMENTS", SECTIONS }, { "SHARED", SHARED_K }, { "STACKSIZE", STACKSIZE_K }, + { "UNDEFINED", UNDEFINED }, { "VERSION", VERSIONK }, { "WRITE", WRITE }, { 0, 0 } diff --git a/ld/pe-dll.c b/ld/pe-dll.c index 6fb3dce2..972742b5 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -784,6 +784,9 @@ process_def_file_and_drectve (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info * for (ui = 0; ui < pe_def_file->exclude_symbols.count; ui++) pe_dll_add_excludes (pe_def_file->exclude_symbols.array[ui], EXCLUDESYMS); + for (ui = 0; ui < pe_def_file->undefined_symbols.count; ui++) + lang_add_gc_name (pe_def_file->undefined_symbols.array[ui]); + /* If we are building an executable and there is nothing to export, we do not build an export table at all. */ if (bfd_link_executable (info) && pe_def_file->num_exports == 0 diff --git a/ld/testsuite/ld-pe/pe.exp b/ld/testsuite/ld-pe/pe.exp index b95f61b8..7f6806ca 100644 --- a/ld/testsuite/ld-pe/pe.exp +++ b/ld/testsuite/ld-pe/pe.exp @@ -177,6 +177,10 @@ run_dump_test "exclude-symbols-embedded-i386" run_dump_test "exclude-symbols-embedded-x86_64" run_dump_test "exclude-symbols-def-i386" run_dump_test "exclude-symbols-def-x86_64" +run_dump_test "undefined-embedded-i386" +run_dump_test "undefined-embedded-x86_64" +run_dump_test "undefined-def-i386" +run_dump_test "undefined-def-x86_64" if [check_shared_lib_support] { set old_ASFLAGS $ASFLAGS diff --git a/ld/testsuite/ld-pe/undefined-def-i386.d b/ld/testsuite/ld-pe/undefined-def-i386.d new file mode 100755 index 00000000..dd7943ee --- /dev/null +++ b/ld/testsuite/ld-pe/undefined-def-i386.d @@ -0,0 +1,16 @@ +#source: undefined-def-i386.s +#target: i?86-*-cygwin* i?86-*-pe i?86-*-mingw* +#ld: --gc-sections -shared ${srcdir}/${subdir}/undefined-def-i386.def +#objdump: -h + +#not .*sym3.* +#... +Sections: +Idx Name.* +\s+\d+ export1 .* +^.*$ +\s+\d+ sym1 .* +^.*$ +\s+\d+ sym2 .* +^.*$ +#pass diff --git a/ld/testsuite/ld-pe/undefined-def-i386.def b/ld/testsuite/ld-pe/undefined-def-i386.def new file mode 100755 index 00000000..3c023fc4 --- /dev/null +++ b/ld/testsuite/ld-pe/undefined-def-i386.def @@ -0,0 +1,4 @@ +LIBRARY undefined-def.dll +UNDEFINED +_sym1 +_sym2 diff --git a/ld/testsuite/ld-pe/undefined-def-i386.s b/ld/testsuite/ld-pe/undefined-def-i386.s new file mode 100755 index 00000000..2b89178a --- /dev/null +++ b/ld/testsuite/ld-pe/undefined-def-i386.s @@ -0,0 +1,19 @@ +.global _export1 +.global _sym1 +.global _sym2 +.global _sym3 +.section export1,"xr" +_export1: + ret +.section sym1,"xr" +_sym1: + ret +.section sym2,"xr" +_sym2: + ret +.section sym3,"xr" +_sym3: + ret + +.section .drectve,"yn" +.ascii " -export:export1" diff --git a/ld/testsuite/ld-pe/undefined-def-x86_64.d b/ld/testsuite/ld-pe/undefined-def-x86_64.d new file mode 100755 index 00000000..52314c91 --- /dev/null +++ b/ld/testsuite/ld-pe/undefined-def-x86_64.d @@ -0,0 +1,16 @@ +#source: undefined-def-x86_64.s +#target: x86_64-*-cygwin* x86_64-*-pe x86_64-*-mingw* +#ld: --gc-sections -shared ${srcdir}/${subdir}/undefined-def-x86_64.def +#objdump: -h + +#not .*sym3.* +#... +Sections: +Idx Name.* +\s+\d+ export1 .* +^.*$ +\s+\d+ sym1 .* +^.*$ +\s+\d+ sym2 .* +^.*$ +#pass diff --git a/ld/testsuite/ld-pe/undefined-def-x86_64.def b/ld/testsuite/ld-pe/undefined-def-x86_64.def new file mode 100755 index 00000000..18b4b6d9 --- /dev/null +++ b/ld/testsuite/ld-pe/undefined-def-x86_64.def @@ -0,0 +1,4 @@ +LIBRARY undefined-def.dll +UNDEFINED +sym1 +sym2 diff --git a/ld/testsuite/ld-pe/undefined-def-x86_64.s b/ld/testsuite/ld-pe/undefined-def-x86_64.s new file mode 100755 index 00000000..6d2c70a5 --- /dev/null +++ b/ld/testsuite/ld-pe/undefined-def-x86_64.s @@ -0,0 +1,19 @@ +.global export1 +.global sym1 +.global sym2 +.global sym3 +.section export1,"xr" +export1: + ret +.section sym1,"xr" +sym1: + ret +.section sym2,"xr" +sym2: + ret +.section sym3,"xr" +sym3: + ret + +.section .drectve,"yn" +.ascii " -export:export1" diff --git a/ld/testsuite/ld-pe/undefined-embedded-i386.d b/ld/testsuite/ld-pe/undefined-embedded-i386.d new file mode 100755 index 00000000..690dbf77 --- /dev/null +++ b/ld/testsuite/ld-pe/undefined-embedded-i386.d @@ -0,0 +1,16 @@ +#source: undefined-embedded-i386.s +#target: i?86-*-cygwin* i?86-*-pe i?86-*-mingw* +#ld: --gc-sections -shared +#objdump: -h + +#not .*sym3.* +#... +Sections: +Idx Name.* +\s+\d+ export1 .* +^.*$ +\s+\d+ sym1 .* +^.*$ +\s+\d+ sym2 .* +^.*$ +#pass diff --git a/ld/testsuite/ld-pe/undefined-embedded-i386.s b/ld/testsuite/ld-pe/undefined-embedded-i386.s new file mode 100755 index 00000000..d229429f --- /dev/null +++ b/ld/testsuite/ld-pe/undefined-embedded-i386.s @@ -0,0 +1,21 @@ +.global _export1 +.global _sym1 +.global _sym2 +.global _sym3 +.section export1,"xr" +_export1: + ret +.section sym1,"xr" +_sym1: + ret +.section sym2,"xr" +_sym2: + ret +.section sym3,"xr" +_sym3: + ret + +.section .drectve,"yn" +.ascii " -export:export1" +.ascii " -undefined:_sym1,_unknownsym" +.ascii " -include:_unknownsym,_sym2" diff --git a/ld/testsuite/ld-pe/undefined-embedded-x86_64.d b/ld/testsuite/ld-pe/undefined-embedded-x86_64.d new file mode 100755 index 00000000..5ceceb40 --- /dev/null +++ b/ld/testsuite/ld-pe/undefined-embedded-x86_64.d @@ -0,0 +1,16 @@ +#source: undefined-embedded-x86_64.s +#target: x86_64-*-cygwin* x86_64-*-pe x86_64-*-mingw* +#ld: --gc-sections -shared +#objdump: -h + +#not .*sym3.* +#... +Sections: +Idx Name.* +\s+\d+ export1 .* +^.*$ +\s+\d+ sym1 .* +^.*$ +\s+\d+ sym2 .* +^.*$ +#pass diff --git a/ld/testsuite/ld-pe/undefined-embedded-x86_64.s b/ld/testsuite/ld-pe/undefined-embedded-x86_64.s new file mode 100755 index 00000000..1331c3f0 --- /dev/null +++ b/ld/testsuite/ld-pe/undefined-embedded-x86_64.s @@ -0,0 +1,21 @@ +.global export1 +.global sym1 +.global sym2 +.global sym3 +.section export1,"xr" +export1: + ret +.section sym1,"xr" +sym1: + ret +.section sym2,"xr" +sym2: + ret +.section sym3,"xr" +sym3: + ret + +.section .drectve,"yn" +.ascii " -export:export1" +.ascii " -undefined:sym1,unknownsym" +.ascii " -include:unknownsym,sym2"