Place jump tables in RELRO only when targets require local relocation to be placed in a read-write section
Message ID | b931efa5-d881-c144-57ea-970d2a60f750@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 765D2393A41B for <patchwork@sourceware.org>; Wed, 12 Jan 2022 07:21:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 765D2393A41B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641972066; bh=NxHGZ7sZyg1UIWM2NIyt83iaJSZD2uIm3ybUim/Jbd8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=v6lhUhohk53xOM0h4HOEiaJQ2cRanyU6X+ejjVh6lPYT+wBMrQlLMdMRvYHKHLoto w9FiMZmr+V88ymdIQ6iG+DwrPT0+0Lc/FITcdXxCZya5zXS/sCRBmZqAnW/XQguyAo l6NhjnsBT0O2DVvAaaBzn7fZI7+u2ebtzopyf4Pw= 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 8E36D3858416 for <gcc-patches@gcc.gnu.org>; Wed, 12 Jan 2022 07:20:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8E36D3858416 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20C5LhD6018019; Wed, 12 Jan 2022 07:20:36 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 3dhrs89w5j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Jan 2022 07:20:35 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 20C7CEQe003936; Wed, 12 Jan 2022 07:20:33 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03fra.de.ibm.com with ESMTP id 3df289cwhb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Jan 2022 07:20:33 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 20C7KTXI42336648 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Jan 2022 07:20:29 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8561352069; Wed, 12 Jan 2022 07:20:29 +0000 (GMT) Received: from [9.200.100.183] (unknown [9.200.100.183]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 3E21552051; Wed, 12 Jan 2022 07:20:27 +0000 (GMT) Message-ID: <b931efa5-d881-c144-57ea-970d2a60f750@linux.ibm.com> Date: Wed, 12 Jan 2022 15:20:26 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Content-Language: en-US To: gcc-patches <gcc-patches@gcc.gnu.org> Subject: [PATCH] Place jump tables in RELRO only when targets require local relocation to be placed in a read-write section Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: gPcQ_Vj7CB-eieYKf4q_KTZp14EXbAFz X-Proofpoint-ORIG-GUID: gPcQ_Vj7CB-eieYKf4q_KTZp14EXbAFz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-12_02,2022-01-11_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 bulkscore=0 suspectscore=0 adultscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201120044 X-Spam-Status: No, score=-12.7 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 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>, 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 |
Place jump tables in RELRO only when targets require local relocation to be placed in a read-write section
|
|
Commit Message
HAO CHEN GUI
Jan. 12, 2022, 7:20 a.m. UTC
Hi, This patch sets "relocatable" of jump table to true when targets require local relocation to be placed in a read-write section - bit 0 is set in reloc_rw_mask. Jump tables are in local relocation, so they should be placed in RELRO only when both global and local relocation need to be placed in a read-write section. Bit 1 is always set when bit 0 is set. Bootstrapped and tested on powerpc64-linux BE/LE and x86 with no regressions. Is this okay for trunk? Any recommendations? Thanks a lot. ChangeLog 2022-01-12 Haochen Gui <guihaoc@linux.ibm.com> gcc/ * final.c (jumptable_relocatable): Set relocatable to true when targets require local relocation to be placed in a read-write section. patch.diff
Comments
On 1/12/2022 12:20 AM, HAO CHEN GUI via Gcc-patches wrote: > Hi, > This patch sets "relocatable" of jump table to true when targets require local relocation to be placed > in a read-write section - bit 0 is set in reloc_rw_mask. Jump tables are in local relocation, so they > should be placed in RELRO only when both global and local relocation need to be placed in a read-write > section. Bit 1 is always set when bit 0 is set. > Bootstrapped and tested on powerpc64-linux BE/LE and x86 with no regressions. Is this okay for trunk? > Any recommendations? Thanks a lot. > > ChangeLog > 2022-01-12 Haochen Gui <guihaoc@linux.ibm.com> > > gcc/ > * final.c (jumptable_relocatable): Set relocatable to true when > targets require local relocation to be placed in a read-write section. It seems unwise to me to rely on the fact that bit1 is already on when bit0 is on. I realize that's likely just preserving existing behavior, but unless there's a compelling reason, I'd rather do: relocatable = (targetm.asm_out.reloc_rw_mask () & 1) != 0; Which avoids the assumption that if bit0 is on, then bit 1 will always be on. jeff
diff --git a/gcc/final.c b/gcc/final.c index 296a9382e91..e86223cb96b 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -2141,7 +2141,7 @@ jumptable_relocatable (void) if (!CASE_VECTOR_PC_RELATIVE && !targetm.asm_out.generate_pic_addr_diff_vec () && targetm_common.have_named_sections) - relocatable = targetm.asm_out.reloc_rw_mask (); + relocatable = targetm.asm_out.reloc_rw_mask () == 3; return relocatable; }