From patchwork Fri May 7 02:49:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 1475307 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; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=i8MyVwd6; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.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 4Fbw110vZhz9sVt for ; Fri, 7 May 2021 12:50:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 27750389641E; Fri, 7 May 2021 02:50:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 27750389641E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1620355826; bh=Ew4F4/HC+Fw5IuyQnxlUIHB9iRfZua2NTo2GbaE4Ysw=; h=To:Subject:Date:In-Reply-To:References:In-Reply-To:References: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: List-Subscribe:From:Reply-To:Cc:From; b=i8MyVwd6WwuD1S0zBeMXKKQFGurzDYaX0765WkaAbed3Te9cpTrhlQnGmN8Aleb3x KPEpmeLmBOrIfJDrOhwnScW4ftH4eweM176x1NSc+DwKruLXcG2MHbFNF24R3D+CFD PdqW5TIaUIGQ+6s91FIkIsc1RDxLtyK1KhdKtAy0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 78A593AA9C52 for ; Fri, 7 May 2021 02:50:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 78A593AA9C52 Received: by mail-pf1-x429.google.com with SMTP id p4so6642952pfo.3 for ; Thu, 06 May 2021 19:50:23 -0700 (PDT) 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:in-reply-to :references:in-reply-to:references; bh=Ew4F4/HC+Fw5IuyQnxlUIHB9iRfZua2NTo2GbaE4Ysw=; b=ZtdwIiLQ0bjBCifnOxF1KLmHvM72jzPgIj+sb8UZKI0KH5h0crRShIdOLSrH43qXhO fc1uc5eSuVODURKDX0HpLJiWMp9/lpqY8/wIyj4gSjcDpq99T82GhXuHY68g/IaLwpUu 1OntThNQZrKYFiCPIDuSSNsbzl1s1XqueC7qm4zdj11nBBuMd95oLRJ57ZjUWRhUvNeQ 97rnoGjH6qSz5wsj2aD5ZCbn5ob53cpdjpejcF3P8g5oFO7Jk4Nb53MzxwT8Vw5HrTGt g//l2vF5/EjNx6dmcSph5FZN3JrcJ+2VtRIUNa2hOU7GSIpzWqeGxowPuQ8GHBWCt2aN +vDA== X-Gm-Message-State: AOAM530GfEo/Crf3i9+f1+1smKJGLCxkW3xtqFHsluyx6Fw1jytSif0x yrkH90ceneILzyIjXSAslOKVLRp0sZG9mw8L X-Google-Smtp-Source: ABdhPJwdCgsxug9YUjzFau4jYUseSIwKXdaQJcIaXbTq1VXtZhd0OLkyemNbpLUKejScUReUH86A/g== X-Received: by 2002:a65:5c4a:: with SMTP id v10mr7387878pgr.73.1620355822162; Thu, 06 May 2021 19:50:22 -0700 (PDT) Received: from bubble.grove.modra.org ([2406:3400:51d:8cc0:a19e:d7f4:3b6a:77ba]) by smtp.gmail.com with ESMTPSA id y14sm3278449pfm.123.2021.05.06.19.50.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 19:50:21 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: PowerPC64 ELFv1 -fpatchable-function-entry Date: Fri, 7 May 2021 12:19:50 +0930 Message-Id: <7d37f81086c8fdd5774ed28915812575f08d296f.1620345816.git.amodra@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-Spam-Status: No, score=-3038.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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: , X-Patchwork-Original-From: Alan Modra via Gcc-patches From: Alan Modra Reply-To: Alan Modra Cc: Jakub Jelinek , Segher Boessenkool Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" On PowerPC64 ELFv1 function symbols are defined on function descriptors in an .opd section rather than in the function code. .opd is not split up by the PowerPC64 backend for comdat groups or other situations where per-function sections are required. Thus SECTION_LINK_ORDER can't use the function name to reference a suitable section for ordering: The .opd section might contain many other function descriptors and they may be in a different order to the final function code placement. This patch arranges to use a code label instead of the function name symbol. I chose to emit the label inside default_elf_asm_named_section, immediately before the .section directive using the label, and in case someone uses .previous or the like, need to save and restore the current section when switching to the function code section to emit the label. That requires a tweak to switch_to_section in order to get the current section. I checked all the TARGET_ASM_NAMED_SECTION functions and unnamed.callback functions and it appears none will be affected by that tweak. PR target/98125 * varasm.c (default_elf_asm_named_section): Use a function code label rather than the function symbol as the "o" argument. (switch_to_section): Don't set in_section until section directive has been emitted. diff --git a/gcc/varasm.c b/gcc/varasm.c index 97c1e6fff25..5f95f8cfa75 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -6866,6 +6866,26 @@ default_elf_asm_named_section (const char *name, unsigned int flags, *f = '\0'; } + char func_label[256]; + if (flags & SECTION_LINK_ORDER) + { + static int recur; + if (recur) + gcc_unreachable (); + else + { + ++recur; + section *save_section = in_section; + static int func_code_labelno; + switch_to_section (function_section (decl)); + ++func_code_labelno; + ASM_GENERATE_INTERNAL_LABEL (func_label, "LPFC", func_code_labelno); + ASM_OUTPUT_LABEL (asm_out_file, func_label); + switch_to_section (save_section); + --recur; + } + } + fprintf (asm_out_file, "\t.section\t%s,\"%s\"", name, flagchars); /* default_section_type_flags (above) knows which flags need special @@ -6893,11 +6913,8 @@ default_elf_asm_named_section (const char *name, unsigned int flags, fprintf (asm_out_file, ",%d", flags & SECTION_ENTSIZE); if (flags & SECTION_LINK_ORDER) { - tree id = DECL_ASSEMBLER_NAME (decl); - ultimate_transparent_alias_target (&id); - const char *name = IDENTIFIER_POINTER (id); - name = targetm.strip_name_encoding (name); - fprintf (asm_out_file, ",%s", name); + fputc (',', asm_out_file); + assemble_name_raw (asm_out_file, func_label); } if (HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE)) { @@ -7821,11 +7838,6 @@ switch_to_section (section *new_section, tree decl) else if (in_section == new_section) return; - if (new_section->common.flags & SECTION_FORGET) - in_section = NULL; - else - in_section = new_section; - switch (SECTION_STYLE (new_section)) { case SECTION_NAMED: @@ -7843,6 +7855,11 @@ switch_to_section (section *new_section, tree decl) break; } + if (new_section->common.flags & SECTION_FORGET) + in_section = NULL; + else + in_section = new_section; + new_section->common.flags |= SECTION_DECLARED; }