From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108181 invoked by alias); 19 Oct 2015 09:28:30 -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 108168 invoked by uid 89); 19 Oct 2015 09:28:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 19 Oct 2015 09:28:28 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-12-7qfln6S2RcKGTbRAdy2GcA-1; Mon, 19 Oct 2015 10:28:19 +0100 Received: from [10.2.206.40] ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 19 Oct 2015 10:28:19 +0100 Message-ID: <5624B7B3.6020005@arm.com> Date: Mon, 19 Oct 2015 10:12:00 -0000 From: Szabolcs Nagy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Andreas Krebbel , Bernd Schmidt , Jakub Jelinek , Richard Henderson Subject: Re: [PATCH] Fix default_binds_local_p_2 for extern protected data References: <55AFCC7C.8010105@arm.com> <55C8854D.5060609@arm.com> <55FA84C1.6010603@arm.com> <560BE7F9.1010708@redhat.com> <560C0BEC.6010508@arm.com> <560C36B7.3050306@linux.vnet.ibm.com> <561E26A8.5030800@arm.com> In-Reply-To: <561E26A8.5030800@arm.com> X-MC-Unique: 7qfln6S2RcKGTbRAdy2GcA-1 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-10/txt/msg01711.txt.bz2 On 14/10/15 10:55, Szabolcs Nagy wrote: > On 30/09/15 20:23, Andreas Krebbel wrote: >> On 09/30/2015 06:21 PM, Szabolcs Nagy wrote: >>> On 30/09/15 14:47, Bernd Schmidt wrote: >>>> On 09/17/2015 11:15 AM, Szabolcs Nagy wrote: >>>>> ping 2. >>>>> >>>>> this patch is needed for working visibility ("protected") >>>>> attribute for extern data on targets using default_binds_local_p_2. >>>>> https://gcc.gnu.org/ml/gcc-patches/2015-07/msg01871.html >>>> >>>> I hesitate to review this one since I don't think I understand the >>>> issues on the various affected arches well enough. It looks like Jakub >>>> had some input on the earlier changes, maybe he could take a look? Or >>>> maybe rth knows best. Adding Ccs. >>>> >>>> It would help to have examples of code generation demonstrating the >>>> problem and how you would solve it. Input from the s390 maintainers >>>> whether this is correct for their port would also be appreciated. >> >> We are having the same problem on S/390. I think the GCC change is corre= ct for S/390 as well. >> >> -Andreas- >> > > i think the approvals of arm and aarch64 maintainers > are needed to apply this fix for pr target/66912. > > (only s390, arm and aarch64 use this predicate.) > i was told this needs global maintainer approval. adding jakub and rth back to cc. >>>> >>> >>> consider the TU >>> >>> __attribute__((visibility("protected"))) int n; >>> >>> int f () { return n; } >>> >>> if n "binds_local" then gcc -O -fpic -S is like >>> >>> .text >>> .align 2 >>> .global f >>> .arch armv8-a+fp+simd >>> .type f, %function >>> f: >>> adrp x0, n >>> ldr w0, [x0, #:lo12:n] >>> ret >>> .size f, .-f >>> .protected n >>> .comm n,4,4 >>> >>> so 'n' is a direct reference, not accessed through >>> the GOT ('n' will be in the .bss of the dso). >>> this is the current behavior. >>> >>> if i remove the protected visibility attribute >>> then the access goes through GOT: >>> >>> .text >>> .align 2 >>> .global f >>> .arch armv8-a+fp+simd >>> .type f, %function >>> f: >>> adrp x0, _GLOBAL_OFFSET_TABLE_ >>> ldr x0, [x0, #:gotpage_lo15:n] >>> ldr w0, [x0] >>> ret >>> .size f, .-f >>> .comm n,4,4 >>> >>> protected visibility means the definition cannot >>> be overridden by another module, but it should >>> still allow extern references. >>> >>> if the main module references such an object then >>> (as an implementation detail) it may use copy >>> relocation against it, which places 'n' in the >>> main module and the dynamic linker should make >>> sure that references to 'n' point there. >>> >>> this is only possible if references to 'n' go >>> through the GOT (i.e. it should not be "binds_local"). >> >> >> >> >> >