From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8378 invoked by alias); 2 Dec 2014 18:01:14 -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 8369 invoked by uid 89); 2 Dec 2014 18:01:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RCVD_IN_DNSWL_LOW,SPF_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mail-qc0-f179.google.com Received: from mail-qc0-f179.google.com (HELO mail-qc0-f179.google.com) (209.85.216.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 02 Dec 2014 18:01:12 +0000 Received: by mail-qc0-f179.google.com with SMTP id c9so9602730qcz.38 for ; Tue, 02 Dec 2014 10:01:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=5tbkbROPEczEhw+HfLOZZg5h2CWUIQgp+bAQU7CyUUE=; b=Iz12RZ7aXRNNcV5Lgs/DSwbpqnOqqKgBzm5EsL3NvsfjuV52wENIrGsjBXskzO3RS2 0X4t0OXuXkZPPv9SmUbxl/k/Ts3/sE4fdCRGkExpdZq+EOlZ8P3q7me77AhSO43vB/lY 6Lmeu9XHswkHkw9/CEUrI5RQRPeeTR75hbeWE5/B1PzxEm+LkHitC+okls+UWz6eS8ss vqbLQ375shVBaTJWTHe8CGszmV7deAPI2QVWOmTyjUU5YSDnSRlqinvqarFTgvmXzC6y HMIAt/Nrf8RYBOAvqJ934YjW6gpSitML0/ivPPs5xUbHJ7mkzcYoIsnEEs2KafrIudFF 2//w== X-Gm-Message-State: ALoCoQnVwxtKys+RP3H5glPjghvdESl7zkykwiyJfxEDmyHg+9EY88DdyLwRet+DOAjrL4Hv4J+D MIME-Version: 1.0 X-Received: by 10.140.34.78 with SMTP id k72mr651920qgk.21.1417543270141; Tue, 02 Dec 2014 10:01:10 -0800 (PST) Received: by 10.229.158.135 with HTTP; Tue, 2 Dec 2014 10:01:10 -0800 (PST) In-Reply-To: References: <54062B52.9040706@redhat.com> Date: Tue, 02 Dec 2014 18:01:00 -0000 Message-ID: Subject: Re: [PATCH x86_64] Optimize access to globals in "-fpie -pie" builds with copy relocations From: Sriraman Tallam To: Richard Henderson Cc: GCC Patches , David Li , Cary Coutant , Ian Lance Taylor , Paul Pluzhnikov Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-12/txt/msg00185.txt.bz2 Ping. On Mon, Nov 10, 2014 at 3:22 PM, Sriraman Tallam wrote: > Ping. > > On Mon, Oct 6, 2014 at 1:43 PM, Sriraman Tallam wrote: >> Ping. >> >> On Mon, Sep 29, 2014 at 10:57 AM, Sriraman Tallam wrote: >>> Ping. >>> >>> On Fri, Sep 19, 2014 at 2:11 PM, Sriraman Tallam wrote: >>>> Hi Richard, >>>> >>>> I also ran the gcc testsuite with >>>> RUNTESTFLAGS="--tool_opts=-mcopyrelocs" to check for issues. The only >>>> test that failed was g++.dg/tsan/default_options.C. It uses -fpie >>>> -pie and BFD ld to link. Since BFD ld does not support copy >>>> relocations with -pie, it does not link. I linked with gold to make >>>> the test pass. >>>> >>>> Could you please take another look at this patch? >>>> >>>> Thanks >>>> Sri >>>> >>>> On Mon, Sep 8, 2014 at 3:19 PM, Sriraman Tallam wrote: >>>>> On Tue, Sep 2, 2014 at 1:40 PM, Richard Henderson wrote: >>>>>> On 06/20/2014 05:17 PM, Sriraman Tallam wrote: >>>>>>> Index: config/i386/i386.c >>>>>>> =================================================================== >>>>>>> --- config/i386/i386.c (revision 211826) >>>>>>> +++ config/i386/i386.c (working copy) >>>>>>> @@ -12691,7 +12691,9 @@ legitimate_pic_address_disp_p (rtx disp) >>>>>>> return true; >>>>>>> } >>>>>>> else if (!SYMBOL_REF_FAR_ADDR_P (op0) >>>>>>> - && SYMBOL_REF_LOCAL_P (op0) >>>>>>> + && (SYMBOL_REF_LOCAL_P (op0) >>>>>>> + || (TARGET_64BIT && ix86_copyrelocs && flag_pie >>>>>>> + && !SYMBOL_REF_FUNCTION_P (op0))) >>>>>>> && ix86_cmodel != CM_LARGE_PIC) >>>>>>> return true; >>>>>>> break; >>>>>> >>>>>> This is the wrong place to patch. >>>>>> >>>>>> You ought to be adjusting SYMBOL_REF_LOCAL_P, by providing a modified >>>>>> TARGET_BINDS_LOCAL_P. >>>>> >>>>> I have done this in the new attached patch, I added a new function >>>>> i386_binds_local_p which will check for this and call >>>>> default_binds_local_p otherwise. >>>>> >>>>>> >>>>>> Note in particular that I believe that you are doing the wrong thing with weak >>>>>> and COMMON symbols, in that you probably ought not force a copy reloc there. >>>>> >>>>> I added an extra check to not do this for WEAK symbols. I also added a >>>>> check for DECL_EXTERNAL so I believe this will also not be called for >>>>> COMMON symbols. >>>>> >>>>>> >>>>>> Note the complexity of default_binds_local_p_1, and the fact that all you >>>>>> really want to modify is >>>>>> >>>>>> /* If PIC, then assume that any global name can be overridden by >>>>>> symbols resolved from other modules. */ >>>>>> else if (shlib) >>>>>> local_p = false; >>>>>> >>>>>> near the bottom of that function. >>>>> >>>>> I did not understand what you mean here? Were you suggesting an >>>>> alternative way of doing this? >>>>> >>>>> Thanks for reviewing >>>>> Sri >>>>> >>>>>> >>>>>> >>>>>> r~