From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-oln040092003027.outbound.protection.outlook.com [40.92.3.27]) by sourceware.org (Postfix) with ESMTPS id D7C5C397200C for ; Thu, 1 Oct 2020 03:48:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D7C5C397200C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maskray.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=i@maskray.me ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CwbE2HbPAt95VCj9yfzCS07LNRAolPjpLpMGy0ks/5EYbUXVQdwylcyvg0cVD+Us1RSV1VLcck03lSHJN8z3BoztmMqRZbTkSqqbJNaem6ExxXoNsC2KfOLF9MTVj3nObQumtRlZ2htK4/ltlTmxx4a3FXP5eWpGTon8ERUNg1ZN8miqfnBBttNY9rnT32M+cjeH2QmXtdI+eNNSKeN8OMF5hGEAF321h8chvqJsVsX9JB/YSP05npQr7THWuEGLYGWNEtWVu503dftOVhtJsmPptqmZRVwxwT1dtj+BMg1IIvB+t3tUUrt5alVT0XV4Kpbt+P59l7FIyt0rZL94cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zfEZESSft9vp5LWB9l7ROcWpsrY/rB1TehaTAlVCHK0=; b=gelj9+tjB7atbhcqqskWo+9BJsq1YigSbOETJculttg49guoRDSSGdQMgrF2YtRr0fen7src771+dQbBj1PydK783R05ZGwLI2hNsOMVjjVAXtNv0JXzK5BQvdGU1czD6UMwAgg7OddUUU8X/MPSShcavqmiwV1Fu6fTWwJEDabvx6LzwZXZYfVjALngg9c/RhGyKltC2OlTVSq2+RwEty+VhlUfNAExil5T/kwHmIykojvtsEC8r4Wm3hZHHI4gCaoM8NYIU4CRrNZ2D1pOTgd+IfbVcVZlBUEP+7fzRK1KeapjbVB4SDsEPaV1CxgqSQqTXdWl8W3usmKQBvfUoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from BL2NAM02FT028.eop-nam02.prod.protection.outlook.com (10.152.76.57) by BL2NAM02HT104.eop-nam02.prod.protection.outlook.com (10.152.77.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.21; Thu, 1 Oct 2020 03:48:14 +0000 Received: from MWHPR12MB1456.namprd12.prod.outlook.com (2a01:111:e400:7e46::46) by BL2NAM02FT028.mail.protection.outlook.com (2a01:111:e400:7e46::421) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.21 via Frontend Transport; Thu, 1 Oct 2020 03:48:14 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:8A9BE40F60687C046F9C2060851269BF800FCCC2A725ECB2765F8A108BE91BDE; UpperCasedChecksum:551181D949939589EE6197B54ACB2C6DE301A7B35760E8DFC86521224952D4B9; SizeAsReceived:9419; Count:50 Received: from MWHPR12MB1456.namprd12.prod.outlook.com ([fe80::99bb:68ba:9c0c:c4a9]) by MWHPR12MB1456.namprd12.prod.outlook.com ([fe80::99bb:68ba:9c0c:c4a9%6]) with mapi id 15.20.3433.032; Thu, 1 Oct 2020 03:48:14 +0000 X-Gm-Message-State: AOAM530DTBKDd53wy7Z2rSCEeiBDvAPUfbKCkdirheI5NszRyz9XoHsb /2u7gSUKuI/K38/jY42KIQdu1b2+JDH2/Xlmo4Q= X-Google-Smtp-Source: ABdhPJwtoqFCzp1jDWA3WHIt32wSGpY7O235meqAY3sw9AsMTMbzbAqGnJZDvRU3GpoX2ysXsx9MeFG49ffmi8kfvf4= X-Received: by 2002:a37:478c:: with SMTP id u134mr6164432qka.206.1601523729852; Wed, 30 Sep 2020 20:42:09 -0700 (PDT) References: <87pn647h1h.fsf@redhat.com> <20200929165317.2yebvny6gas4jz5f@gmail.com> <3609c590-8750-a021-92fb-05ff0ba7ca7d@redhat.com> <8176aa1f-3c9b-45ec-b1a3-8e7cf19de47c@redhat.com> In-Reply-To: From: Fangrui Song Date: Wed, 30 Sep 2020 20:41:59 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] elf: Also check linked-to section for SHT_NOTE section To: "H.J. Lu" Cc: Nick Clifton , Binutils Content-Type: text/plain; charset="UTF-8" X-TMN: [WiiRBNabt8l2xSNHgnU6nz37KyU0vnyj] X-ClientProxiedBy: MN2PR20CA0011.namprd20.prod.outlook.com (2603:10b6:208:e8::24) To MWHPR12MB1456.namprd12.prod.outlook.com (2603:10b6:301:f::9) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mail-qk1-f171.google.com (209.85.222.171) by MN2PR20CA0011.namprd20.prod.outlook.com (2603:10b6:208:e8::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.34 via Frontend Transport; Thu, 1 Oct 2020 03:48:13 +0000 Received: by mail-qk1-f171.google.com with SMTP id q5so3993045qkc.2 for ; Wed, 30 Sep 2020 20:48:13 -0700 (PDT) X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 0196b9f4-e8c0-4bab-7b71-08d865bcd2d3 X-MS-TrafficTypeDiagnostic: BL2NAM02HT104: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qKUQSI0NO0nYv53dSWGsUYodeVATN1X6j2wXSvL5SURB9cL9ckU3wLdgSdFqDohpzsGr63bIBXptGK2aqUvTB8f9jrPdfgswjF6OBaD5PJT3E7xu39LuSQBHR4tXA6m3z3Y6+2s0FFAI6iJlKX7N0fYAIaMwkV8AQflDvB6mcZZVPNhzRHU7pp41fAgFbBJOyd6nhdAxkc8SCxH/GIAORaYh8TB2WUS2hx3XKbTH2HrosJ8qz4WrS1w1SPfLnZXE X-MS-Exchange-AntiSpam-MessageData: izWaLneglAP7Xk2YAMK6S4/DLbDq0t/oxEpiSHckXaa8PUFCrozRLCxKmb8lcxAKcWOBEFGZEZnHtZyiDgM5GF7jSWkVCBinBOqHNq3A+0w/WHh1745CFjHTKNpwI+TB2YjyPsNsvhFGP8fyHh2KPw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0196b9f4-e8c0-4bab-7b71-08d865bcd2d3 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2020 03:48:14.0886 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: BL2NAM02FT028.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2NAM02HT104 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_INFOUSMEBIZ, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Oct 2020 03:48:17 -0000 On Wed, Sep 30, 2020 at 7:03 AM H.J. Lu wrote: > > On Wed, Sep 30, 2020 at 7:01 AM Nick Clifton wrote: > > > > Hi H.J. > > > > Thanks for taking an interest in this. > > > > > Please try this patch. > > It did not appear to make a difference. :-( > > > > I am using an extended test case (attached) but the results are the > > same as before: > > > > % as eliminate.s -o eliminate.o > > % ld -e 0 --gc-sections --print-gc-sections eliminate.o > > ld: removing unused section '.group' in file 'eliminate.o' > > ld: removing unused section '.group' in file 'eliminate.o' > > ld: removing unused section '.text' in file 'eliminate.o' > > ld: removing unused section '.unused1' in file 'eliminate.o' > > ld: removing unused section '.unused2[unused_group]' in file 'eliminate.o' > > ld: removing unused section '.unused3[unused_group2]' in file 'eliminate.o' > > ld: removing unused section '.gnu.note2[unused_group]' in file 'eliminate.o' > > ld: removing unused section '.gnu.note3[unused_group2]' in file 'eliminate.o' > > ld: a.out: sh_link of section `.gnu.note1' points to discarded section `.unused1' of `eliminate.o' > > ld: final link failed: bad value > > > > Cheers > > Nick > > Works for me: > > [hjl@gnu-cfl-2 ld]$ gcc -c eliminate.s > [hjl@gnu-cfl-2 ld]$ ./ld-new -e 0 --gc-sections --print-gc-sections eliminate.o > ./ld-new: removing unused section '.group' in file 'eliminate.o' > ./ld-new: removing unused section '.group' in file 'eliminate.o' > ./ld-new: removing unused section '.text' in file 'eliminate.o' > ./ld-new: removing unused section '.unused1' in file 'eliminate.o' > ./ld-new: removing unused section '.unused2[unused_group]' in file 'eliminate.o' > ./ld-new: removing unused section '.unused3[unused_group2]' in file > 'eliminate.o' > ./ld-new: removing unused section '.gnu.note1' in file 'eliminate.o' > ./ld-new: removing unused section '.gnu.note2[unused_group]' in file > 'eliminate.o' > ./ld-new: removing unused section '.gnu.note3[unused_group2]' in file > 'eliminate.o' > [hjl@gnu-cfl-2 ld]$ > > > -- > H.J. Thanks HJ for the patch. The --gc-sections semantics I expect are written down here: https://sourceware.org/pipermail/binutils/2020-February/109851.html (If SHF_GNU_RETAIN (https://sourceware.org/pipermail/binutils/2020-September/113534.html) is accepted, a SHF_GNU_RETAIN section will be added to the GC root list. I forwarded the progress to a few toolchain folks on LLVM side and encouraged them to reply if they still have concerns.)