From patchwork Mon Sep 4 10:57:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1829481 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=MlflofNu; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RfQbh5YBWz1yhH for ; Mon, 4 Sep 2023 20:58:23 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BFA9F3858C74 for ; Mon, 4 Sep 2023 10:58:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BFA9F3858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693825101; bh=WXIpXVGHeTaARUcDTO1ElEBm7YDHBJlsrqLNdRSOuYc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=MlflofNuxdvlczpP5aTBNdjC/CRfSXw90Gb11jyp+yx1QK1iIDYMq1gcxJ1LOLLcw FpnexJUMsk+ktuhpefMvcnMpO1fXqMN+ZV3DL36ma2BLfqwiE4u5x7q6qgy6oQph2N cDZGtM5t1BelPomWfsKyqRrtr5rjBBm92xu9pTIE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 0F63D3858C54 for ; Mon, 4 Sep 2023 10:58:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0F63D3858C54 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-402c1407139so14272215e9.1 for ; Mon, 04 Sep 2023 03:58:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693825081; x=1694429881; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=WXIpXVGHeTaARUcDTO1ElEBm7YDHBJlsrqLNdRSOuYc=; b=d3bTLSrizEDnx5Hvv8EL6t0V17ll6NT93GOXJVSeaCTixr4mq2YS913BrrBgI8ykTa nkhcJzWthwGS8PEFWJIHDgiow54whyZbeb4zvWWtPJe1IEPHbX5y1/gly/Umg5TrxJLi OUnEjR8ezS2KXZ4nFcXA/OMMgQHB181s3uAIWUyts/kj7hUwQaxXNPy8a6+VLPIcnY17 IoWGzUzRptlTshoSbPjcy+zE0aSnI2TPd0sITz7uWBqPuWltq9KPqUjwHmFxSi1f6ZNo lniDXn3g3Oy1rT/+1htAj6E4+tDXj+BxrqX0sNNC7KI+xmkbraHg7R1PdchEggqoRcOU qEQA== X-Gm-Message-State: AOJu0Yx3FV8oKzTqd3U5r7H+NbLmCr/lesj+6051ijMt4Mu40XWs3ZFk rWn5WEga34zfoCMpYB2dVYuKy6GiVvk= X-Google-Smtp-Source: AGHT+IE0p6fEMLIjEcCqQ0pFbrbOkOCc63kwtzrqTcH9dcaHW7F1z9M+W69PMW6bc0RKkddxJZFOjw== X-Received: by 2002:a5d:668f:0:b0:317:54de:9718 with SMTP id l15-20020a5d668f000000b0031754de9718mr6796494wru.22.1693825080433; Mon, 04 Sep 2023 03:58:00 -0700 (PDT) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id dd18-20020a0560001e9200b0031f3ad17b2csm6653375wrb.52.2023.09.04.03.57.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 04 Sep 2023 03:58:00 -0700 (PDT) X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Subject: [pushed] Darwin: Match system sections and relocs for exception tables. Date: Mon, 4 Sep 2023 11:57:59 +0100 Message-Id: <20230904105759.17192-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.39.2 (Apple Git-143) MIME-Version: 1.0 X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Sandoe via Gcc-patches From: Iain Sandoe Reply-To: iain@sandoe.co.uk Cc: Iain Sandoe Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Tested on x86_64-darwin21 and i686-darwin9, pushed to trunk, thanks, Iain --- 8< --- System tools from Darwin10 onwards have moved the exceptions tables from the __DATA segment to the __TEXT one. They also revised the relocations used for typeinfo. While Darwin9 was not changed at the time, in fact the tools there are equally happy with the revised scheme - and therefore at present there seems no reason to special-case it. Signed-off-by: Iain Sandoe gcc/ChangeLog: * config/darwin-sections.def (darwin_exception_section): Move to the __TEXT segment. * config/darwin.cc (darwin_emit_except_table_label): Align before the exception table label. * config/darwin.h (ASM_PREFERRED_EH_DATA_FORMAT): Use indirect PC- relative 4byte relocs. --- gcc/config/darwin-sections.def | 2 +- gcc/config/darwin.cc | 1 + gcc/config/darwin.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/config/darwin-sections.def b/gcc/config/darwin-sections.def index 62a51b9761c..de2334f4a7a 100644 --- a/gcc/config/darwin-sections.def +++ b/gcc/config/darwin-sections.def @@ -157,7 +157,7 @@ DEF_SECTION (machopic_picsymbol_stub3_section, SECTION_NO_ANCHOR, /* Exception-related. */ DEF_SECTION (darwin_exception_section, SECTION_NO_ANCHOR, - ".section __DATA,__gcc_except_tab", 0) + ".section __TEXT,__gcc_except_tab", 0) DEF_SECTION (darwin_eh_frame_section, SECTION_NO_ANCHOR, ".section " EH_FRAME_SECTION_NAME ",__eh_frame" EH_FRAME_SECTION_ATTR, 0) diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index 0d53e97ae80..b435bb2b80a 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -2271,6 +2271,7 @@ darwin_emit_except_table_label (FILE *file) { char section_start_label[30]; + fputs ("\t.p2align\t2\n", file); ASM_GENERATE_INTERNAL_LABEL (section_start_label, "GCC_except_table", except_table_label_num++); ASM_OUTPUT_LABEL (file, section_start_label); diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 1b3f1bd984c..b7cfab607db 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -1089,7 +1089,7 @@ enum machopic_addr_class { #undef ASM_PREFERRED_EH_DATA_FORMAT #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \ - (((CODE) == 2 && (GLOBAL) == 1) \ + (((CODE) == 2 && (GLOBAL) == 1) || ((CODE) == 0 && (GLOBAL) == 1) \ ? (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4) : \ ((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr)