From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7915 invoked by alias); 13 Nov 2013 09:49:59 -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 7902 invoked by uid 89); 13 Nov 2013 09:49:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.9 required=5.0 tests=AWL,BAYES_99,KAM_STOCKGEN,RDNS_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: service87.mimecast.com Received: from Unknown (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Nov 2013 09:49:30 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 13 Nov 2013 09:49:21 +0000 Received: from [10.1.208.33] ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 13 Nov 2013 09:49:21 +0000 Message-ID: <52834B21.5080305@arm.com> Date: Wed, 13 Nov 2013 10:52:00 -0000 From: Richard Earnshaw User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-Version: 1.0 To: Joey Ye CC: "gcc-patches@gcc.gnu.org" Subject: Re: [patch] [arm] New option for PIC offset unfixed References: <000001cedf74$bd1bf710$3753e530$@arm.com> <528207A5.9070702@arm.com> <000001cee038$2a027e80$7e077b80$@arm.com> In-Reply-To: <000001cee038$2a027e80$7e077b80$@arm.com> X-MC-Unique: 113111309492102301 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg01419.txt.bz2 On 13/11/13 06:18, Joey Ye wrote: >> -----Original Message----- >> From: Richard Earnshaw >> Sent: Tuesday, November 12, 2013 18:49 >> To: Joey Ye >> Cc: gcc-patches@gcc.gnu.org >> Subject: Re: [patch] [arm] New option for PIC offset unfixed >> >> The name of the option and the documentation highlights that the >> option's concept is confusing. >> >> I think what you really need to do is to reverse the sense of the option >> name and have >> >> -mpic-data-is-text-relative >> >> with the inverse (-mno-pic-data-is-text-relative) being the active value >> that triggers for vxworks. That is, PIC data being text-relative is the >> default for all targets except vxworks. >> >> R. >> >> Oh, and at run time, we should be talking about segments, not sections! > Richard, Thanks for quick response. >=20 > Updated patch renamed the option, variables and macro. Also use segments = in > document. OK? >=20 > 2013-11-13 Joey Ye >=20 > * config/arm/arm.c (arm_option_override): Error if > -mpic-data-is-text-relative without -fpic, and set for > VxWorks RTP. > (legitimize_pic_address): Use arm_pic_data_is_text_relative > (arm_assemble_integer): Likewise. > * config/arm/arm.h > (TARGET_DEFAULT_PIC_DATA_IS_TEXT_RELATIVE): New macro. > * config/arm/arm.opt (mpic-data-is-text-relative): New option. > * doc/invoke.texi (-mpic-data-is-text-relative): Doc for new option. >=20 >=20 > pic_data_text_rel-1113.patch.txt >=20 >=20 > diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c > index 7757e86..fdd5684 100644 > --- a/gcc/config/arm/arm.c > +++ b/gcc/config/arm/arm.c > @@ -2504,6 +2504,13 @@ arm_option_override (void) > arm_pic_register =3D pic_register; > } >=20=20 > + if (TARGET_VXWORKS_RTP) > + arm_pic_data_is_text_relative =3D 0; Why is this needed? Surely, even a VxWorks user should have the right to force the compiler to behave differently. You've set things up through the default, now just accept what the user has asked for. > + > + if (arm_pic_data_is_text_relative !=3D TARGET_DEFAULT_PIC_DATA_IS_TEXT= _RELATIVE > + && !flag_pic) > + error ("-mpic-data-is-text-relative must be used with -fpic"); I'm not sure about this either. The option should just be ignored when not PIC. > + > /* Enable -mfix-cortex-m3-ldrd by default for Cortex-M3 cores. */ > if (fix_cm3_ldrd =3D=3D 2) > { > @@ -6020,7 +6027,7 @@ legitimize_pic_address (rtx orig, enum machine_mode= mode, rtx reg) > || (GET_CODE (orig) =3D=3D SYMBOL_REF && > SYMBOL_REF_LOCAL_P (orig))) > && NEED_GOT_RELOC > - && !TARGET_VXWORKS_RTP) > + && arm_pic_data_is_text_relative) > insn =3D arm_pic_static_addr (orig, reg); > else > { > @@ -21498,7 +21505,7 @@ arm_assemble_integer (rtx x, unsigned int size, i= nt aligned_p) > { > /* See legitimize_pic_address for an explanation of the > TARGET_VXWORKS_RTP check. */ > - if (TARGET_VXWORKS_RTP > + if (!arm_pic_data_is_text_relative > || (GET_CODE (x) =3D=3D SYMBOL_REF && !SYMBOL_REF_LOCAL_P (x))) > fputs ("(GOT)", asm_out_file); > else > diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h > index 1781b75..dbd841e 100644 > --- a/gcc/config/arm/arm.h > +++ b/gcc/config/arm/arm.h > @@ -568,6 +568,10 @@ extern int prefer_neon_for_64bits; > #define NEED_PLT_RELOC 0 > #endif >=20=20 > +#ifndef TARGET_DEFAULT_PIC_DATA_IS_TEXT_RELATIVE > +#define TARGET_DEFAULT_PIC_DATA_IS_TEXT_RELATIVE 1 > +#endif > + > /* Nonzero if we need to refer to the GOT with a PC-relative > offset. In other words, generate >=20=20 > diff --git a/gcc/config/arm/arm.opt b/gcc/config/arm/arm.opt > index 9b74038..fa0839a 100644 > --- a/gcc/config/arm/arm.opt > +++ b/gcc/config/arm/arm.opt > @@ -158,6 +158,10 @@ mlong-calls > Target Report Mask(LONG_CALLS) > Generate call insns as indirect calls, if necessary >=20=20 > +mpic-data-is-text-relative > +Target Report Var(arm_pic_data_is_text_relative) Init(TARGET_DEFAULT_PIC= _DATA_IS_TEXT_RELATIVE) > +Assume data segments are relative to text segment. ^ Assume data segment will be loaded at a fixed relative offset to the text segment. > + > mpic-register=3D > Target RejectNegative Joined Var(arm_pic_register_string) > Specify the register to be used for PIC addressing > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index 863e518..298fcc3 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -12120,6 +12120,12 @@ before execution begins. > Specify the register to be used for PIC addressing. The default is R10 > unless stack-checking is enabled, when R9 is used. >=20=20 > +@item -mpic-data-is-text-relative > +@opindex mpic-data-is-text-relative > +Assume that each data segments are relative to text segment at load time. > +Therefore, prevent PC relative and GOTOFF style relocations to reference > +data.=20=20 I think the sense of this sentence is now backwards. I'd also try to avoid GOTOFF in the user part of the manual. > This is on by default for targets other than VxWorks RTP. > + > @item -mpoke-function-name > @opindex mpoke-function-name > Write the name of each function into the text section, directly >=20 R.