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: 137447 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp1014989vqo; Mon, 4 Sep 2023 03:58:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFNqJiyVmGfIaIWLAP++cmzYUb9P1CgbuIi+vBlaF8TGe6X85CxvZlclK16hgdwSXMyy6W X-Received: by 2002:a17:906:1054:b0:9a5:b95a:1179 with SMTP id j20-20020a170906105400b009a5b95a1179mr6013000ejj.77.1693825126229; Mon, 04 Sep 2023 03:58:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693825126; cv=none; d=google.com; s=arc-20160816; b=IN8yH+j1mmz3tuBd7p5g8nn5vU2fzarb5IjiQWYN/Ly/Ai07yDO2WdvdOIULKFq4bG XG1gj985561PKa2zs4Xr6jnnFHVLD+dKwXPrqpP/1HrpCDDZT928KDgAudMD9tSr+Vx/ tVRBIprsmCDD2mXfvdWqyTEt67HNHyKlHyQLJr+EwVTbFgprAvB6spScw9nF3AfBZ9y0 n5x4aVaO0fwFaNj7eT4bqJRNEnaVxsN6yh235IguxqFKdwYmkKhgLn3REackwdn2Ksa6 WFf9QdJpBmujSDh5eKUec5sonXz8nMK38sM6ahE7pKWhfroW+mvQkf4IazPyLpi7+Pge OYgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=WXIpXVGHeTaARUcDTO1ElEBm7YDHBJlsrqLNdRSOuYc=; fh=hKkF4Qm4zMpuuPSvBuLljwLCLYziV8/JqYgl0gS1cUA=; b=YHlvxJRwB1RwCK/2EkRRSGf4fs2LY374o+tvJpgSDjNBdiAwUlO0c9HvzT6/8qQAu+ hhtdvmNblyi9XXaeF32MIKc+UzMBTd12D7TCzr6q6X5TNHnqSAVPf4ElqcY1WlXoL5VG rb4kpwNX/gmJ0pEi2sVxnvgz9P81VD4a5JL/zIByXyDjj+Iytf0+LD2439ilTetbcN96 58rsyR1sanHDaBPMCGH/4ZiHLzMH6kBHWU5s0M17y/8c0IlVrZcyf64vmicUy004FTcW 2lFQAhxDBNN2hMFZNOFYnL/B2DcVZE0Fx67oDqExg/ncLVjruAo0SD7SnF4fSHiItC52 I3YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=i7icQ5X5; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gy19-20020a170906f25300b009a1b857e3aasi6364969ejb.3.2023.09.04.03.58.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Sep 2023 03:58:46 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=i7icQ5X5; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E12B0385840E for ; Mon, 4 Sep 2023 10:58:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E12B0385840E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693825124; bh=WXIpXVGHeTaARUcDTO1ElEBm7YDHBJlsrqLNdRSOuYc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=i7icQ5X5qP3fW8L0dQkPl6eK+tl2aZyafwuv4QjCIVuxk5LCJG7FPaSxoxB5FJcgD 6wK6TIS2EhXiXjUtVaFcwe8Bf7sXUevgv9G5l4jlZfEZDNQ9KbNfVE37sfr/xelHRD U83uE+gNfQCThJuOj6Isr25rJyoZRGRyY7YO35qY= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776104375399162257 X-GMAIL-MSGID: 1776104375399162257 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)