From patchwork Tue Oct 4 16:22:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Lapshin X-Patchwork-Id: 1691 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp205781wrs; Tue, 4 Oct 2022 09:23:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6PYd2QCy/XGgOthGMspjyXvWpxKHwfI0QJk+Dve5/7c8H4LLGaUL/exrCWLbbMwNntvse5 X-Received: by 2002:a17:907:5ce:b0:730:bae0:deb with SMTP id wg14-20020a17090705ce00b00730bae00debmr20321526ejb.181.1664900582167; Tue, 04 Oct 2022 09:23:02 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gn17-20020a1709070d1100b00730ac298aa9si11616307ejc.783.2022.10.04.09.23.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 09:23:02 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=BTgzWJxs; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA970385828E for ; Tue, 4 Oct 2022 16:23:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EA970385828E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664900581; bh=CoM+jgZSxIqq21b99pO4hBfR75h8X6jMS3c2gEv2G9M=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=BTgzWJxsJ7F3ETDV9E8hAXXZVe8AVj01tdz2VwqnNcFt7b0KkZ9iPT8aZLhffXy09 tucp6iroFH7DAibsqPwvkx6skLC2rXPwmlmQgFYmGcGwhACn/Z5iuforBsheOiXrqq SVEp+GthlIZj+I1H8vShuKw1iLFGs/pzgDtZSVwo= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2107.outbound.protection.outlook.com [40.107.117.107]) by sourceware.org (Postfix) with ESMTPS id 191D53858D37 for ; Tue, 4 Oct 2022 16:22:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 191D53858D37 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IczTRYPZEa0f9+uP4vI0f1bnJSNC+X+Fm2e3UcoN5Gw5ZYiJpFKZHytblPHPAkYSssOiNQL2oNQc9SnNlbrl4JUhjVaWmKy60iSSxVBik9dSvmf4GzupCJXXbUbCuNKMovzYSKQW9A1NnPcCJ9Vez2Enk6QeEE0VrUbb1bcR2kMaR33aGfsXorFjTrMKq1ZS4V+94b8Eo5MF8cUVEfLBvqlyYOuWIsUIHtKoXdb+Fiuc7/P/H/AQ12/xREkZG+ozS9/0zBf+j3MNW9yhxGUtYSdQeYs8K07AJDJ6lmyqpcC97fzcmcfHO4k0GGx8AK5N5QV5vBmwJ+YYAPj9jygvnA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CoM+jgZSxIqq21b99pO4hBfR75h8X6jMS3c2gEv2G9M=; b=hHxwpOoF7rbCZ2CnqF/pYkX6CJFY4Fj36taNlPH9qa1a/FWZpv0+zTBaG6jFbY0KQkdhIk19eJdJrxQmX2xOAY2Tfinl5OYupM1ezFFgQdzSd38c4V+s6ImQ2VL6M982V+4zKuZNlN0ZXZIZybEq7CQ1Dag1myavWwk7Oj/0+vm6j2oZNgK7wlZoS8+FzUbQckuZW19go9bSRD9cMiepORedi/zeL/g9Xloux9MZWSfddOXKSft+UoRQr+QAhjj6jNNw1N6CYiy6bWME7db66s2QRBfa5mbnKd6yVFSa6Ogb6q+o/dZ1rB3y5HxiO2vrEe6F1zg9rr3oYBQEjOONfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=espressif.com; dmarc=pass action=none header.from=espressif.com; dkim=pass header.d=espressif.com; arc=none Received: from TYZPR04MB5736.apcprd04.prod.outlook.com (2603:1096:400:1fa::7) by SEZPR04MB5828.apcprd04.prod.outlook.com (2603:1096:101:7c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Tue, 4 Oct 2022 16:22:05 +0000 Received: from TYZPR04MB5736.apcprd04.prod.outlook.com ([fe80::1158:9697:c801:3d13]) by TYZPR04MB5736.apcprd04.prod.outlook.com ([fe80::1158:9697:c801:3d13%9]) with mapi id 15.20.5676.017; Tue, 4 Oct 2022 16:22:05 +0000 To: "binutils@sourceware.org" Subject: [PATCH] bfd: xtensa: fix __stop_SECTION literal drop, Thread-Topic: [PATCH] bfd: xtensa: fix __stop_SECTION literal drop, Thread-Index: AQHY2A1x+sglB13V7kui1yJD+toF0Q== Date: Tue, 4 Oct 2022 16:22:05 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: TYZPR04MB5736:EE_|SEZPR04MB5828:EE_ x-ms-office365-filtering-correlation-id: 28da437f-12b9-455e-c120-08daa62493a7 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8v7COYH48AFFjCVe7ws6vxoPM8jOuAlojlkwV7HeXyzDaAJLzCeKiM13AIW+ECiGqju49HCEuML7HTdllpeS15E4BnO1rXh0HTM1JtnOafCKpDQf67e+iWawWxajt70vks7bz8SmICfk7OdsCZ6CAcxyuv25JQkhKZctlco4odLSCcUPyODsA75x5x4qTfBFpNPxhrdBDJ/caxDcXN79YijlwAL1HNi5uYlQZ5fZctBrKWWWl/iZCxJBuksjvPPhum4mdlCFERcISXH4iHtVr1gPhFtg7BIN0L9YP37cvsbyLQ0/O8PZoQUumMDSXcjkbWOt7hPLSzlmAqoJF6IF7sLWIsC02cRfrFJB62p/+AG6YL0DL3z6oomsRSctfYBKsOypIbqUeb9JI+PaFS5s/FBBzRQwWq+4sw6t8iazk/SVPOHZq6gQeHLS0FCcB2daOabQEyA8LRaeUVe3wrgGokRZlFaDVv5f/eQQHDKFoh3hVbpmUE0ZyuOCWU0p90Gia36pcy6HOrn7LPkoT/Av/TtYZEu/MpitK30YDf2KgGpbAf+lL8Tmxil4OoAsOgtwR6KGDHe1Vs198OOX3tcW2yrDQu5yxjxuYopbY7do7p5+DT6rMp8vtxR+pxIqc0JBHGn+GVy7DDVLpDF+fhM3VCj0EgGMRo1RcbeXz/E59HL6uiy2QBfOhaz1U7v5tCKUEwB9uHnskkUk62JacATcNKynxc0ZEHU/+oDhUumPqzUwRTbBNzRcOTTYG6NFK/XBKckx1Oprk77er1KqvIIV0A== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYZPR04MB5736.apcprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(366004)(396003)(376002)(136003)(346002)(39850400004)(451199015)(38100700002)(316002)(2906002)(122000001)(2616005)(38070700005)(44832011)(6486002)(6512007)(41300700001)(8936002)(5660300002)(186003)(26005)(6506007)(76116006)(53546011)(478600001)(4326008)(66556008)(64756008)(71200400001)(8676002)(66946007)(66476007)(66446008)(107886003)(36756003)(91956017)(6916009)(54906003)(86362001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?0qsfsbwYvG7qhjoyBxT8jUXm5tRh?= =?utf-8?q?VChbcJrfIE+DykpyheOuyomEDMw3kyBokxNbcIR3hB0/BuM22dvp534a9e7So9703?= =?utf-8?q?3y6ghmBZFawZPy5+++finvmgVvKEDCnr9PHrJBTuOTS/vq2HwMyWv2fXZmSgpy5bc?= =?utf-8?q?q9jIpXfYa8dIbixjuyWzWiw5hGjQHBnpGM/jup8gWfV5Vp4W5U401EeKioawOwrLg?= =?utf-8?q?uEBTjCF9kNFczpx6+iRxjiqTehclNn/C5NNT1GZma1TmBVgKUNQFv4EWn3aqnq6sy?= =?utf-8?q?xg+tvvVRNu2E0KjeNzeXdb9SjHUP2sXpnHf7IoaVTxpEc7zU3AppvTYoG7gehWy9S?= =?utf-8?q?e5R73H9g/ZywgGv4LUFCAGqxHaPPTsF8DQP1kCEwiLSYPOOV7WYQ9/7NMcABVQGHQ?= =?utf-8?q?qhXYpxo7O3XNrtOQMB9CND1r6wtV3k1ItptIchejQ9GBhqTuxZtDuoyGp/O+kPwrp?= =?utf-8?q?Dpkh9So+UqFVmpPKBiUT/dB0pV4Pw4It3TZaKfNrDOg9KGN5ejLOVBbRyrmBvwkLH?= =?utf-8?q?pZig4In+yUW+PLvr98jwGITsjOdE2qIJ4dfKOpxAh7S/8s0gQCbZ9RPRdatoDuTtq?= =?utf-8?q?10jdpSJzrTVxoS6+qciTiZ8dz4NggbQPwIGQWQ8PtPqHd4O6A4zg33uqgQldkw+qu?= =?utf-8?q?t28yjc1J+y/CRt40yb7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TM/X7JbTYj5NXXfHpg=3D=3D?= Content-ID: MIME-Version: 1.0 X-OriginatorOrg: espressif.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TYZPR04MB5736.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 28da437f-12b9-455e-c120-08daa62493a7 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Oct 2022 16:22:05.1999 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 5faf27fd-3557-4294-9545-8ea74a409f39 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Hfg+rPPp7x2JMeS+7C8HrUCYK9vmIYa5Ruh/KNBpNCQRmi7RNr7Kkgi0qaXMUKL4/W6WVPqh5w1/lEWdEbBtXFErHQX7PBCcHhdE0riQxfg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR04MB5828 X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Alexey Lapshin via Binutils From: Alexey Lapshin Reply-To: Alexey Lapshin Cc: Ivan Grokhotkov , Alexey Gerenkov , Anton Maklakov Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745774792872059000?= X-GMAIL-MSGID: =?utf-8?q?1745774792872059000?= From b5cdb6b44dfd6d36608f63e8795cd669da97a123 Mon Sep 17 00:00:00 2001 From: Alexey Lapshin Date: Wed, 3 Aug 2022 18:45:39 +0400 Subject: [PATCH] bfd: xtensa: fix __stop_SECTION literal drop Literals placement algorithm may drop __stop_SECTION symbol as duplicated because it is not initialized yet and we can not differ it from __start_SECTION symbol at this stage. Both symbols will be initialized a bit later. This workaround prevented start_stop symbols from equality in compare function --- bfd/elf32-xtensa.c | 7 +++++++ ld/testsuite/ld-xtensa/startstop.d | 6 ++++++ ld/testsuite/ld-xtensa/startstop.s | 16 ++++++++++++++++ ld/testsuite/ld-xtensa/xtensa.exp | 2 ++ 4 files changed, 31 insertions(+) create mode 100644 ld/testsuite/ld-xtensa/startstop.d create mode 100644 ld/testsuite/ld-xtensa/startstop.s -- 2.34.1 diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index ce3c46f69e5..cb658483ca6 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -5244,6 +5244,13 @@ literal_value_equal (const literal_value *src1, (if undefined or weak). */ h1 = r_reloc_get_hash_entry (&src1->r_rel); h2 = r_reloc_get_hash_entry (&src2->r_rel); + + /* Keep start_stop literals always unique to avoid dropping it due to they + have late initialization. + Now they are equal because initialized with zeroed values. */ + if (h2 && h2->start_stop) + return false; + if (r_reloc_is_defined (&src1->r_rel) && (final_static_link || ((!h1 || h1->root.type != bfd_link_hash_defweak) diff --git a/ld/testsuite/ld-xtensa/startstop.d b/ld/testsuite/ld- xtensa/startstop.d new file mode 100644 index 00000000000..6cea49add33 --- /dev/null +++ b/ld/testsuite/ld-xtensa/startstop.d @@ -0,0 +1,6 @@ +#as: +#ld: +#objdump: -h +#... +.*TEST_SECTION\.literal[ ]*00000008.* +#... diff --git a/ld/testsuite/ld-xtensa/startstop.s b/ld/testsuite/ld- xtensa/startstop.s new file mode 100644 index 00000000000..b94b0ec573c --- /dev/null +++ b/ld/testsuite/ld-xtensa/startstop.s @@ -0,0 +1,16 @@ + .file "startstop.s" + .text + .section .rodata + .align 4 +.LC0: + .section TEST_SECTION,"aw" + .align 4 + .literal_position + .literal .LC1, __start_TEST_SECTION + .literal .LC2, __stop_TEST_SECTION + .align 4 + .global _start + .type _start, @function +_start: + l32r a2, .LC1 + l32r a3, .LC2 diff --git a/ld/testsuite/ld-xtensa/xtensa.exp b/ld/testsuite/ld- xtensa/xtensa.exp index 71d1597fc72..c09b865f2b4 100644 --- a/ld/testsuite/ld-xtensa/xtensa.exp +++ b/ld/testsuite/ld-xtensa/xtensa.exp @@ -41,3 +41,5 @@ run_dump_test "relax-undef-weak-pie-export-dynamic" run_dump_test "relax-undef-weak-local-pie" run_dump_test "relax-undef-weak-shared" run_dump_test "relax-undef-weak-local-shared" + +run_dump_test "startstop"