From patchwork Tue May 12 23:53:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Wilson X-Patchwork-Id: 1288844 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=d2wgnpzL; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49MF4W5wlrz9sSF for ; Wed, 13 May 2020 09:53:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1657F386F831; Tue, 12 May 2020 23:53:25 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by sourceware.org (Postfix) with ESMTPS id C66FE386F447 for ; Tue, 12 May 2020 23:53:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C66FE386F447 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=jimw@sifive.com Received: by mail-pj1-x1043.google.com with SMTP id t9so10328197pjw.0 for ; Tue, 12 May 2020 16:53:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id; bh=ZLg5ASLK30bwvcVlXJ0by8L1hKPJBxpRPZ487dSbMMA=; b=d2wgnpzLMyQ4Pr+k+yNk6999VOu4vWuXYRfVGbn4Z0JomtrIJHHUVt9HSg/DkO8x38 7s2m445CANHsTp5d5IaeQ85yM1TA2rdUkaerR8SWLjqOPtfT589ADz6+qwBHmVe2EXVP 8eON0j1oh7PTejlm5ZlNUTvWiiWOCHYu5OCK7EC4xbaABwzvOcb6KFNm7rmJhxjtHl7T OXoTbpojxetSXmAOLn3ZXBij1YlEjhfkQAkWVFKvZDpIOHu+39sl+6Zg37dhkKE6TQkE 76/SD3c1FjabHfuTtNZrtM1GPQm0dl054CZo/u7I+74cD7B4wybsl6R4EVGYF1jDoaD5 RXgg== 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; bh=ZLg5ASLK30bwvcVlXJ0by8L1hKPJBxpRPZ487dSbMMA=; b=KYSCoir6ylBuWRXY5IXeZ8g/TB5TsVIFUwJIYdOjuN57Dd4qgojHA32OyymKVipAUz iyVRJufF5ehdT25MBoA7YX74C7/jn0qrKZBEiyPcl3KnudXzSBPV0T9qY7sn1jDW2kBS 8vvFWbZNr/YBFyG6bMmKpvXkr1emSZIVeUuKlaJGWZ/lKJ+y0RuMtb2AEFLENI3G2F7M jRA3KeyDqunlSmEaAMVN5sFWlMOlXvcUaFcNkCPKAcVlZlnpvOIywZzYt8X+aLCuRV6D VoZeMApFP/u6U58aYaP5jDr4CX6WLBBGq2FmIV1bjUrmIbhVUPA/NjEP+e/rzTUCXIDC jOZA== X-Gm-Message-State: AGi0Pub0alT8dQO3woVJegHwlsVJx+qFhS7vEH1japfCZkVlhF0omgjt Ku3tW+JH+jES5M0zzYJHjO3dntBNghE= X-Google-Smtp-Source: APiQypLmy1KP5nM4WNTe0bkmuUNl6mzna0nTwwZ6jVNpTRcJ0WJ2khpwoQszsXhvWPFX1EwFzvpt+g== X-Received: by 2002:a17:90b:1498:: with SMTP id js24mr31270740pjb.214.1589327600054; Tue, 12 May 2020 16:53:20 -0700 (PDT) Received: from rohan.hsd1.ca.comcast.net ([2601:646:c180:b150:a162:93a1:261:918a]) by smtp.gmail.com with ESMTPSA id e196sm12691543pfh.43.2020.05.12.16.53.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2020 16:53:19 -0700 (PDT) From: Jim Wilson To: gcc-patches@gcc.gnu.org Subject: [PATCH] RISC-V: Make unique SECCAT_SRODATA names start with .srodata Date: Tue, 12 May 2020 16:53:14 -0700 Message-Id: <20200512235314.8586-1-jimw@sifive.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: , Cc: Keith Packard Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This fixes a bug reported to the RISC-V sw-dev mailing list late last year. https://groups.google.com/a/groups.riscv.org/forum/#!topic/sw-dev/JV5Jdh4UjVw Keith Packard wote the obvious patch to fix it. I tested it with cross builds for riscv32-newlib and riscv64-linux. There were no regressions. Checking toolchain libraries with objdump shows that there are no longer sdata2 sections in the libraries. Committed. Jim 2020-05-12 Keith Packard * config/riscv/riscv.c (riscv_unique_section): New. (TARGET_ASM_UNIQUE_SECTION): New. default_unique_section uses ".sdata2" as a prefix for SECCAT_SRODATA unique sections, but RISC-V uses ".srodata" instead. Override the TARGET_ASM_UNIQUE_SECTION function to catch this case, allowing the default to be used for all other sections. Signed-off-by: Keith Packard --- gcc/config/riscv/riscv.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c index e4c08d780db..1ad9799fce4 100644 --- a/gcc/config/riscv/riscv.c +++ b/gcc/config/riscv/riscv.c @@ -3492,6 +3492,43 @@ riscv_select_section (tree decl, int reloc, } } +/* Switch to the appropriate section for output of DECL. */ + +static void +riscv_unique_section (tree decl, int reloc) +{ + const char *prefix = NULL; + bool one_only = DECL_ONE_ONLY (decl) && !HAVE_COMDAT_GROUP; + + switch (categorize_decl_for_section (decl, reloc)) + { + case SECCAT_SRODATA: + prefix = one_only ? ".sr" : ".srodata"; + break; + + default: + break; + } + if (prefix) + { + const char *name, *linkonce; + char *string; + + name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); + name = targetm.strip_name_encoding (name); + + /* If we're using one_only, then there needs to be a .gnu.linkonce + prefix to the section name. */ + linkonce = one_only ? ".gnu.linkonce" : ""; + + string = ACONCAT ((linkonce, prefix, ".", name, NULL)); + + set_decl_section_name (decl, string); + return; + } + default_unique_section (decl, reloc); +} + /* Return a section for X, handling small data. */ static section * @@ -5254,6 +5291,9 @@ riscv_new_address_profitable_p (rtx memref, rtx_insn *insn, rtx new_addr) #undef TARGET_ASM_SELECT_SECTION #define TARGET_ASM_SELECT_SECTION riscv_select_section +#undef TARGET_ASM_UNIQUE_SECTION +#define TARGET_ASM_UNIQUE_SECTION riscv_unique_section + #undef TARGET_ASM_SELECT_RTX_SECTION #define TARGET_ASM_SELECT_RTX_SECTION riscv_elf_select_rtx_section