From patchwork Mon Oct 17 13:54:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Edelsohn X-Patchwork-Id: 682979 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3syKT804Pfz9s9c for ; Tue, 18 Oct 2016 00:54:51 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=rqrGqV0m; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=C211sIv3Q61bTTRSlB8+9n1tVoAG8xRJ5GLJZ+0gS1s67R ctBzNtSx63CuMkE/1prEokkqWsogHGJxpUGZtquUPuxikDBwoI0yIaB+yywwAbFi pWGvvnZKxuVL0m1EeS/gapj+HWNEeaILZV/KJVpQT+zkbcXZ/gVFvO+TlkEeg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=y3qBJOAVTP/vlFZTmFvOeze5hWI=; b=rqrGqV0mynuj+ZZtFpdf HksmBljLGLloYURwpwL2GIGXPFxJQENnlCZCtwG6nYcStHEOmF8iZHME8K+4nPN7 zKaK8nYP/B8Y1Q3k0Sj4YVTOjFn0fsNvWBQvTxnzOjO56Ohz+ygvzMSdWe+rmg7k a8oal+FEoUzF6ZuNCYym7cQ= Received: (qmail 115062 invoked by alias); 17 Oct 2016 13:54:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 115047 invoked by uid 89); 17 Oct 2016 13:54:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=Storage, xstr, XSTR, sk:RS6000_ X-HELO: mail-qk0-f170.google.com Received: from mail-qk0-f170.google.com (HELO mail-qk0-f170.google.com) (209.85.220.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 17 Oct 2016 13:54:37 +0000 Received: by mail-qk0-f170.google.com with SMTP id z190so235666076qkc.2 for ; Mon, 17 Oct 2016 06:54:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=gICKBEZjbTHUymO0h0rh/htRT1tbv3xpq2uj2pt14ls=; b=idRX4CyVTxUaBVgYPOvmADGrXU1pB8SqBfX+DMlScVFekdRZ1Lo6iZLwT3aSgXDOxm CP8Uus0YpIjwRnCSTU2ppeCGDLmvucPWsLF2aMI9z+uPlhXF2IrUWc8QV+dLwLTrOaJ/ sALLqJv/5d3z4Pgt3A9ss4o4/VZJXW5gcATJ+VTZUOklcyAjwBO/ohMJH+y+81UuthTn 6ohpjyhbjVta09m7EtWzYHc8iYckCw/qFw4iONxDaQ3uJmzxwPlDxJcmkjVWhhSMhiQW bTRQQUw2bPWnuOXhfimS9OA0cq8GbqSYYXYmGRTIjGtlI/ghQ9Y17OYfDvrkOCMzaWDB qmCw== X-Gm-Message-State: AA6/9RmGbFFNl5+QcWP0IHPhykResgs69ews9mCO98v0/RwUnRhIeLVtgbZSROqaH4jVhZtA+MUKoEIpWqGmwQ== X-Received: by 10.55.151.70 with SMTP id z67mr27599979qkd.185.1476712476223; Mon, 17 Oct 2016 06:54:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.131.225 with HTTP; Mon, 17 Oct 2016 06:54:35 -0700 (PDT) From: David Edelsohn Date: Mon, 17 Oct 2016 09:54:35 -0400 Message-ID: Subject: [PATCH] AIX symbol encoding To: Segher Boessenkool , GCC Patches This patch shifts earlier the point during compilation where the rs6000 backend adds decoration to symbols: to encode_section_info. AIX uses the XCOFF file format, which extends COFF in a few ways, including some increased granularity of sections through a mechanism called Storage Mapping Class -- a decoration for identifiers that maps to a COFF section. Because of the order in which GCC emits symbols and the behavior of the AIX Assembler, the AIX Assembler can see an early reference to an undeclared identifier and create a symbol in the wrong section. The rs6000 backend has been addressing this by emitting storage mapping class decorations on DECLs declared external in OUTPUT_SYMBOL_REF. The rs6000 port replaces the string so that future references also contain the mapping class. This string replacement conflicts with some hash tables so that the port emitted multiple references to the symbol. This patch changes the point at which the mapping class is added and the string is replaced to encode_section_info hook called by make_decl_rtl() and friends. The patch also moves the string management to the stringpool instead of malloc() called by concat(). Bootstrapped on powerpc-ibm-aix7.1.0.0. Thanks, David * config/rs6000/rs6000.c (rs6000_output_symbol_ref): Move storage mapping class decoration from here ... (rs6000_xcoff_encode_section): to here. Index: rs6000.c =================================================================== --- rs6000.c (revision 241237) +++ rs6000.c (working copy) @@ -30667,31 +30668,8 @@ rs6000_xcoff_strip_dollar (const char *name) void rs6000_output_symbol_ref (FILE *file, rtx x) { - /* Currently C++ toc references to vtables can be emitted before it - is decided whether the vtable is public or private. If this is - the case, then the linker will eventually complain that there is - a reference to an unknown section. Thus, for vtables only, - we emit the TOC reference to reference the symbol and not the - section. */ const char *name = XSTR (x, 0); - tree decl = SYMBOL_REF_DECL (x); - if (decl /* sync condition with assemble_external () */ - && DECL_P (decl) && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl) - && (TREE_CODE (decl) == VAR_DECL - || TREE_CODE (decl) == FUNCTION_DECL) - && name[strlen (name) - 1] != ']') - { - name = concat (name, - (TREE_CODE (decl) == FUNCTION_DECL - ? "[DS]" : "[UA]"), - NULL); - - /* Don't modify name in extern VAR_DECL to include mapping class. */ - if (TREE_CODE (decl) == FUNCTION_DECL) - XSTR (x, 0) = name; - } - if (VTABLE_NAME_P (name)) { RS6000_OUTPUT_BASENAME (file, name); @@ -35264,6 +35242,7 @@ rs6000_xcoff_encode_section_info (tree decl, rtx r { rtx symbol; int flags; + const char *symname; default_encode_section_info (decl, rtl, first); @@ -35280,6 +35259,28 @@ rs6000_xcoff_encode_section_info (tree decl, rtx r flags &= ~SYMBOL_FLAG_HAS_BLOCK_INFO; SYMBOL_REF_FLAGS (symbol) = flags; + + /* Currently C++ toc references to vtables can be emitted before it + is decided whether the vtable is public or private. If this is + the case, then the linker will eventually complain that there is + a reference to an unknown section. Thus, for vtables only, + we emit the TOC reference to reference the symbol and not the + label identifier. */ + symname = XSTR (symbol, 0); + + if (decl /* sync condition with assemble_external () */ + && DECL_P (decl) && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl) + && ((TREE_CODE (decl) == VAR_DECL && !DECL_THREAD_LOCAL_P (decl)) + || TREE_CODE (decl) == FUNCTION_DECL) + && symname[strlen (symname) - 1] != ']') + { + char *newname = (char *) alloca (strlen (symname) + 5); + strcpy (newname, symname); + strcat (newname, (TREE_CODE (decl) == FUNCTION_DECL + ? "[DS]" : "[UA]")); + XSTR (symbol, 0) = ggc_strdup (newname); + } + } #endif /* HAVE_AS_TLS */ #endif /* TARGET_XCOFF */