From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18911 invoked by alias); 16 May 2015 19:00:00 -0000 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 Received: (qmail 18898 invoked by uid 89); 16 May 2015 18:59:59 -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,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f180.google.com Received: from mail-ob0-f180.google.com (HELO mail-ob0-f180.google.com) (209.85.214.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sat, 16 May 2015 18:59:58 +0000 Received: by obfe9 with SMTP id e9so98906963obf.1 for ; Sat, 16 May 2015 11:59:56 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.202.106.197 with SMTP id f188mr12876950oic.128.1431802796731; Sat, 16 May 2015 11:59:56 -0700 (PDT) Received: by 10.76.160.68 with HTTP; Sat, 16 May 2015 11:59:56 -0700 (PDT) In-Reply-To: References: <20150515194824.GB14415@kam.mff.cuni.cz> <20150515202319.GE17573@brightrain.aerifal.cx> <20150515204237.GF17573@brightrain.aerifal.cx> <20150515230810.GA73210@kam.mff.cuni.cz> <20150515234900.GH17573@brightrain.aerifal.cx> Date: Sat, 16 May 2015 19:03:00 -0000 Message-ID: Subject: Re: [PATCH i386] Allow sibcalls in no-PLT PIC From: "H.J. Lu" To: Rich Felker Cc: Jan Hubicka , Alexander Monakov , GCC Patches , Uros Bizjak Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-05/txt/msg01496.txt.bz2 On Sat, May 16, 2015 at 7:19 AM, H.J. Lu wrote: > On Fri, May 15, 2015 at 4:49 PM, Rich Felker wrote: >> On Fri, May 15, 2015 at 04:34:57PM -0700, H.J. Lu wrote: >>> On Fri, May 15, 2015 at 4:30 PM, H.J. Lu wrote: >>> > On Fri, May 15, 2015 at 4:14 PM, H.J. Lu wrote: >>> >> My relax branch proposal works even without LTO. >>> >> >>> > >>> > I will borrow GOTPCREL from x86-64 and do >>> > >>> > [hjl@gnu-6 relax-4]$ cat b.S >>> > call *foo@GOTPCREL(%eax) >>> >>> call *foo@GOTPLT(%eax) >>> >>> is a better choice. >> >> foo@GOTPCREL is preferable (but does not yet exist for ia32, so the >> reloc type would have to be added) since it saves a useless add. >> Instead of: >> >> call __x86.get_pc_thunk.ax >> addl $_GLOBAL_OFFSET_TABLE_, %eax >> call *foo@GOTPLT(%eax) >> >> you can just do: >> >> call __x86.get_pc_thunk.ax >> call *foo@GOTPCREL(%eax) >> >> Note that it also works to have extra instructions between: >> >> call __x86.get_pc_thunk.ax >> 1: ... >> call *foo@GOTPCREL+(1b-.)(%eax) >> >> I may not have gotten the syntax quite right, but hopefully yoy get >> the idea. This same approach (with GOTPCREL) can be used for _all_ GOT >> accesses, including global data, to eliminate the useless add. >> > > This is a good idea. But I'd like to use something for both i386 and > x86-64. I am proposing > > call/jmp *foo@GOTPCRELAX+addend(%reg) > > It is similar to @GOTPCREL, but with a new relax relocation. Before > I can do that, I need to fix It doesn't work. REG must hold GOT base for other GOT relocations. We need to keep addl $_GLOBAL_OFFSET_TABLE_, %eax -- H.J.