From patchwork Wed Aug 15 18:50:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 958000 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-483737-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="GpZ8VKoQ"; 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 41rJSd3TQyz9sBx for ; Thu, 16 Aug 2018 04:50:41 +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:from :content-type:content-transfer-encoding:mime-version:subject :message-id:date:cc:to; q=dns; s=default; b=d6nYVUlxt1/pdjtSSeE1 5I6+6MNVKGz3zQkkrdAXFbr7EwzzRS9FMf8uuf3NdzblJnxJI1gxzNqC/1WVxkV2 sy35Kfvlia1CsF6Dul23Q3HnbrvdP9Wdpzjga1mZ9jU+S42RiTvsJICxEdbIRQJ6 STDptCVNO9Q3u/+s8mevC2Q= 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:from :content-type:content-transfer-encoding:mime-version:subject :message-id:date:cc:to; s=default; bh=UmnxpXEx0CbVldRw+5t/gaW0x+ w=; b=GpZ8VKoQ9gWFh9l3Nez+t2nBBmtLh09NtDqZ/oL2lg7pcbqrcGi5I1x/vi BtRxvSYfnpsq5eoaM3QlcR/vxtOGKVOedS/5JMe/UzImIS5KTuK7P1GBFZ+e36GZ vyii2RrON+X3O/ofWrGMqbzEgtYLr5tg8lwiF2vbi0hZRFhQw= Received: (qmail 42285 invoked by alias); 15 Aug 2018 18:50:34 -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 42260 invoked by uid 89); 15 Aug 2018 18:50:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_COUK, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT autolearn=ham version=3.3.2 spammy=carrying, jam, pipe, crt X-HELO: smtp2.wavenetuk.net Received: from lisa.wavenetuk.net (HELO smtp2.wavenetuk.net) (195.26.37.17) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 Aug 2018 18:50:30 +0000 Received: from euterpe-sie.home (host81-138-1-83.in-addr.btopenworld.com [81.138.1.83]) by smtp2.wavenetuk.net (Postfix) with ESMTPA id 360E2600179; Wed, 15 Aug 2018 19:50:28 +0100 (BST) From: Iain Sandoe Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [PATCH, Darwin] Move fixed _Unwind_find_Enclosing_func to a crt. Message-Id: Date: Wed, 15 Aug 2018 19:50:25 +0100 Cc: Mike Stump To: GCC Patches Hi, This is a pre-cursor to other tidy-ups aimed at being able to dispense with the “ext” library that we introduced (a loooong time ago) to deal with the differences between Darwin’s installed libgcc_s and the current compiler. Since the installed version of _Unwind_find_Enclosing_func was broken, we built a small shim function to allow Java to work on Darwin10. We have been carrying this around in the darwin-specific unwinder code ever since. This patch splits the patch function out into a shim crt that is included only when needed (for x86 and ppc via Rosetta on Darwin10). There is no need to treat Darwin12+ differently in this and that allows us to simplify the header there. OK for trunk? Iain 2018-08-15 Iain Sandoe gcc/ * config/darwin10.h (LINK_GCC_C_SEQUENCE_SPEC): Adjust to use the Darwin10-specific unwinder-shim. * config/darwin12.h (LINK_GCC_C_SEQUENCE_SPEC): Remove. * config/rs6000/darwin.h (DARWIN_CRT1_SPEC, DARWIN_DYLIB1_SPEC): New to cater for Darwin10 Rosetta. libgcc/ * config/unwind-dw2-fde-darwin.c (_darwin10_Unwind_FindEnclosingFunction): move from here ... * config/darwin10-unwind-find-enc-func.c: … to here. * config/t-darwin: Build Darwin10 unwinder shim crt. * libgcc/config.host: Add the Darwin10 unwinder shim. --- gcc/config/darwin10.h | 10 ++++++---- gcc/config/darwin12.h | 8 -------- gcc/config/rs6000/darwin.h | 13 +++++++++++++ libgcc/config.host | 2 +- libgcc/config/darwin10-unwind-find-enc-func.c | 13 +++++++++++++ libgcc/config/t-darwin | 4 ++++ libgcc/config/unwind-dw2-fde-darwin.c | 13 ------------- 7 files changed, 37 insertions(+), 26 deletions(-) create mode 100644 libgcc/config/darwin10-unwind-find-enc-func.c diff --git a/gcc/config/darwin10.h b/gcc/config/darwin10.h index d61eb40b8f..df694299ad 100644 --- a/gcc/config/darwin10.h +++ b/gcc/config/darwin10.h @@ -25,10 +25,12 @@ along with GCC; see the file COPYING3. If not see #undef LINK_GCC_C_SEQUENCE_SPEC #define LINK_GCC_C_SEQUENCE_SPEC \ "%:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) \ - %{!static:%{!static-libgcc: \ - %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \ - %{fno-pic|fno-PIC|fno-pie|fno-PIE|fapple-kext|mkernel|static|mdynamic-no-pic: \ - %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } %G %{!nolibc:%L}" + %{!static:%{!static-libgcc: \ + %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \ + %{fno-pic|fno-PIC|fno-pie|fno-PIE|fapple-kext|mkernel|static|mdynamic-no-pic: \ + %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } \ + %{!nostdlib:%:version-compare(>< 10.6 10.7 mmacosx-version-min= -ld10-uwfef.o)} \ + %G %{!nolibc:%L}" #undef DEF_MIN_OSX_VERSION #define DEF_MIN_OSX_VERSION "10.6" diff --git a/gcc/config/darwin12.h b/gcc/config/darwin12.h index e1e1eb085a..adc9a78d37 100644 --- a/gcc/config/darwin12.h +++ b/gcc/config/darwin12.h @@ -18,14 +18,6 @@ You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see . */ -#undef LINK_GCC_C_SEQUENCE_SPEC -#define LINK_GCC_C_SEQUENCE_SPEC \ -"%:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) \ - %{!static:%{!static-libgcc: \ - %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \ - %{fno-pic|fno-PIC|fno-pie|fno-PIE|fapple-kext|mkernel|static|mdynamic-no-pic: \ - %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } %G %{!nolibc:%L}" - #undef DEF_MIN_OSX_VERSION #define DEF_MIN_OSX_VERSION "10.8" diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h index cea1aa94b0..6b0f18e118 100644 --- a/gcc/config/rs6000/darwin.h +++ b/gcc/config/rs6000/darwin.h @@ -119,6 +119,13 @@ extern int darwin_emit_branch_islands; mcpu=G5:ppc970; \ :ppc}}" +/* We need to jam the crt to 10.5 for 10.6 (Rosetta) use. */ +#undef DARWIN_CRT1_SPEC +#define DARWIN_CRT1_SPEC \ + "%:version-compare(!> 10.5 mmacosx-version-min= -lcrt1.o) \ + %:version-compare(>< 10.5 10.7 mmacosx-version-min= -lcrt1.10.5.o) \ + %{fgnu-tm: -lcrttms.o}" + /* crt2.o is at least partially required for 10.3.x and earlier. */ #define DARWIN_CRT2_SPEC \ "%{!m64:%:version-compare(!> 10.4 mmacosx-version-min= crt2.o%s)}" @@ -130,6 +137,12 @@ extern int darwin_emit_branch_islands; { "darwin_crt2", DARWIN_CRT2_SPEC }, \ { "darwin_subarch", DARWIN_SUBARCH_SPEC }, +/* We need to jam the dylib crt to 10.5 for 10.6 (Rosetta) use. */ +#undef DARWIN_DYLIB1_SPEC +#define DARWIN_DYLIB1_SPEC \ + "%:version-compare(!> 10.5 mmacosx-version-min= -ldylib1.o) \ + %:version-compare(>< 10.5 10.7 mmacosx-version-min= -ldylib1.10.5.o)" + /* Output a .machine directive. */ #undef TARGET_ASM_FILE_START #define TARGET_ASM_FILE_START rs6000_darwin_file_start diff --git a/libgcc/config.host b/libgcc/config.host index 18cabaf24f..74024e50ef 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -205,7 +205,7 @@ case ${host} in *-*-darwin*) asm_hidden_op=.private_extern tmake_file="$tmake_file t-darwin ${cpu_type}/t-darwin t-libgcc-pic t-slibgcc-darwin" - extra_parts="crt3.o crttms.o crttme.o" + extra_parts="crt3.o d10-uwfef.o crttms.o crttme.o" ;; *-*-dragonfly*) tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip" diff --git a/libgcc/config/darwin10-unwind-find-enc-func.c b/libgcc/config/darwin10-unwind-find-enc-func.c new file mode 100644 index 0000000000..67c43757e5 --- /dev/null +++ b/libgcc/config/darwin10-unwind-find-enc-func.c @@ -0,0 +1,13 @@ +#include "tconfig.h" +#include "tsystem.h" +#include "unwind-dw2-fde.h" + +void * +_darwin10_Unwind_FindEnclosingFunction (void *pc) +{ + struct dwarf_eh_bases bases; + const struct dwarf_fde *fde = _Unwind_Find_FDE (pc-1, &bases); + if (fde) + return bases.func; + return NULL; +} diff --git a/libgcc/config/t-darwin b/libgcc/config/t-darwin index 13ca6ed99d..8340ea2bfe 100644 --- a/libgcc/config/t-darwin +++ b/libgcc/config/t-darwin @@ -20,3 +20,7 @@ HOST_LIBGCC2_CFLAGS += -pipe # Use unwind-dw2-fde-darwin LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/config/unwind-dw2-fde-darwin.c \ $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c + +# Patch to __Unwind_Find_Enclosing_Function for Darwin10. +d10-uwfef.o: $(srcdir)/config/darwin10-unwind-find-enc-func.c + $(crt_compile) $(DARWIN_EXTRA_CRT_BUILD_CFLAGS) -mmacosx-version-min=10.6 -c $< diff --git a/libgcc/config/unwind-dw2-fde-darwin.c b/libgcc/config/unwind-dw2-fde-darwin.c index 6e2d0d6d8b..c919de9abe 100644 --- a/libgcc/config/unwind-dw2-fde-darwin.c +++ b/libgcc/config/unwind-dw2-fde-darwin.c @@ -273,16 +273,3 @@ _Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases) the_obj_info); return ret; } - -void * -_darwin10_Unwind_FindEnclosingFunction (void *pc ATTRIBUTE_UNUSED) -{ -#if __MACH__ && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060) - struct dwarf_eh_bases bases; - const struct dwarf_fde *fde = _Unwind_Find_FDE (pc-1, &bases); - if (fde) - return bases.func; -#endif - return NULL; -} -