From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3848 invoked by alias); 23 May 2011 18:39:39 -0000 Received: (qmail 3838 invoked by uid 22791); 23 May 2011 18:39:38 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_50,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-px0-f172.google.com (HELO mail-px0-f172.google.com) (209.85.212.172) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 May 2011 18:39:23 +0000 Received: by pxi6 with SMTP id 6so4637360pxi.17 for ; Mon, 23 May 2011 11:39:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.249.39 with SMTP id w39mr865519wfh.96.1306175962745; Mon, 23 May 2011 11:39:22 -0700 (PDT) Received: by 10.142.108.7 with HTTP; Mon, 23 May 2011 11:39:22 -0700 (PDT) In-Reply-To: References: Date: Mon, 23 May 2011 21:32:00 -0000 Message-ID: Subject: Re: [build] Fix Solaris 2/x86 GD/LD TLS code sequences with Sun ld From: Uros Bizjak To: Rainer Orth Cc: gcc-patches@gcc.gnu.org Content-Type: multipart/mixed; boundary=001636ed6a18460b1804a3f5ca3e Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg01678.txt.bz2 --001636ed6a18460b1804a3f5ca3e Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-length: 1995 On Mon, May 23, 2011 at 7:22 PM, Rainer Orth wrote: > As described in > > =A0 =A0 =A0 =A0[testsuite] Provide TLS access model testcases > =A0 =A0 =A0 =A0http://gcc.gnu.org/ml/gcc-patches/2011-05/msg01601.html > > both the 32 and 64-bit TLS GD and LD execution tests fail on Solaris 2 > with Sun ld unless you have a very recent Solaris 11 version (snv_164). > > This happens because the code sequences emitted by GCC don't match those > expected by Sun ld: > > =A0 =A0 =A0 =A032-bit x86: Thread-Local Variable Access > =A0 =A0 =A0 =A0http://download.oracle.com/docs/cd/E19963-01/html/819-0690= /chapter8-20.html#gentextid-20367 > > For GD, one needs to use call x@tlsgdplt here, but call ___tls_get_addr@p= lt > works, too. > > For LD, one really needs call x@tlsldmplt. > > The corresponding R_386_TLS_GD_PLT and R_386_TLS_LDM_PLT relocations are > not yet handled by binutils. > > =A0 =A0 =A0 =A0x64: Thread-Local Variable Access > =A0 =A0 =A0 =A0http://download.oracle.com/docs/cd/E19963-01/html/819-0690= /chapter8-20.html#chapter8-60 > > For both GD and LD, one needs to use call __tls_get_addr@plt. > > The following patch handles this: > > * It autoconfigures support for the @tlsgdplt and @tlsldmplt > =A0relocations: Sun as supports them, while gas doesn't yet. =A0I've got a > =A0patch in the works to fix this: while the gas part is easy, I have > =A0serious problems getting the ld side to work properly. =A0Unfortunatel= y, > =A0I doubt the binutils maintainers will accept such partial support for > =A0the relocs. > > * I'm using a new 'p' code to control the printing of @plt. =A0'P' doesn't > =A0work since this is needed in both PIC and non-PIC code. Since handling of "p" is not conditional (that is, controlled by some compile flag), it is IMO better to just output correct assembly from the insn pattern itself. You will also output lower-case "@plt" which is IIRC preferred by Sun assebler. Something like attached (untested) patch. Uros. --001636ed6a18460b1804a3f5ca3e Content-Type: text/plain; charset=US-ASCII; name="p.diff.txt" Content-Disposition: attachment; filename="p.diff.txt" Content-Transfer-Encoding: base64 X-Attachment-Id: f_go1re4jb0 Content-length: 1713 SW5kZXg6IGkzODYubWQKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gaTM4 Ni5tZAkocmV2aXNpb24gMTc0MDc2KQorKysgaTM4Ni5tZAkod29ya2luZyBj b3B5KQpAQCAtMTIzNjcsNiArMTIzNjcsMTIgQEAKIHsKICAgb3V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