From patchwork Tue May 4 17:45:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Edelsohn X-Patchwork-Id: 1473948 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=yGK10gU8; 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 4FZS2351DYz9sPf for ; Wed, 5 May 2021 03:46:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 35AA73969014; Tue, 4 May 2021 17:46:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 35AA73969014 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1620150376; bh=hTNppfDP7WgpkSfD2WwURyJXJe0lmQmc+vtI9eF6YF4=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=yGK10gU89lNdjVfjukQqxYsfx2s9CMPSiLJ4vXokBOKOuPTR+FypxCR2s5Zfql9uj r8r4PIX//F6DEDJPf/vJYqzB5a96Kdghij2+w3kd40t/1Z6FJvFMrhXTWu6ntiX7Qd TBB3QLm+49Jx8VygZmIJnG9qZ8YhrfV+UqnmmRlk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id A37BB3955401 for ; Tue, 4 May 2021 17:46:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A37BB3955401 Received: by mail-lj1-x22f.google.com with SMTP id w4so3546064ljw.9 for ; Tue, 04 May 2021 10:46:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=hTNppfDP7WgpkSfD2WwURyJXJe0lmQmc+vtI9eF6YF4=; b=BedB3lWw8GUpNTxxBqyAF5b4soEcOSHC2noEL6uesiM8m1WEtO7iR+F/3sCHC1hLd1 ZBeTRw/fUOgTi+mYMe84bZKTC2Jn5I6NqTMUdm6OMp7NFrHdICu0XfR2I/lOHSAcJU9m pjX1wEwiLU1dk7SL2lyF/QRlxpcrHbtPMkt3FXReYw1KfvEMydl+CL3qpX/Kfx4g6mWJ HAGvCFLDl8JyPW0JfGTa3YgGITNUFR4fxoQlITW6dh0fGjzWwhb3mK+5hp+96ZCLC6yd h8+Bc6z8Jz0OBrzBnpFjpcjnYlz9VIG3n23V9Nx8yxANkIwF9xrdDOnevMaqKFVhh7ZJ YNvw== X-Gm-Message-State: AOAM530bKv+ZjDXZPsmuhKKUUoHqqrHVvMrom1XAbDeBU4oPp7vog3YJ UStQWmXFHYx/DO22FGK2WMoNZzGydfM8R9fdBV1UtJaZgSI= X-Google-Smtp-Source: ABdhPJymUtiWZESaCgibZWx3rh2zKAj8miTxwCiWOqxsHknCJLr8kFZqHmESGYLyrVSibR6wg3T1QIl0VsXhQU+UK6E= X-Received: by 2002:a2e:7212:: with SMTP id n18mr18484928ljc.378.1620150370835; Tue, 04 May 2021 10:46:10 -0700 (PDT) MIME-Version: 1.0 Date: Tue, 4 May 2021 13:45:59 -0400 Message-ID: Subject: [PATCH] AIX Encode function section and rs6000 MI Thunk To: GCC Patches , Segher Boessenkool X-Spam-Status: No, score=-8.1 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: David Edelsohn via Gcc-patches From: David Edelsohn Reply-To: David Edelsohn Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" AIX XCOFF symbols can be labels or qualnames (names with an appended mapping class). CSECTs must be declared with a mapping class. Within an assembler file, the symbol names with and without the mapping class are unique. An object file symbol table only presents the symbol name without the mapping class, but the section of the symbol depends on the mapping class. The AIX XCOFF assembly language does not support first class aliases. GCC implements symbol aliases by emitting additional labels for the function or object. When GCC encodes sections for a DECL, it must distinguish between the primary definition and the aliases, which don't have a mapping class encoding. .globl foo[DS] .globl .foo .globl foo1 .globl .foo1 .csect foo[DS] foo: foo1: .long .foo, TOC[tc0] 0 .csect .foo[PR] .foo: .foo1: The CSECT foo[DS] and label foo are distinct. foo1 is another label (alias) for foo, and .foo1 is another label (alias) for .foo. foo is the function descriptor and .foo is the code. This patch adds the [DS] mapping class to the encoding of FUNCTION_DECL but ensures that mapping class is not added to function aliases. rs6000_output_mi_thunk is updated to emit the function name that matches the behavior of GCC final.c for normal functions: get_fnname_from_decl based on the RTL name, not the DECL name. Bootstrapped on powerpc-ibm-aix7.2.3.0 and powerpc64le-linux. * config/rs6000/rs6000-call.c (rs6000_output_mi_thunk): Use get_fnname_from_decl for name of thunk. * config/rs6000/rs6000.c (rs6000_declare_alias): Use assemble_name and ASM_OUTPUT_LABEL. (rs6000_xcoff_declare_function_name): Use assemble_name and ASM_OUTPUT_LABEL. (rs6000_xcoff_declare_object_name): Use ASM_OUTPUT_LABEL. (rs6000_xcoff_encode_section_info): Don't add mapping class for aliases. Always add [DS] mapping class to primary FUNCTION_DECL. (rs6000_asm_weaken_decl): Don't explicitly add [DS]. @@ -21574,21 +21573,24 @@ rs6000_xcoff_declare_function_name (FILE *file, const char *name, tree decl) RS6000_OUTPUT_BASENAME (file, buffer); putc ('\n', file); } + fputs ("\t.csect ", file); - RS6000_OUTPUT_BASENAME (file, buffer); - fputs (TARGET_32BIT ? "[DS]\n" : "[DS],3\n", file); - RS6000_OUTPUT_BASENAME (file, buffer); - fputs (":\n", file); + assemble_name (file, buffer); + fputs (TARGET_32BIT ? "\n" : ",3\n", file); + + ASM_OUTPUT_LABEL (file, buffer); + symtab_node::get (decl)->call_for_symbol_and_aliases (rs6000_declare_alias, &data, true); fputs (TARGET_32BIT ? "\t.long ." : "\t.llong .", file); RS6000_OUTPUT_BASENAME (file, buffer); fputs (", TOC[tc0], 0\n", file); + in_section = NULL; switch_to_section (function_section (decl)); putc ('.', file); - RS6000_OUTPUT_BASENAME (file, buffer); - fputs (":\n", file); + ASM_OUTPUT_LABEL (file, buffer); + data.function_descriptor = true; symtab_node::get (decl)->call_for_symbol_and_aliases (rs6000_declare_alias, &data, true); @@ -21683,8 +21685,7 @@ void rs6000_xcoff_declare_object_name (FILE *file, const char *name, tree decl) { struct declare_alias_data data = {file, false}; - RS6000_OUTPUT_BASENAME (file, name); - fputs (":\n", file); + ASM_OUTPUT_LABEL (file, name); symtab_node::get_create (decl)->call_for_symbol_and_aliases (rs6000_declare_alias, &data, true); } @@ -21740,20 +21741,19 @@ rs6000_xcoff_encode_section_info (tree decl, rtx rtl, int first) symname = XSTR (symbol, 0); - /* Append CSECT mapping class, unless the symbol already is qualified. */ + /* Append CSECT mapping class, unless the symbol already is qualified. + Aliases are implemented as labels, so the symbol name should not add + a mapping class. */ if (decl && DECL_P (decl) && VAR_OR_FUNCTION_DECL_P (decl) - && lookup_attribute ("alias", DECL_ATTRIBUTES (decl)) == NULL_TREE + && symtab_node::get (decl)->alias == 0 && symname[strlen (symname) - 1] != ']') { const char *smclass = NULL; if (TREE_CODE (decl) == FUNCTION_DECL) - { - if (DECL_EXTERNAL (decl)) - smclass = "[DS]"; - } + smclass = "[DS]"; else if (DECL_THREAD_LOCAL_P (decl)) { if (bss_initializer_p (decl)) @@ -21796,8 +21796,6 @@ rs6000_asm_weaken_decl (FILE *stream, tree decl, if (decl && TREE_CODE (decl) == FUNCTION_DECL && DEFAULT_ABI == ABI_AIX && DOT_SYMBOLS) { - if (TARGET_XCOFF && name[strlen (name) - 1] != ']') - fputs ("[DS]", stream); #if TARGET_XCOFF && HAVE_GAS_HIDDEN if (TARGET_XCOFF) fputs (rs6000_xcoff_visibility (decl), stream); @@ -21810,6 +21808,7 @@ rs6000_asm_weaken_decl (FILE *stream, tree decl, fputs (rs6000_xcoff_visibility (decl), stream); #endif fputc ('\n', stream); + if (val) { #ifdef ASM_OUTPUT_DEF diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c index 6f6dc47f0ae..c4332a61862 100644 --- a/gcc/config/rs6000/rs6000-call.c +++ b/gcc/config/rs6000/rs6000-call.c @@ -15077,7 +15077,7 @@ rs6000_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED, HOST_WIDE_INT delta, HOST_WIDE_INT vcall_offset, tree function) { - const char *fnname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (thunk_fndecl)); + const char *fnname = get_fnname_from_decl (thunk_fndecl); rtx this_rtx, funexp; rtx_insn *insn; diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 0e9cf178245..ee15af9efa4 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -21468,7 +21468,7 @@ rs6000_declare_alias (struct symtab_node *n, void *d) putc ('\n', data->file); } fputs ("\t.globl ", data->file); - RS6000_OUTPUT_BASENAME (data->file, buffer); + assemble_name (data->file, buffer); putc ('\n', data->file); } #ifdef ASM_WEAKEN_DECL @@ -21491,13 +21491,12 @@ rs6000_declare_alias (struct symtab_node *n, void *d) putc ('\n', data->file); } fputs ("\t.lglobl ", data->file); - RS6000_OUTPUT_BASENAME (data->file, buffer); + assemble_name (data->file, buffer); putc ('\n', data->file); } if (data->function_descriptor) - fputs (".", data->file); - RS6000_OUTPUT_BASENAME (data->file, buffer); - fputs (":\n", data->file); + putc ('.', data->file); + ASM_OUTPUT_LABEL (data->file, buffer); return false; }