From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 47946 invoked by alias); 29 Aug 2019 15:35:13 -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 47936 invoked by uid 89); 29 Aug 2019 15:35:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy=Similarly X-HELO: mx07-00178001.pphosted.com Received: from mx07-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (62.209.51.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 29 Aug 2019 15:35:11 +0000 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7TFUgHS032090; Thu, 29 Aug 2019 17:35:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=subject : to : references : from : message-id : date : mime-version : in-reply-to : content-type; s=STMicroelectronics; bh=GOLMy39pMvZ76QBhNlkUv6VCResVT91V9qkIsvSVCsU=; b=dTPtBAGGTbdFwGF7QJBgr9aWxA4GZ9qxioW0mrc3PMuALW4vIZRBmPflpTZZ12ACSWga hYHaRtTTRCKqxTZsdIrmyx9BENSoc0IXl2aIl7AHLzLKWWaBKMtPRaa5myG9ESwcas6r k/Ebuy9kdnNWotGtGEQFyhlykEsTHRhih77RvEHOzFi2QqgOdethculqtS7labfsH6Zv oVMQuygA7RP/Umlg+C55RqI0HqCxGDDnZ5axaAB4qZCe7T+EYZGov9Lk3uW+aMnpSScW mAlGpmESIdugdDtvmX5sdouo/rX+jdMpOB/Gj1bgr7plZ3590VvN+Icj3ModAmQTntPn pQ== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx07-00178001.pphosted.com with ESMTP id 2upe31s55q-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 29 Aug 2019 17:35:06 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 1F11E22; Thu, 29 Aug 2019 15:35:03 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 813002D43B9; Thu, 29 Aug 2019 17:35:02 +0200 (CEST) Received: from [10.129.178.138] (10.75.127.50) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 29 Aug 2019 17:35:02 +0200 Subject: Re: [ARM/FDPIC v5 05/21] [ARM] FDPIC: Fix __do_global_dtors_aux and frame_dummy generation To: , References: <20190515124006.25840-1-christophe.lyon@st.com> <20190515124006.25840-6-christophe.lyon@st.com> From: Christophe Lyon Message-ID: <64380f14-d2bd-a3c4-4cae-ba1cb21bad1d@st.com> Date: Thu, 29 Aug 2019 15:39:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------4AB5938259E55D602C32B2B3" X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg01997.txt.bz2 --------------4AB5938259E55D602C32B2B3 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-length: 1948 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 > . > --------------4AB5938259E55D602C32B2B3 Content-Type: text/x-patch; name="0005-ARM-FDPIC-Fix-__do_global_dtors_aux-and-frame_dummy-.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename*0="0005-ARM-FDPIC-Fix-__do_global_dtors_aux-and-frame_dummy-.pa"; filename*1="tch" Content-length: 2526 >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. 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 */ -- 2.6.3 --------------4AB5938259E55D602C32B2B3--