From patchwork Thu May 10 13:27:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 911373 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-477493-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=CeBiTec.Uni-Bielefeld.DE Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="b3IqG4OY"; dkim-atps=neutral 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 40hYvC6Qvnz9s01 for ; Thu, 10 May 2018 23:28:07 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=BnJGLrWMfADkX3JnylWZD5m5VN4j9wmJ2ZqxWOvDVx2anW162My+x lC9iJLnLXApaWO9GvA0XZBDTYzLyJhBUWI4+gk9/cv4plve8rz9fZ0JbuiE6b5zB zP36MFbBM4N/cKTNEW3dE21uU0yeYJLnZDvmn7lpwivWj6Uv+NYTLw= 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:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=p53mgMlydVfDmOxN1GiHFnll2f8=; b=b3IqG4OYRrxZgs4rlyk3 t3ukmMFZ2bnAFe5XgKap9pOKqGSCQq+G8YX/7qb+ekIr2t4K34fy1IUpVnsrJ1UI +wREcqix2td5A8a4v7+KmRho83zEFhkLmijK35jVvyGOEdDc7261gM9Vfg/0jwTG Eqv0pAYWnN4XsdzSrlPopsk= Received: (qmail 110347 invoked by alias); 10 May 2018 13:28:00 -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 110328 invoked by uid 89); 10 May 2018 13:27:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-20.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=Biotechnology, biotechnology X-HELO: smtp.CeBiTec.Uni-Bielefeld.DE Received: from smtp.CeBiTec.Uni-Bielefeld.DE (HELO smtp.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 May 2018 13:27:52 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 2779E66 for ; Thu, 10 May 2018 15:27:48 +0200 (CEST) Received: from smtp.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id EQeHKglEZhwV for ; Thu, 10 May 2018 15:27:44 +0200 (CEST) Received: from manam.CeBiTec.Uni-Bielefeld.DE (p4FDDB419.dip0.t-ipconnect.de [79.221.180.25]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPSA id 5659D65 for ; Thu, 10 May 2018 15:27:44 +0200 (CEST) From: Rainer Orth To: gcc-patches@gcc.gnu.org Subject: [build] Support SHF_EXCLUDE on non-x86 and with Solaris as Date: Thu, 10 May 2018 15:27:43 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes Prompted by PR go/85429 (gotools unconditionally using gas syntax for setting SHF_EXCLUDE), I looked into what it takes to enable the flag (SECTION_EXCLUDE in gcc) on Solaris with /bin/as. Here's what I found: * Unlike most (all?) other section flags, the Solaris/x86 as doesn't accept the "e" flag for SHF_EXCLUDE, but needs #exclude instead, just as on SPARC. * Solaris/SPARC as does use #exclude to set the flag, completely in line with its section flag syntax. * I noticed that the configure check for the "e" section flag is currently only run on x86, although gas on ELF targets supports it everywhere. The following patch fixes all this. There's one point to note: running gcc_GAS_CHECK_FEATURE twice with the same cache variable for different syntaxes of some feature won't work: as currently happens for gcc_cv_as_shf_merge, when the first such test returns no, the second one isn't even run, using the cached no value instead. Bootstrapped without regressions on i386-pc-solaris2.1[01], sparc-sun-solaris2.1[01] (each with as and gas), and x86_64-pc-linux-gnu. Ok for mainline? Rainer # HG changeset patch # Parent 2c8ad65d830fdf48991fa8f278e5d0d896120b86 Support Solaris as SHF_EXCLUDE flag syntax diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -45240,6 +45240,15 @@ i386_solaris_elf_named_section (const ch solaris_elf_asm_comdat_section (name, flags, decl); return; } + + /* Solaris/x86 as uses the same syntax for the SHF_EXCLUDE flags as the + SPARC assembler. One cannot mix single-letter flags and #exclude, so + only emit the latter here. */ + if (flags & SECTION_EXCLUDE) + { + fprintf (asm_out_file, "\t.section\t%s,#exclude\n", name); + return; + } #endif default_elf_asm_named_section (name, flags, decl); diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -10502,6 +10502,10 @@ sparc_solaris_elf_asm_named_section (con if (!(flags & SECTION_DEBUG)) fputs (",#alloc", asm_out_file); +#if HAVE_GAS_SECTION_EXCLUDE + if (flags & SECTION_EXCLUDE) + fputs (",#exclude", asm_out_file); +#endif if (flags & SECTION_WRITE) fputs (",#write", asm_out_file); if (flags & SECTION_TLS) diff --git a/gcc/configure.ac b/gcc/configure.ac --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2953,6 +2953,34 @@ if test $gcc_cv_as_eh_frame = buggy; the [Define if your assembler mis-optimizes .eh_frame data.]) fi +# Test if the assembler supports the section flag 'e' or #exclude for +# specifying an excluded section. +gcc_GAS_CHECK_FEATURE([section exclude flag], gcc_cv_as_section_exclude_e, + [2,22,51], [--fatal-warnings], + [.section foo1,"e" + .byte 0,0,0,0]) +if test $gcc_cv_as_section_exclude_e = no; then + case "${target}" in + # Solaris as uses #exclude instead. + *-*-solaris2*) + case "${target}" in + sparc*-*-solaris2*) + conftest_s='.section "foo1", #exclude' + ;; + i?86-*-solaris2* | x86_64-*-solaris2*) + conftest_s='.section foo1, #exclude' + ;; + esac + ;; + esac + gcc_GAS_CHECK_FEATURE([section exclude flag], gcc_cv_as_section_exclude_hash,,, + [$conftest_s + .byte 0,0,0,0]) +fi +AC_DEFINE_UNQUOTED(HAVE_GAS_SECTION_EXCLUDE, + [`if test $gcc_cv_as_section_exclude_e = yes || test $gcc_cv_as_section_exclude_hash = yes; then echo 1; else echo 0; fi`], +[Define if your assembler supports specifying the exclude section flag.]) + gcc_GAS_CHECK_FEATURE(section merging support, gcc_cv_as_shf_merge, [elf,2,12,0], [--fatal-warnings], [.section .rodata.str, "aMS", @progbits, 1]) @@ -4202,16 +4230,6 @@ foo: nop [AC_DEFINE(HAVE_AS_XBRACE_COMMENT_OPTION, 1, [Define if your assembler supports -xbrace_comment option.])]) - # Test if the assembler supports the section flag 'e' for specifying - # an excluded section. - gcc_GAS_CHECK_FEATURE([.section with e], gcc_cv_as_section_has_e, - [2,22,51], [--fatal-warnings], -[.section foo1,"e" -.byte 0,0,0,0]) - AC_DEFINE_UNQUOTED(HAVE_GAS_SECTION_EXCLUDE, - [`if test $gcc_cv_as_section_has_e = yes; then echo 1; else echo 0; fi`], - [Define if your assembler supports specifying the section flag e.]) - gcc_GAS_CHECK_FEATURE([filds and fists mnemonics], gcc_cv_as_ix86_filds,,, [filds (%ebp); fists (%ebp)],, diff --git a/gcc/varasm.c b/gcc/varasm.c --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -6427,7 +6427,7 @@ default_elf_asm_named_section (const cha { if (!(flags & SECTION_DEBUG)) *f++ = 'a'; -#if defined (HAVE_GAS_SECTION_EXCLUDE) && HAVE_GAS_SECTION_EXCLUDE == 1 +#if HAVE_GAS_SECTION_EXCLUDE if (flags & SECTION_EXCLUDE) *f++ = 'e'; #endif