From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 85095 invoked by alias); 30 Aug 2019 08:06:53 -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 85087 invoked by uid 89); 30 Aug 2019 08:06:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 30 Aug 2019 08:06:52 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8E53B344; Fri, 30 Aug 2019 01:06:50 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.99.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 14C7F3F718; Fri, 30 Aug 2019 01:06:49 -0700 (PDT) From: Richard Sandiford To: Christophe Lyon Mail-Followup-To: Christophe Lyon ,, richard.sandiford@arm.com Cc: Subject: Re: [ARM/FDPIC v5 05/21] [ARM] FDPIC: Fix __do_global_dtors_aux and frame_dummy generation References: <20190515124006.25840-1-christophe.lyon@st.com> <20190515124006.25840-6-christophe.lyon@st.com> <64380f14-d2bd-a3c4-4cae-ba1cb21bad1d@st.com> Date: Fri, 30 Aug 2019 08:41:00 -0000 In-Reply-To: <64380f14-d2bd-a3c4-4cae-ba1cb21bad1d@st.com> (Christophe Lyon's message of "Thu, 29 Aug 2019 17:35:02 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg02042.txt.bz2 Christophe Lyon writes: > On 12/07/2019 08:06, Richard Sandiford wrote: >> Christophe Lyon writes: >>> In FDPIC, we need to make sure __do_global_dtors_aux and frame_dummy >>> are referenced by their address, not by pointers to the function >>> descriptors. >>> >>> 2019-XX-XX Christophe Lyon >>> Mickaël Guêné >>> >>> * libgcc/crtstuff.c: Add support for FDPIC. >>> >>> Change-Id: I0bc4b1232fbf3c69068fb23a1b9cafc895d141b1 >>> >>> diff --git a/libgcc/crtstuff.c b/libgcc/crtstuff.c >>> index 4927a9f..159b461 100644 >>> --- a/libgcc/crtstuff.c >>> +++ b/libgcc/crtstuff.c >>> @@ -429,9 +429,18 @@ __do_global_dtors_aux (void) >>> #ifdef FINI_SECTION_ASM_OP >>> CRT_CALL_STATIC_FUNCTION (FINI_SECTION_ASM_OP, __do_global_dtors_aux) >>> #elif defined (FINI_ARRAY_SECTION_ASM_OP) >>> +#if defined(__FDPIC__) >>> +__asm__( >>> + " .section .fini_array\n" >>> + " .align 2\n" >>> + " .word __do_global_dtors_aux\n" >>> +); >>> +asm (TEXT_SECTION_ASM_OP); >>> +#else /* defined(__FDPIC__) */ >>> static func_ptr __do_global_dtors_aux_fini_array_entry[] >>> __attribute__ ((__used__, section(".fini_array"), aligned(sizeof(func_ptr)))) >>> = { __do_global_dtors_aux }; >>> +#endif /* defined(__FDPIC__) */ >>> #else /* !FINI_SECTION_ASM_OP && !FINI_ARRAY_SECTION_ASM_OP */ >>> static void __attribute__((used)) >>> __do_global_dtors_aux_1 (void) >> >> It'd be good to avoid hard-coding the pointer size. Would it work to do: >> >> __asm__("\t.equ\.t__do_global_dtors_aux_alias, __do_global_dtors_aux\n"); >> extern char __do_global_dtors_aux_alias; >> static void *__do_global_dtors_aux_fini_array_entry[] >> __attribute__ ((__used__, section(".fini_array"), aligned(sizeof(void *)))) >> = { &__do_global_dtors_aux_alias }; >> >> ? Similarly for the init_array. >> > OK, done. > >> AFAICT this and 02/21 are the only patches that aren't Arm-specific, >> is that right? >> >> Thanks, >> Richard >> . >> > > From ea0eee1ddeddef92277ae68eac4af28994c2902c Mon Sep 17 00:00:00 2001 > From: Christophe Lyon > Date: Thu, 8 Feb 2018 11:12:52 +0100 > Subject: [ARM/FDPIC v6 05/24] [ARM] FDPIC: Fix __do_global_dtors_aux and > frame_dummy generation > MIME-Version: 1.0 > Content-Type: text/plain; charset=UTF-8 > Content-Transfer-Encoding: 8bit > > In FDPIC, we need to make sure __do_global_dtors_aux and frame_dummy > are referenced by their address, not by pointers to the function > descriptors. > > 2019-XX-XX Christophe Lyon > Micka«l Guªn© > > libgcc/ > * libgcc/crtstuff.c: Add support for FDPIC. OK, thanks. Richard > > Change-Id: I0bc4b1232fbf3c69068fb23a1b9cafc895d141b1 > > diff --git a/libgcc/crtstuff.c b/libgcc/crtstuff.c > index 4927a9f..6659039 100644 > --- a/libgcc/crtstuff.c > +++ b/libgcc/crtstuff.c > @@ -429,9 +429,17 @@ __do_global_dtors_aux (void) > #ifdef FINI_SECTION_ASM_OP > CRT_CALL_STATIC_FUNCTION (FINI_SECTION_ASM_OP, __do_global_dtors_aux) > #elif defined (FINI_ARRAY_SECTION_ASM_OP) > +#if defined(__FDPIC__) > +__asm__("\t.equ\t__do_global_dtors_aux_alias, __do_global_dtors_aux\n"); > +extern char __do_global_dtors_aux_alias; > +static void *__do_global_dtors_aux_fini_array_entry[] > +__attribute__ ((__used__, section(".fini_array"), aligned(sizeof(void *)))) > + = { &__do_global_dtors_aux_alias }; > +#else /* defined(__FDPIC__) */ > static func_ptr __do_global_dtors_aux_fini_array_entry[] > __attribute__ ((__used__, section(".fini_array"), aligned(sizeof(func_ptr)))) > = { __do_global_dtors_aux }; > +#endif /* defined(__FDPIC__) */ > #else /* !FINI_SECTION_ASM_OP && !FINI_ARRAY_SECTION_ASM_OP */ > static void __attribute__((used)) > __do_global_dtors_aux_1 (void) > @@ -473,9 +481,17 @@ frame_dummy (void) > #ifdef __LIBGCC_INIT_SECTION_ASM_OP__ > CRT_CALL_STATIC_FUNCTION (__LIBGCC_INIT_SECTION_ASM_OP__, frame_dummy) > #else /* defined(__LIBGCC_INIT_SECTION_ASM_OP__) */ > +#if defined(__FDPIC__) > +__asm__("\t.equ\t__frame_dummy_alias, frame_dummy\n"); > +extern char __frame_dummy_alias; > +static void *__frame_dummy_init_array_entry[] > +__attribute__ ((__used__, section(".init_array"), aligned(sizeof(void *)))) > + = { &__frame_dummy_alias }; > +#else /* defined(__FDPIC__) */ > static func_ptr __frame_dummy_init_array_entry[] > __attribute__ ((__used__, section(".init_array"), aligned(sizeof(func_ptr)))) > = { frame_dummy }; > +#endif /* defined(__FDPIC__) */ > #endif /* !defined(__LIBGCC_INIT_SECTION_ASM_OP__) */ > #endif /* USE_EH_FRAME_REGISTRY || USE_TM_CLONE_REGISTRY */