From patchwork Thu Jul 18 00:26:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 1133475 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-505245-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bell.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Bmm04rp4"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45pw116vy4z9s3l for ; Thu, 18 Jul 2019 10:26:25 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=H2KchOmn9yMI5DbW x/IiOZ06yuLWchOT8hyMwUiT+P9xPUVKtDTXDczZb1Y0bdvqoqxs30UkRUywW1Xp geMm/FToWLuRwwMgQmmVuYsnBb5IkCNtw0/Q2uBB88jTyUPnhSmj5zLyXFflIQud ZimJSkxoIAxuQjAvRiKkzGvBK/4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type :content-transfer-encoding; s=default; bh=mHHWn/T3ePwq/KpUp6SOjm ab+y8=; b=Bmm04rp40ncOIDiDiPaGRBTM9u7Zu79asZo+N/9NXsOEY/Eys1MdmJ g8MrezFF54vxTIQGhO3EjrgXvWPzte2ls+6GyvxH/suJvhblRzsEngRUxpK6zkAm zSkClmWl3nmZRffB8VbZoZL5fekT8R8uAYlCQg6OJXUb8hMClR/B4= Received: (qmail 52139 invoked by alias); 18 Jul 2019 00:26:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 52129 invoked by uid 89); 18 Jul 2019 00:26:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 spammy=H*r:192.168.2 X-HELO: torfep01.bell.net Received: from simcoe207srvr.owm.bell.net (HELO torfep01.bell.net) (184.150.200.207) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 18 Jul 2019 00:26:16 +0000 Received: from bell.net torfep01 184.150.200.158 by torfep01.bell.net with ESMTP id <20190718002613.NESG4584.torfep01.bell.net@torspm01.bell.net> for ; Wed, 17 Jul 2019 20:26:13 -0400 Received: from [192.168.2.49] (really [70.53.53.104]) by torspm01.bell.net with ESMTP id <20190718002613.MTKK39285.torspm01.bell.net@[192.168.2.49]>; Wed, 17 Jul 2019 20:26:13 -0400 To: GCC Patches Cc: Helge Deller From: John David Anglin Subject: [PATCH] Put more data in read-only data on hppa Openpgp: preference=signencrypt Message-ID: <9cbb3de8-298e-db9f-0e92-55b594860658@bell.net> Date: Wed, 17 Jul 2019 20:26:13 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 X-CM-Analysis: v=2.3 cv=bPxo382Z c=1 sm=1 tr=0 cx=a_idp_d a=htCe9XT+XAlGhzqgweArVg==:117 a=htCe9XT+XAlGhzqgweArVg==:17 a=IkcTkHD0fZMA:10 a=0o9FgrsRnhwA:10 a=FBHGMhGWAAAA:8 a=mDV3o1hIAAAA:8 a=AXCTBifZoHnGHbpprUEA:9 a=7Zwj6sZBwVKJAoWSPKxL6X1jA+E=:19 a=QEXdDO2ut3YA:10 a=9gvnlMMaQFpL9xblJ6ne:22 a=_FVE-zBwftR9WsbkzFJk:22 X-CM-Envelope: MS4wfOYhF8GymZdR21MwQLM1AYjLaRKp/USjZRJexAIM2jcGQ4NKSccQkBxea+r9iqD9MIuR6w+HqLpfQBSVgkiiMhXA3DZD+wAPnsiOIwcDvm9GbjIzzSNY 26qbQMpoOaYbSKVRRvpZBsKiARb0xDQ5PV5ayvhIG+XQUYClZ0zpeF6D6u5i94d6AcTcdeqktD1n3Q== When generating non-PIC code on Linux, the linker support allows us to put both local and global relocs in read-only data. On HP-UX, we can put local relocs in read-only data. We can also put constant data in read-only data on the HP-UX SOM target when generating PIC code. This patch implements the above. Tested on hppa2.0w-hp-hpux11.11, hppa64-hp-hpux11.11 and hppa-unknown-linux-gnu. Committed to trunk and gcc-9. Dave Index: config/pa/pa.c =================================================================== --- config/pa/pa.c (revision 273480) +++ config/pa/pa.c (working copy) @@ -9805,20 +9805,23 @@ = get_unnamed_section (0, output_section_asm_op, "\t.SPACE $PRIVATE$\n\t.SUBSPA $TM_CLONE_TABLE$"); - /* FIXME: HPUX ld generates incorrect GOT entries for "T" fixups - which reference data within the $TEXT$ space (for example constant + /* HPUX ld generates incorrect GOT entries for "T" fixups which + reference data within the $TEXT$ space (for example constant strings in the $LIT$ subspace). The assemblers (GAS and HP as) both have problems with handling - the difference of two symbols which is the other correct way to + the difference of two symbols. This is the other correct way to reference constant data during PIC code generation. - So, there's no way to reference constant data which is in the - $TEXT$ space during PIC generation. Instead place all constant - data into the $PRIVATE$ subspace (this reduces sharing, but it - works correctly). */ - readonly_data_section = flag_pic ? data_section : som_readonly_data_section; + Thus, we can't put constant data needing relocation in the $TEXT$ + space during PIC generation. + Previously, we placed all constant data into the $DATA$ subspace + when generating PIC code. This reduces sharing, but it works + correctly. Now we rely on pa_reloc_rw_mask() for section selection. + This puts constant data not needing relocation into the $TEXT$ space. */ + readonly_data_section = som_readonly_data_section; + /* We must not have a reference to an external symbol defined in a shared library in a readonly section, else the SOM linker will complain. @@ -9850,7 +9853,7 @@ && DECL_INITIAL (exp) && (DECL_INITIAL (exp) == error_mark_node || TREE_CONSTANT (DECL_INITIAL (exp))) - && !reloc) + && !(reloc & pa_reloc_rw_mask ())) { if (TARGET_SOM && DECL_ONE_ONLY (exp) @@ -9859,7 +9862,8 @@ else return readonly_data_section; } - else if (CONSTANT_CLASS_P (exp) && !reloc) + else if (CONSTANT_CLASS_P (exp) + && !(reloc & pa_reloc_rw_mask ())) return readonly_data_section; else if (TARGET_SOM && TREE_CODE (exp) == VAR_DECL @@ -9875,12 +9879,11 @@ static int pa_reloc_rw_mask (void) { - /* We force (const (plus (symbol) (const_int))) to memory when the - const_int doesn't fit in a 14-bit integer. The SOM linker can't - handle this construct in read-only memory and we want to avoid - this for ELF. So, we always force an RTX needing relocation to - the data section. */ - return 3; + if (flag_pic || (TARGET_SOM && !TARGET_HPUX_11)) + return 3; + + /* HP linker does not support global relocs in readonly memory. */ + return TARGET_SOM ? 2 : 0; } static void