From patchwork Thu Jan 6 18:49:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 77783 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]) by ozlabs.org (Postfix) with SMTP id 7F275B7043 for ; Fri, 7 Jan 2011 05:49:35 +1100 (EST) Received: (qmail 18219 invoked by alias); 6 Jan 2011 18:49:34 -0000 Received: (qmail 18211 invoked by uid 22791); 6 Jan 2011 18:49:33 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, TW_ZJ, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 06 Jan 2011 18:49:28 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 2A36761A; Thu, 6 Jan 2011 19:49:26 +0100 (CET) Received: from smtp-relay.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 8ZiAhcsFZgGe; Thu, 6 Jan 2011 19:49:23 +0100 (CET) Received: from manam.CeBiTec.Uni-Bielefeld.DE (manam.CeBiTec.Uni-Bielefeld.DE [129.70.161.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id 78559614; Thu, 6 Jan 2011 19:49:23 +0100 (CET) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.4+Sun/8.14.4/Submit) id p06InMP6018987; Thu, 6 Jan 2011 19:49:22 +0100 (MET) From: Rainer Orth To: Uros Bizjak Cc: Richard Henderson , gcc-patches@gcc.gnu.org Subject: Re: Fix 64-bit Solaris 2/x86 IE TLS code sequence (PR target/43309) References: <4D0FC4B3.6040107@redhat.com> <4D10D81B.8010104@redhat.com> Date: Thu, 06 Jan 2011 19:49:22 +0100 In-Reply-To: (Uros Bizjak's message of "Sat, 25 Dec 2010 19:48:09 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes 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 Uros Bizjak writes: > Attached variant of your original patch works for me - I have > bootstrapped and regression test the patch on x86_64-pc-linux-gnu. Thanks. I've successfully bootstrapped the following version (changing SUN to Sun; while Sun started as an acronym ages ago, it has long been a name) on i386-pc-solaris2.1[01] with Sun as and gas. Ok for mainline now and the obvious backport (replacing define_c_enum with define_constants) for the 4.4 and 4.5 branches after testing? Thanks for all your help with this. There's more coming, though: the testcase exercising all TLS models you sent me when I started investigating this bug still fails for TLS GD and LD (32 and 64-bit with Sun ld), but this isn't currently exercised anywhere else in the GCC testsuite. I've a preliminary patch to address this, which works with Sun as and Sun ld, but requires gas support for the R_386_TLS_LDM_PLT reloc which I'm still fighting with. I'll address this in a separate thread when I get to it, though. Rainer 2010-03-06 Uros Bizjak Rainer Orth gcc: PR target/43309 * config/i386/i386.c (legitimize_tls_address) : Handle TARGET_64BIT && TARGET_SUN_TLS. * config/i386/i386.md (UNSPEC_TLS_IE_SUN): Declare. (tls_initial_exec_64_sun): New pattern. diff -r 91ae5b1efcf5 gcc/config/i386/i386.c --- a/gcc/config/i386/i386.c Wed Jan 05 14:19:38 2011 +0100 +++ b/gcc/config/i386/i386.c Wed Jan 05 14:27:56 2011 +0100 @@ -12542,6 +12542,17 @@ case TLS_MODEL_INITIAL_EXEC: if (TARGET_64BIT) { + if (TARGET_SUN_TLS) + { + /* The Sun linker took the AMD64 TLS spec literally + and can only handle %rax as destination of the + initial executable code sequence. */ + + dest = gen_reg_rtx (Pmode); + emit_insn (gen_tls_initial_exec_64_sun (dest, x)); + return dest; + } + pic = NULL; type = UNSPEC_GOTNTPOFF; } diff -r 91ae5b1efcf5 gcc/config/i386/i386.md --- a/gcc/config/i386/i386.md Wed Jan 05 14:19:38 2011 +0100 +++ b/gcc/config/i386/i386.md Wed Jan 05 14:27:56 2011 +0100 @@ -93,6 +93,7 @@ UNSPEC_TLS_GD UNSPEC_TLS_LD_BASE UNSPEC_TLSDESC + UNSPEC_TLS_IE_SUN ;; Other random patterns UNSPEC_SCAS @@ -12686,6 +12687,18 @@ (set_attr "memory" "load") (set_attr "imm_disp" "false")]) +;; The Sun linker took the AMD64 TLS spec literally and can only handle +;; %rax as destination of the initial executable code sequence. +(define_insn "tls_initial_exec_64_sun" + [(set (match_operand:DI 0 "register_operand" "=a") + (unspec:DI + [(match_operand:DI 1 "tls_symbolic_operand" "")] + UNSPEC_TLS_IE_SUN)) + (clobber (reg:CC FLAGS_REG))] + "TARGET_64BIT && TARGET_SUN_TLS" + "mov{q}\t{%%fs:0, %0|%0, QWORD PTR fs:0}\n\tadd{q}\t{%a1@gottpoff(%%rip), %0|%0, %a1@gottpoff[rip]}" + [(set_attr "type" "multi")]) + ;; GNU2 TLS patterns can be split. (define_expand "tls_dynamic_gnu2_32"