Message ID | a22cb9f0-937c-7880-ef63-b3b67fd495af@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AA5FC3858437 for <patchwork@sourceware.org>; Wed, 16 Feb 2022 08:42:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA5FC3858437 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1645000965; bh=4y7tqYyMMh4gBtzhCQZxjQV3/XRFjWYOt2vY06QbgXc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=o7JDq6yr6pXVPe6LUjLErU1x0btzjYW3peDpqNaO+qrgdgTvjD7iqqEOZ/xAzOrBa LqmzFYDt1/W2x78R7Y8FxETDWJHjZAdJPxkX1yJ/Mq3qMh02jSPCXGp4zZW88fiyOy 9k86roP31j/aL0qrIKtERaH/ui8JQyYGwNKW3upU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 972903858D3C for <gcc-patches@gcc.gnu.org>; Wed, 16 Feb 2022 08:42:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 972903858D3C Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21G798Sv005977; Wed, 16 Feb 2022 08:42:15 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e8utetk51-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Feb 2022 08:42:15 +0000 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 21G8gEeq019717; Wed, 16 Feb 2022 08:42:14 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e8utetk4b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Feb 2022 08:42:14 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 21G8c6KF029228; Wed, 16 Feb 2022 08:42:12 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma01fra.de.ibm.com with ESMTP id 3e64h9mmu4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Feb 2022 08:42:12 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 21G8VlrO49742118 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Feb 2022 08:31:47 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 27A2D11C05E; Wed, 16 Feb 2022 08:42:10 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E2A7411C058; Wed, 16 Feb 2022 08:42:08 +0000 (GMT) Received: from [9.200.101.176] (unknown [9.200.101.176]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 16 Feb 2022 08:42:08 +0000 (GMT) Message-ID: <a22cb9f0-937c-7880-ef63-b3b67fd495af@linux.ibm.com> Date: Wed, 16 Feb 2022 16:42:07 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Content-Language: en-US To: gcc-patches <gcc-patches@gcc.gnu.org> Subject: [PATCH v2, rs6000] Enable absolute jump table for PPC AIX and Linux Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: DwapgI5V_dwMkPKP8yCgdhctQnkfsooJ X-Proofpoint-ORIG-GUID: wcepSSqfJ_1yLCFXgtcBrlaN6NJgV10n X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-16_04,2022-02-14_04,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 bulkscore=0 phishscore=0 spamscore=0 mlxlogscore=999 lowpriorityscore=0 mlxscore=0 adultscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202160047 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: HAO CHEN GUI via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: HAO CHEN GUI <guihaoc@linux.ibm.com> Cc: Bill Schmidt <wschmidt@linux.ibm.com>, David <dje.gcc@gmail.com>, Segher Boessenkool <segher@kernel.crashing.org> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
[v2,rs6000] Enable absolute jump table for PPC AIX and Linux
|
|
Commit Message
HAO CHEN GUI
Feb. 16, 2022, 8:42 a.m. UTC
Hi, This patch enables absolute jump tables on PPC AIX and Linux. For AIX, the jump table is placed in data section. For Linux, it is placed in RELRO section when relocation is needed. Bootstrapped and tested on AIX,Linux BE and LE with no regressions. Is this okay for trunk? Any recommendations? Thanks a lot. ChangeLog 2022-02-16 Haochen Gui <guihaoc@linux.ibm.com> gcc/ * config/rs6000/aix.h (JUMP_TABLES_IN_TEXT_SECTION): Define. * config/rs6000/linux64.h (JUMP_TABLES_IN_TEXT_SECTION): Likewise. * config/rs6000/rs6000.cc (rs6000_option_override_internal): Enable absolute jump tables for AIX and Linux. (rs6000_xcoff_function_rodata_section): Implement. * config/rs6000/xcoff.h (TARGET_ASM_FUNCTION_RODATA_SECTION): Define. patch.diff
Comments
Hi Haochen, Some minor comments are inlined. on 2022/2/16 下午4:42, HAO CHEN GUI via Gcc-patches wrote: > Hi, > This patch enables absolute jump tables on PPC AIX and Linux. For AIX, the jump > table is placed in data section. For Linux, it is placed in RELRO section when > relocation is needed. > > Bootstrapped and tested on AIX,Linux BE and LE with no regressions. Is this okay for trunk? > Any recommendations? Thanks a lot. > I may miss something, but there seem no test cases in power target testsuite to check expected assembly for absolute and relative jump table. If so, maybe it's better to add one or two? > ChangeLog > 2022-02-16 Haochen Gui <guihaoc@linux.ibm.com> > > gcc/ > * config/rs6000/aix.h (JUMP_TABLES_IN_TEXT_SECTION): Define. > * config/rs6000/linux64.h (JUMP_TABLES_IN_TEXT_SECTION): Likewise. > * config/rs6000/rs6000.cc (rs6000_option_override_internal): Enable > absolute jump tables for AIX and Linux. > (rs6000_xcoff_function_rodata_section): Implement. > * config/rs6000/xcoff.h (TARGET_ASM_FUNCTION_RODATA_SECTION): Define. > > patch.diff > diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h > index ad3238bf09a..b52208c2ee7 100644 > --- a/gcc/config/rs6000/aix.h > +++ b/gcc/config/rs6000/aix.h > @@ -253,7 +253,7 @@ > > /* Indicate that jump tables go in the text section. */ > > -#define JUMP_TABLES_IN_TEXT_SECTION 1 > +#define JUMP_TABLES_IN_TEXT_SECTION 0 > > /* Define any extra SPECS that the compiler needs to generate. */ > #undef SUBTARGET_EXTRA_SPECS > diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h > index b2a7afabc73..16df9ef167f 100644 > --- a/gcc/config/rs6000/linux64.h > +++ b/gcc/config/rs6000/linux64.h > @@ -239,7 +239,7 @@ extern int dot_symbols; > > /* Indicate that jump tables go in the text section. */ > #undef JUMP_TABLES_IN_TEXT_SECTION > -#define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT > +#define JUMP_TABLES_IN_TEXT_SECTION 0 > > /* The linux ppc64 ABI isn't explicit on whether aggregates smaller > than a doubleword should be padded upward or downward. You could > diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc > index bc3ef0721a4..e9c5552c082 100644 > --- a/gcc/config/rs6000/rs6000.cc > +++ b/gcc/config/rs6000/rs6000.cc > @@ -4954,6 +4954,10 @@ rs6000_option_override_internal (bool global_init_p) > warning (0, "%qs is deprecated and not recommended in any circumstances", > "-mno-speculate-indirect-jumps"); > > + /* Enable absolute jump tables for AIX and Linux. */ > + if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) > + rs6000_relative_jumptables = 0; > + > return ret; > } > > @@ -28751,6 +28755,15 @@ constant_generates_xxspltidp (vec_const_128bit_type *vsx_const) > return sf_value; > } > > +section * rs6000_xcoff_function_rodata_section (tree decl ATTRIBUTE_UNUSED, > + bool relocatable) > +{ > + if (relocatable) > + return data_section; > + else > + return readonly_data_section; > +} > + > There is one area to put xcoff related functions and guarded with "#if TARGET_XCOFF", it looks good to put this into? and could we make this function static? Besides, it seems good to put some comments for this function to describe why we choose to use the data_section. > struct gcc_target targetm = TARGET_INITIALIZER; > > diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h > index cd0f99cb9c6..0dacd86eed9 100644 > --- a/gcc/config/rs6000/xcoff.h > +++ b/gcc/config/rs6000/xcoff.h > @@ -98,7 +98,7 @@ > #define TARGET_ASM_SELECT_SECTION rs6000_xcoff_select_section > #define TARGET_ASM_SELECT_RTX_SECTION rs6000_xcoff_select_rtx_section > #define TARGET_ASM_UNIQUE_SECTION rs6000_xcoff_unique_section > -#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section > +#define TARGET_ASM_FUNCTION_RODATA_SECTION rs6000_xcoff_function_rodata_section IIUC, the behavior of rs6000_xcoff_function_rodata_section isn't consistent with what we have in the hook description. If so, we need to update the hook description to align with this change. Otherwise, some future codes might expect this hook only return readonly section (not possible like data section) and get unexpected results. BR, Kewen
Kewen, Thanks so much for your advice. On 21/2/2022 下午 5:42, Kewen.Lin wrote: > Hi Haochen, > > Some minor comments are inlined. > > on 2022/2/16 下午4:42, HAO CHEN GUI via Gcc-patches wrote: >> Hi, >> This patch enables absolute jump tables on PPC AIX and Linux. For AIX, the jump >> table is placed in data section. For Linux, it is placed in RELRO section when >> relocation is needed. >> >> Bootstrapped and tested on AIX,Linux BE and LE with no regressions. Is this okay for trunk? >> Any recommendations? Thanks a lot. >> > > I may miss something, but there seem no test cases in power target testsuite to check expected > assembly for absolute and relative jump table. If so, maybe it's better to add one or two? I will add some testcases. > >> ChangeLog >> 2022-02-16 Haochen Gui <guihaoc@linux.ibm.com> >> >> gcc/ >> * config/rs6000/aix.h (JUMP_TABLES_IN_TEXT_SECTION): Define. >> * config/rs6000/linux64.h (JUMP_TABLES_IN_TEXT_SECTION): Likewise. >> * config/rs6000/rs6000.cc (rs6000_option_override_internal): Enable >> absolute jump tables for AIX and Linux. >> (rs6000_xcoff_function_rodata_section): Implement. >> * config/rs6000/xcoff.h (TARGET_ASM_FUNCTION_RODATA_SECTION): Define. >> >> patch.diff >> diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h >> index ad3238bf09a..b52208c2ee7 100644 >> --- a/gcc/config/rs6000/aix.h >> +++ b/gcc/config/rs6000/aix.h >> @@ -253,7 +253,7 @@ >> >> /* Indicate that jump tables go in the text section. */ >> >> -#define JUMP_TABLES_IN_TEXT_SECTION 1 >> +#define JUMP_TABLES_IN_TEXT_SECTION 0 >> >> /* Define any extra SPECS that the compiler needs to generate. */ >> #undef SUBTARGET_EXTRA_SPECS >> diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h >> index b2a7afabc73..16df9ef167f 100644 >> --- a/gcc/config/rs6000/linux64.h >> +++ b/gcc/config/rs6000/linux64.h >> @@ -239,7 +239,7 @@ extern int dot_symbols; >> >> /* Indicate that jump tables go in the text section. */ >> #undef JUMP_TABLES_IN_TEXT_SECTION >> -#define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT >> +#define JUMP_TABLES_IN_TEXT_SECTION 0 >> >> /* The linux ppc64 ABI isn't explicit on whether aggregates smaller >> than a doubleword should be padded upward or downward. You could >> diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc >> index bc3ef0721a4..e9c5552c082 100644 >> --- a/gcc/config/rs6000/rs6000.cc >> +++ b/gcc/config/rs6000/rs6000.cc >> @@ -4954,6 +4954,10 @@ rs6000_option_override_internal (bool global_init_p) >> warning (0, "%qs is deprecated and not recommended in any circumstances", >> "-mno-speculate-indirect-jumps"); >> >> + /* Enable absolute jump tables for AIX and Linux. */ >> + if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) >> + rs6000_relative_jumptables = 0; >> + >> return ret; >> } >> >> @@ -28751,6 +28755,15 @@ constant_generates_xxspltidp (vec_const_128bit_type *vsx_const) >> return sf_value; >> } >> >> +section * rs6000_xcoff_function_rodata_section (tree decl ATTRIBUTE_UNUSED, >> + bool relocatable) >> +{ >> + if (relocatable) >> + return data_section; >> + else >> + return readonly_data_section; >> +} >> + >> > > There is one area to put xcoff related functions and guarded with "#if TARGET_XCOFF", > it looks good to put this into? and could we make this function static? From my understanding, the function should be only called by xcoff target. Of course, it's safe with the guard. But we couldn't make the function static as it will be called in other files. > > Besides, it seems good to put some comments for this function to describe why we > choose to use the data_section. > >> struct gcc_target targetm = TARGET_INITIALIZER; >> >> diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h >> index cd0f99cb9c6..0dacd86eed9 100644 >> --- a/gcc/config/rs6000/xcoff.h >> +++ b/gcc/config/rs6000/xcoff.h >> @@ -98,7 +98,7 @@ >> #define TARGET_ASM_SELECT_SECTION rs6000_xcoff_select_section >> #define TARGET_ASM_SELECT_RTX_SECTION rs6000_xcoff_select_rtx_section >> #define TARGET_ASM_UNIQUE_SECTION rs6000_xcoff_unique_section >> -#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section >> +#define TARGET_ASM_FUNCTION_RODATA_SECTION rs6000_xcoff_function_rodata_section > > > IIUC, the behavior of rs6000_xcoff_function_rodata_section isn't consistent with what we have > in the hook description. If so, we need to update the hook description to align with this change. > Otherwise, some future codes might expect this hook only return readonly section (not possible > like data section) and get unexpected results. For the AIX/xcoff, the relocatable data section has to be the data section. Though it's not read-only. I think it's consistent with the definition? DEFHOOK (function_rodata_section, "Return the readonly data or reloc readonly data section associated with\n\ @samp{DECL_SECTION_NAME (@var{decl})}. @var{relocatable} selects the latter\n\ over the former.\n\ The default version of this function selects @code{.gnu.linkonce.r.name} if\n\ the function's section is @code{.gnu.linkonce.t.name}, @code{.rodata.name}\n\ or @code{.data.rel.ro.name} if function is in @code{.text.name}, and\n\ the normal readonly-data or reloc readonly data section otherwise.", section *, (tree decl, bool relocatable), default_function_rodata_section) > > BR, > Kewen >
on 2022/2/22 上午9:11, HAO CHEN GUI wrote: > > Kewen, > Thanks so much for your advice. > > On 21/2/2022 下午 5:42, Kewen.Lin wrote: >> Hi Haochen, >> >> Some minor comments are inlined. >> >> on 2022/2/16 下午4:42, HAO CHEN GUI via Gcc-patches wrote: >>> Hi, >>> This patch enables absolute jump tables on PPC AIX and Linux. For AIX, the jump >>> table is placed in data section. For Linux, it is placed in RELRO section when >>> relocation is needed. >>> >>> Bootstrapped and tested on AIX,Linux BE and LE with no regressions. Is this okay for trunk? >>> Any recommendations? Thanks a lot. >>> >> >> I may miss something, but there seem no test cases in power target testsuite to check expected >> assembly for absolute and relative jump table. If so, maybe it's better to add one or two? > I will add some testcases. > Thanks! >> >>> ChangeLog >>> 2022-02-16 Haochen Gui <guihaoc@linux.ibm.com> >>> >>> gcc/ >>> * config/rs6000/aix.h (JUMP_TABLES_IN_TEXT_SECTION): Define. >>> * config/rs6000/linux64.h (JUMP_TABLES_IN_TEXT_SECTION): Likewise. >>> * config/rs6000/rs6000.cc (rs6000_option_override_internal): Enable >>> absolute jump tables for AIX and Linux. >>> (rs6000_xcoff_function_rodata_section): Implement. >>> * config/rs6000/xcoff.h (TARGET_ASM_FUNCTION_RODATA_SECTION): Define. >>> >>> patch.diff >>> diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h >>> index ad3238bf09a..b52208c2ee7 100644 >>> --- a/gcc/config/rs6000/aix.h >>> +++ b/gcc/config/rs6000/aix.h >>> @@ -253,7 +253,7 @@ >>> >>> /* Indicate that jump tables go in the text section. */ >>> >>> -#define JUMP_TABLES_IN_TEXT_SECTION 1 >>> +#define JUMP_TABLES_IN_TEXT_SECTION 0 >>> >>> /* Define any extra SPECS that the compiler needs to generate. */ >>> #undef SUBTARGET_EXTRA_SPECS >>> diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h >>> index b2a7afabc73..16df9ef167f 100644 >>> --- a/gcc/config/rs6000/linux64.h >>> +++ b/gcc/config/rs6000/linux64.h >>> @@ -239,7 +239,7 @@ extern int dot_symbols; >>> >>> /* Indicate that jump tables go in the text section. */ >>> #undef JUMP_TABLES_IN_TEXT_SECTION >>> -#define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT >>> +#define JUMP_TABLES_IN_TEXT_SECTION 0 >>> >>> /* The linux ppc64 ABI isn't explicit on whether aggregates smaller >>> than a doubleword should be padded upward or downward. You could >>> diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc >>> index bc3ef0721a4..e9c5552c082 100644 >>> --- a/gcc/config/rs6000/rs6000.cc >>> +++ b/gcc/config/rs6000/rs6000.cc >>> @@ -4954,6 +4954,10 @@ rs6000_option_override_internal (bool global_init_p) >>> warning (0, "%qs is deprecated and not recommended in any circumstances", >>> "-mno-speculate-indirect-jumps"); >>> >>> + /* Enable absolute jump tables for AIX and Linux. */ >>> + if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) >>> + rs6000_relative_jumptables = 0; >>> + >>> return ret; >>> } >>> >>> @@ -28751,6 +28755,15 @@ constant_generates_xxspltidp (vec_const_128bit_type *vsx_const) >>> return sf_value; >>> } >>> >>> +section * rs6000_xcoff_function_rodata_section (tree decl ATTRIBUTE_UNUSED, >>> + bool relocatable) >>> +{ >>> + if (relocatable) >>> + return data_section; >>> + else >>> + return readonly_data_section; >>> +} >>> + >>> >> >> There is one area to put xcoff related functions and guarded with "#if TARGET_XCOFF", >> it looks good to put this into? and could we make this function static? > From my understanding, the function should be only called by xcoff target. Of course, > it's safe with the guard. But we couldn't make the function static as it will be called > in other files. > Yeah, that's why I suggested moving it. Here the function is used for hook implementation, just like some other existing hook functions, it would be used for function pointer initialization (address taken), I think it's fine to make it static. You can refer to some examples like: rs6000_xcoff_debug_unwind_info, etc... >> >> Besides, it seems good to put some comments for this function to describe why we >> choose to use the data_section. >> >>> struct gcc_target targetm = TARGET_INITIALIZER; >>> >>> diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h >>> index cd0f99cb9c6..0dacd86eed9 100644 >>> --- a/gcc/config/rs6000/xcoff.h >>> +++ b/gcc/config/rs6000/xcoff.h >>> @@ -98,7 +98,7 @@ >>> #define TARGET_ASM_SELECT_SECTION rs6000_xcoff_select_section >>> #define TARGET_ASM_SELECT_RTX_SECTION rs6000_xcoff_select_rtx_section >>> #define TARGET_ASM_UNIQUE_SECTION rs6000_xcoff_unique_section >>> -#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section >>> +#define TARGET_ASM_FUNCTION_RODATA_SECTION rs6000_xcoff_function_rodata_section >> >> >> IIUC, the behavior of rs6000_xcoff_function_rodata_section isn't consistent with what we have >> in the hook description. If so, we need to update the hook description to align with this change. >> Otherwise, some future codes might expect this hook only return readonly section (not possible >> like data section) and get unexpected results. > For the AIX/xcoff, the relocatable data section has to be the data section. > Though it's not read-only. I think it's consistent with the definition? > > DEFHOOK > (function_rodata_section, > "Return the readonly data or reloc readonly data section associated with\n\ > @samp{DECL_SECTION_NAME (@var{decl})}. @var{relocatable} selects the latter\n\ > over the former.\n\ > The default version of this function selects @code{.gnu.linkonce.r.name} if\n\ > the function's section is @code{.gnu.linkonce.t.name}, @code{.rodata.name}\n\ > or @code{.data.rel.ro.name} if function is in @code{.text.name}, and\n\ > the normal readonly-data or reloc readonly data section otherwise.", > section *, (tree decl, bool relocatable), > default_function_rodata_section) > > Sorry, I still think it's inconsistent. As you quoted, the description is "Return the readonly data or reloc readonly data section", here it gives the users the impression that it's for "readonly" data section. And without your patch, I think the previous default_no_function_rodata_section returns readonly_data_section which also holds the "readonly" property. With your patch, it can return the data section (r/w) which is NOT read-only. Ideally, I would expect we can leave this hook alone for readonly purpose and it can return NULL when some target doesn't have the expected section like the case you met here. The hook caller can decide whether just bypass this target which doesn't support readonly section or switch to workaround with some other section like r/w data for further processing. IMHO, it seems more clear than putting one section which isn't readonly but in one hook for readonly. BR, Kewen
diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h index ad3238bf09a..b52208c2ee7 100644 --- a/gcc/config/rs6000/aix.h +++ b/gcc/config/rs6000/aix.h @@ -253,7 +253,7 @@ /* Indicate that jump tables go in the text section. */ -#define JUMP_TABLES_IN_TEXT_SECTION 1 +#define JUMP_TABLES_IN_TEXT_SECTION 0 /* Define any extra SPECS that the compiler needs to generate. */ #undef SUBTARGET_EXTRA_SPECS diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h index b2a7afabc73..16df9ef167f 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h @@ -239,7 +239,7 @@ extern int dot_symbols; /* Indicate that jump tables go in the text section. */ #undef JUMP_TABLES_IN_TEXT_SECTION -#define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT +#define JUMP_TABLES_IN_TEXT_SECTION 0 /* The linux ppc64 ABI isn't explicit on whether aggregates smaller than a doubleword should be padded upward or downward. You could diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index bc3ef0721a4..e9c5552c082 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -4954,6 +4954,10 @@ rs6000_option_override_internal (bool global_init_p) warning (0, "%qs is deprecated and not recommended in any circumstances", "-mno-speculate-indirect-jumps"); + /* Enable absolute jump tables for AIX and Linux. */ + if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) + rs6000_relative_jumptables = 0; + return ret; } @@ -28751,6 +28755,15 @@ constant_generates_xxspltidp (vec_const_128bit_type *vsx_const) return sf_value; } +section * rs6000_xcoff_function_rodata_section (tree decl ATTRIBUTE_UNUSED, + bool relocatable) +{ + if (relocatable) + return data_section; + else + return readonly_data_section; +} + struct gcc_target targetm = TARGET_INITIALIZER; diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h index cd0f99cb9c6..0dacd86eed9 100644 --- a/gcc/config/rs6000/xcoff.h +++ b/gcc/config/rs6000/xcoff.h @@ -98,7 +98,7 @@ #define TARGET_ASM_SELECT_SECTION rs6000_xcoff_select_section #define TARGET_ASM_SELECT_RTX_SECTION rs6000_xcoff_select_rtx_section #define TARGET_ASM_UNIQUE_SECTION rs6000_xcoff_unique_section -#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section +#define TARGET_ASM_FUNCTION_RODATA_SECTION rs6000_xcoff_function_rodata_section #define TARGET_STRIP_NAME_ENCODING rs6000_xcoff_strip_name_encoding #define TARGET_SECTION_TYPE_FLAGS rs6000_xcoff_section_type_flags #ifdef HAVE_AS_TLS