From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by sourceware.org (Postfix) with ESMTPS id EFA8D3846012 for ; Sun, 13 Dec 2020 16:03:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EFA8D3846012 Received: by mail-oo1-xc32.google.com with SMTP id k7so2870226ooa.0 for ; Sun, 13 Dec 2020 08:03:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=UFnT8FtW9lN5xtDhRQ60dgP7imnA9fbEZla//pB00J8=; b=HXgG8iEmfCaDBOOO00LL45uUuuLSoJ5gtGfEMDH9HixcI9MNJtrNjIUb2bOgLiyf8l 1d7V0Qx4ugrCTgHGhKIkwqNULsPOKVr8czS1KEp+8t/hbsqWJBxMuu86g+GMemmxQF92 02WDimBws5DQWolwBJZC7atfO0BH0jlTeot5+EAmC0NhE2eEodwWgdBIta51ah55FGw4 AXADVBrw6UvMh0KTZ4dksIhg+JqUXngwIZ+5xKoyJlC6iMmzxWIvZS+wwW6nmMeOWOkv P0rPYMA9pNBz8b/PAs/rr6SYqzXLchd3tfgywD5sOeHpUFND9oYzHG1g6a74CcMD8DZ7 jmgA== X-Gm-Message-State: AOAM530iqgM1trqrPkKwKYGl/PFViWPIJz4uxbZO/ds4FBTXH/O7yP98 Dl5w616ATdsGQ+VYyKqb1xPcvPJvNb614RCoxUoB0bqj X-Google-Smtp-Source: ABdhPJz+Ke8AJh0oETPLBfYv4TniFi7QCpl4zbme3q4WOVTI1L4W6lbqmWIMTpQcJ9fsM11bcC25yZP4z5475ZDfM+k= X-Received: by 2002:a4a:6459:: with SMTP id d25mr16493601oof.35.1607875425979; Sun, 13 Dec 2020 08:03:45 -0800 (PST) MIME-Version: 1.0 References: <20201208125128.775313-1-hjl.tools@gmail.com> In-Reply-To: <20201208125128.775313-1-hjl.tools@gmail.com> From: "H.J. Lu" Date: Sun, 13 Dec 2020 08:03:10 -0800 Message-ID: Subject: PING^1: V3 [PATCH 0/2] Switch to a new section if the SECTION_RETAIN bit doesn't match To: GCC Patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3030.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Dec 2020 16:03:48 -0000 On Tue, Dec 8, 2020 at 4:51 AM H.J. Lu wrote: > > When SECTION_RETAIN is used, definitions marked with used attribute and > unmarked definitions are placed in a section with the same name. Instead > of issue an error: > > [hjl@gnu-cfl-2 gcc]$ /usr/gcc-11.0.0-x32/bin/gcc -S c.c -fdiagnostics-pla= in-output > c.c:2:49: error: =E2=80=98foo1=E2=80=99 causes a section type conflict wi= th =E2=80=98foo2=E2=80=99 > c.c:1:54: note: =E2=80=98foo2=E2=80=99 was declared here > [hjl@gnu-cfl-2 gcc]$ > > the first patch switches to a new section if the SECTION_RETAIN bit > doesn't match. The second optional patch issues a warning: > > [hjl@gnu-cfl-2 gcc]$ ./xgcc -B./ -S c.c > c.c:2:49: warning: =E2=80=98foo1=E2=80=99 without =E2=80=98used=E2=80=99 = attribute and =E2=80=98foo2=E2=80=99 with =E2=80=98used=E2=80=99 attribute = are placed in a section with the same name [-Wattributes] > 2 | const int __attribute__((section(".data.foo"))) foo1 =3D 1; > | ^~~~ > c.c:1:54: note: =E2=80=98foo2=E2=80=99 was declared here > 1 | const int __attribute__((used,section(".data.foo"))) foo2 =3D 2; > | > [hjl@gnu-cfl-2 gcc]$ > > Changes from V2: > > 1. Add (new_section->common.flags & SECTION_NAMED) check since > SHF_GNU_RETAIN section must be named. > 2. Move c-c++-common/attr-used-9.c to the fist patch since there are > no new warnings. > 3. Check new warnings only for R_flag_in_section target. > > H.J. Lu (2): > Switch to a new section if the SECTION_RETAIN bit doesn't match > Warn used and not used symbols in section with the same name > > gcc/output.h | 2 +- > gcc/testsuite/c-c++-common/attr-used-5.c | 27 ++++++++++++++ > gcc/testsuite/c-c++-common/attr-used-6.c | 27 ++++++++++++++ > gcc/testsuite/c-c++-common/attr-used-7.c | 9 +++++ > gcc/testsuite/c-c++-common/attr-used-8.c | 9 +++++ > gcc/testsuite/c-c++-common/attr-used-9.c | 28 +++++++++++++++ > gcc/varasm.c | 46 +++++++++++++++++++++--- > 7 files changed, 143 insertions(+), 5 deletions(-) > create mode 100644 gcc/testsuite/c-c++-common/attr-used-5.c > create mode 100644 gcc/testsuite/c-c++-common/attr-used-6.c > create mode 100644 gcc/testsuite/c-c++-common/attr-used-7.c > create mode 100644 gcc/testsuite/c-c++-common/attr-used-8.c > create mode 100644 gcc/testsuite/c-c++-common/attr-used-9.c > PING. --=20 H.J.