From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by sourceware.org (Postfix) with ESMTPS id 7053C384241B for ; Fri, 4 Dec 2020 16:17:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7053C384241B Received: by mail-pj1-x102c.google.com with SMTP id l23so3425491pjg.1 for ; Fri, 04 Dec 2020 08:17:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jhpf6Wp0m+sbK8rJKZpZj/OECWEh+YcvjSN8PXC51Vg=; b=YisVBXrD3BSJrsAjkQkE0YzqedcuY3Koj4HeW6XAA2+xOR8cEjvnAT56zmR0+eJdwg maJ9MgZ/61GKoqX4dFOo+FWLokjI77Uq8rBWvRfXI0GnSRIWUjtqd6QetVn+G/bagnLw kj7CUO9PbrokB9yR6il2e9K4qziSb4INFxcGCOlZTV1EDhNQaBGTk/iYyFMBDvHlOoes hcgkTWf63g4ICwvRLIxE9kCf+KGovnx4/6LRXsosh+yd7af6kKj6A5+5JF86/W5FsVNw 41lPKwyDLEKlIB1cFf9C7tWEoZ/MWRW8fNMcbQTn8vlEftoNeX36GtMIf9hFSRRjtKWS h0Wg== X-Gm-Message-State: AOAM5309g5jfb9sN8dJx/jErTntyLhb7U4ACrutd2IB+eGfkSkQDuK0M Ajtlkx+M2ejgNIRuR6QAgzlfUEaZ18M= X-Google-Smtp-Source: ABdhPJwjuT52AWT7sHfTYlJQahXESocNxcX6Wt3ReANVtwjn7pRiZBnmIqbinom2PjGKnFzw0nm0xQ== X-Received: by 2002:a17:902:aa04:b029:d8:b7a8:6a3e with SMTP id be4-20020a170902aa04b02900d8b7a86a3emr4468829plb.58.1607098648901; Fri, 04 Dec 2020 08:17:28 -0800 (PST) Received: from gnu-cfl-2.localdomain (c-69-181-90-243.hsd1.ca.comcast.net. [69.181.90.243]) by smtp.gmail.com with ESMTPSA id k4sm2495387pjo.54.2020.12.04.08.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 08:17:26 -0800 (PST) Received: from gnu-cfl-2.localdomain (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 2FE7A1A0104; Fri, 4 Dec 2020 08:17:25 -0800 (PST) From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Subject: V2 [PATCH 0/2] Switch to a new section if the SECTION_RETAIN bit doesn't match Date: Fri, 4 Dec 2020 08:17:21 -0800 Message-Id: <20201204161723.3625721-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3034.4 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: Fri, 04 Dec 2020 16:17:31 -0000 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-plain-output c.c:2:49: error: ‘foo1’ causes a section type conflict with ‘foo2’ c.c:1:54: note: ‘foo2’ 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: ‘foo1’ without ‘used’ attribute and ‘foo2’ with ‘used’ attribute are placed in a section with the same name [-Wattributes] 2 | const int __attribute__((section(".data.foo"))) foo1 = 1; | ^~~~ c.c:1:54: note: ‘foo2’ was declared here 1 | const int __attribute__((used,section(".data.foo"))) foo2 = 2; | [hjl@gnu-cfl-2 gcc]$ 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 | 45 +++++++++++++++++++++--- 7 files changed, 142 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 -- 2.28.0