From patchwork Sun Jan 28 14:07:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 193135 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp62711dyb; Sun, 28 Jan 2024 06:08:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHaA9x3DU6VVPA8RUTYq/QOuRcmqs1la+29kz5g+dg4buEh8abs4O4jHf80vs9T+ErLg0gr X-Received: by 2002:ad4:5de1:0:b0:686:9499:bacf with SMTP id jn1-20020ad45de1000000b006869499bacfmr4302028qvb.118.1706450918802; Sun, 28 Jan 2024 06:08:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706450918; cv=pass; d=google.com; s=arc-20160816; b=LaX4P42nhbGYep2Rc/ZRUyEFsb4FuMM60sj2smk/yC0rVqjeHXS4MebCOb5ek4gH2T myTsjJWPEPylJG/jzMmXKnc0JcIvCK1NTKRZGE+3lGp6BpzCqOwtM/Labs/73kyPcrKe Tb5C9LEKlKcVQpHHChHJhyyR4MuVwur5lsdoMRdkMnUinAEwVWx7AM7rEvtqBO7pSM1B Sh/ygVHbq9g5d0qoV8jKaFItuqSNxUfosiVUYdgOVusC7EhIn8ZZ/+EeM/pCJcAi5fUz 5Jk7jJ+Ur6tg3VbjcRKc5GEC2THXhL3l9YcL5Jpy44Wqy4RrFp5/IeW0F+ThU3dwCSOE kFeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=BxfuvO+vD6eAWW69GthCQX48zsB7UMkd9x61mccDZ48=; fh=K4AS3pFR26BR8zOf4IwrZlUeM0YSSQqO68Rjh5vfBKs=; b=NBm2XiUU1i7iJnLG5+SyySW+gXQOeST0twI9x7yG3YTYmNN0Vb2tjZtGAm2tRuwdX1 Hrrq+6jA1Fr7gG5yU/YBaGL7v5GVRqs06PZDGO46lDeM1bDTi6k8pea8bLJ3sFNX+lkp wpZBQPuaIJtKnKuk2XTfI07J6nL5DLFkc7b7iC6SVWqMvfW1nSKJigfEJCPqtI+8gdhv TOaNcBJ4t71rGdQhncBJSn7zzRV3dm3iN3bSIcQUZS+OOytbDZaKZHhHoqPJ5NKZZnYN Od2W+SjEBhZBYR9SBUTu/E9f6K3Fx0z/YMwBTKaZ855msnEqGQf7H5gYecT1NLPWFfw3 WkPw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="mZn/Jh/u"; arc=pass (i=1); 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id jk10-20020ad45d4a000000b0068170693ac3si5788035qvb.90.2024.01.28.06.08.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 06:08:38 -0800 (PST) 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=@gmail.com header.s=20230601 header.b="mZn/Jh/u"; arc=pass (i=1); 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7DC763858431 for ; Sun, 28 Jan 2024 14:08:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 80A003858402 for ; Sun, 28 Jan 2024 14:07:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 80A003858402 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 80A003858402 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706450874; cv=none; b=DhGsHrA1mQO1PmPZvmK4Ec3kVnmPwHC4YJpDKahWbkJn10kcHmfU1kPW0bxmsGYc2cZ49kXEfULGu8rOqEaBRVeDPCp+5jIz/QXqLluguK3oJ9WyHCpXVTVq7Uciv2rf9SeXzieucl5FAzG12/p0ZFERDfh1XbxJayZQq80CiKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706450874; c=relaxed/simple; bh=HPEz/HpmrxAAan85QaclVrCZPV40ELvfzHkHaGhEMhw=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=F5Pu7ZFy7YMG3knnQQWI/EfzyRRWLC/SiFXeciPLJYzqTdqZd5yhI0OCz6wCt0j6RWIjR04FKeZUJ4PD0Ix9jWGWR781iLPmgHiBEyeo+4Wv8knacC8jp+kwKlDGQTDYB6gtqjTxIwIzP77BFAoonU7ES3Q6eWi50bREj7pXBVw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3394b892691so978958f8f.1 for ; Sun, 28 Jan 2024 06:07:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706450869; x=1707055669; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=BxfuvO+vD6eAWW69GthCQX48zsB7UMkd9x61mccDZ48=; b=mZn/Jh/uPuzKw1Nzk0P/rgYFDiGqpQE59ps+AwcFh72rVwaElqOH41TFPh7yUrhOcn TFWIyOzlOrUP72THlgR4jwE++bA0q3ewQzNMd2Xj42jd/4wuUYonPySq89wIQ9hhGDCs f3W2e9BtGgRGQx+tqT7nxJAccNCZpeILFxR3zhWFGDC/Eql2KX898K5hi7bDL5jheeTi BerJ3hQJ81ueI27wWN/2chtzCAn1TtbnwGDq5k5bsUGIDX89wRgcjUKo+ZxwqALJ0nRv m9Iczfu2jgsntRlq6dBnxM3PbANSUsQaXiJQfY8q1C4ekfbSxYJAAoRBLJAyBQ9eYgSn G89w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706450869; x=1707055669; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=BxfuvO+vD6eAWW69GthCQX48zsB7UMkd9x61mccDZ48=; b=ulb2qykdO+0KENV8AiFhF+adJjEhzvs2pFbCGFwpIcl0w0mxTF8ooyCcUPsLe8LG8o ybrH0MQda8GTW0lL7vkuvRgT03ecDVVOVIISLEiWltDOVXO0gUjKSdjhFQ0Lwv0Y/mda r39O7x6ybwhahMT8vUufBB6w/0cGJsu3FgzTyDr7y3FTpVPLLsZVhBjH323haBuFnDVy 91eS+Hv5O2MmGy8ZtCNaTH5kZ2xhY0Bfqzh3u2je2KXtp4J0t4YuRdBjcSg0iPh24QR/ UevbkBIlf06Bt/mKLVnVKfL3J3CJeONvfcPyeMUohsctXdws0VnN3hRNAvXMgDT1Y8K4 Ik1w== X-Gm-Message-State: AOJu0YyZK96dSVOUkZj979oFFaOPjm/D82Yf3rSW2W3Cp7Tbxj5IBpUe VjdoHvRljBHg6denpnNeYSXz2R1I0+vvPCogWGSI/tAX7nhbUxyJopZBxjfp X-Received: by 2002:a05:6000:1563:b0:33a:ed51:5cda with SMTP id 3-20020a056000156300b0033aed515cdamr574954wrz.4.1706450869053; Sun, 28 Jan 2024 06:07:49 -0800 (PST) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id d2-20020adf9c82000000b0033929310ae4sm5694734wre.73.2024.01.28.06.07.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 28 Jan 2024 06:07:48 -0800 (PST) From: Iain Sandoe X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Cc: jakub@redhat.com Subject: [PATCH 2/2] libgcc: Make heap trampoline support dynamic [PR113403]. Date: Sun, 28 Jan 2024 14:07:33 +0000 Message-Id: <20240128140733.94198-3-iain@sandoe.co.uk> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20240128140733.94198-2-iain@sandoe.co.uk> References: <20240128140733.94198-1-iain@sandoe.co.uk> <20240128140733.94198-2-iain@sandoe.co.uk> MIME-Version: 1.0 X-Spam-Status: No, score=-8.5 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, T_SCC_BODY_TEXT_LINE 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: , Reply-To: iain@sandoe.co.uk Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789343474167883807 X-GMAIL-MSGID: 1789343478494730492 In order to handle system security constraints during GCC build and test and that most platform versions cannot link to libgcc_eh since the unwinder there is incompatible with the system one. 1. We make the support functions weak definitions. 2. We include them as a CRT for platform conditions that do not allow libgcc_eh. 3. We ensure that the weak symbols are exported from DSOs (which includes exes on Darwin) so that the dynamic linker will pick one instance (which avoids duplication of trampoline caches). PR libgcc/113403 gcc/ChangeLog: * config/darwin.h (DARWIN_SHARED_WEAK_ADDS, DARWIN_WEAK_CRTS): New. (REAL_LIBGCC_SPEC): Move weak CRT handling to separate spec. * config/i386/darwin.h (DARWIN_HEAP_T_LIB): New. * config/i386/darwin32-biarch.h (DARWIN_HEAP_T_LIB): New. * config/i386/darwin64-biarch.h (DARWIN_HEAP_T_LIB): New. * config/rs6000/darwin.h (DARWIN_HEAP_T_LIB): New. libgcc/ChangeLog: * config.host: Build libheap_t.a for i686/x86_64 Darwin. * config/aarch64/heap-trampoline.c (HEAP_T_ATTR): New. (allocate_tramp_ctrl): Allow a target to build this as a weak def. (__gcc_nested_func_ptr_created): Likewise. * config/i386/heap-trampoline.c (HEAP_T_ATTR): New. (allocate_tramp_ctrl): Allow a target to build this as a weak def. (__gcc_nested_func_ptr_created): Likewise. * config/t-darwin: Build libheap_t.a (a CRT with heap trampoline support). --- gcc/config/darwin.h | 43 ++++++++++++++++--------- gcc/config/i386/darwin.h | 2 ++ gcc/config/i386/darwin32-biarch.h | 3 ++ gcc/config/i386/darwin64-biarch.h | 3 ++ gcc/config/rs6000/darwin.h | 3 ++ libgcc/config.host | 7 ++-- libgcc/config/aarch64/heap-trampoline.c | 8 +++++ libgcc/config/i386/heap-trampoline.c | 8 +++++ libgcc/config/t-darwin | 13 ++++++++ 9 files changed, 72 insertions(+), 18 deletions(-) diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index cb96d67b3b1..31019a0c49d 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -314,13 +314,17 @@ extern GTY(()) int darwin_ms_struct; # define DARWIN_RPATH_LINK \ "%{!r:%{!nostdlib:%{!nodefaultrpaths:%(darwin_rpaths)}}}" # define DARWIN_SHARED_LIBGCC "-lgcc_s.1.1" +# define DARWIN_SHARED_WEAK_ADDS " " #else # define DARWIN_RPATH_LINK "" # define DARWIN_SHARED_LIBGCC \ -"%:version-compare(!> 10.11 mmacosx-version-min= -lgcc_s.1.1) \ - %:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w) " +"%:version-compare(!> 10.11 mmacosx-version-min= -lgcc_s.1.1)" +# define DARWIN_SHARED_WEAK_ADDS \ +"%{%:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w): \ + " DARWIN_HEAP_T_LIB "}" #endif + /* We might elect to add a path even when this compiler does not use embedded run paths, so that we can use libraries from an alternate compiler that is using embedded runpaths. */ @@ -398,7 +402,9 @@ extern GTY(()) int darwin_ms_struct; %{e*} %{r} \ %{o*}%{!o:-o a.out} \ %{!r:%{!nostdlib:%{!nostartfiles:%S}}} \ - %{L*} %(link_libgcc) %o \ + %{L*} %(link_libgcc) \ + %{!r:%{!nostdlib:%{!nodefaultlibs: " DARWIN_WEAK_CRTS "}}} \ + %o \ %{!r:%{!nostdlib:%{!nodefaultlibs:\ %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} \ %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): \ @@ -412,15 +418,15 @@ extern GTY(()) int darwin_ms_struct; %(link_ssp) \ %:version-compare(>< 10.6 10.7 mmacosx-version-min= -ld10-uwfef) \ %(link_gcc_c_sequence) \ - %{!nodefaultexport:%{dylib|dynamiclib|bundle: \ - %:version-compare(>= 10.11 asm_macosx_version_min= -U) \ - %:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_get_address) \ - %:version-compare(>= 10.11 asm_macosx_version_min= -exported_symbol) \ - %:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_get_address) \ - %:version-compare(>= 10.11 asm_macosx_version_min= -U) \ - %:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_register_common) \ - %:version-compare(>= 10.11 asm_macosx_version_min= -exported_symbol) \ - %:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_register_common) \ + %{!nodefaultexport: \ + %{%:version-compare(>= 10.11 asm_macosx_version_min= -U): \ + ___emutls_get_address -exported_symbol ___emutls_get_address \ + -U ___emutls_register_common \ + -exported_symbol ___emutls_register_common \ + -U ___gcc_nested_func_ptr_created \ + -exported_symbol ___gcc_nested_func_ptr_created \ + -U ___gcc_nested_func_ptr_deleted \ + -exported_symbol ___gcc_nested_func_ptr_deleted \ }} \ }}}\ %{!r:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} %{F*} "\ @@ -542,16 +548,21 @@ extern GTY(()) int darwin_ms_struct; #undef REAL_LIBGCC_SPEC #define REAL_LIBGCC_SPEC \ "%{static-libgcc|static: \ - %:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh) \ - %:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w); \ + %:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh); \ shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime: \ " DARWIN_SHARED_LIBGCC " \ %:version-compare(!> 10.3.9 mmacosx-version-min= -lgcc_eh) \ %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4) \ - %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5); \ - : -lemutls_w \ + %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5) \ } -lgcc " +#define DARWIN_WEAK_CRTS \ +"%{static-libgcc|static: \ + %{%:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w): \ + " DARWIN_HEAP_T_LIB "} ; \ + : -lemutls_w " DARWIN_HEAP_T_LIB " \ + }" + /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */ #undef STARTFILE_SPEC diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h index b7814f7c42e..8e64b4e9b5f 100644 --- a/gcc/config/i386/darwin.h +++ b/gcc/config/i386/darwin.h @@ -119,6 +119,8 @@ along with GCC; see the file COPYING3. If not see /* We default to x86_64 for single-arch builds, bi-arch overrides. */ #define DARWIN_ARCH_SPEC "x86_64" #define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC +#undef DARWIN_HEAP_T_LIB +#define DARWIN_HEAP_T_LIB " -lheapt_w " #endif #undef SUBTARGET_EXTRA_SPECS diff --git a/gcc/config/i386/darwin32-biarch.h b/gcc/config/i386/darwin32-biarch.h index 051ad12b425..2180f5a5352 100644 --- a/gcc/config/i386/darwin32-biarch.h +++ b/gcc/config/i386/darwin32-biarch.h @@ -27,6 +27,9 @@ along with GCC; see the file COPYING3. If not see #undef DARWIN_SUBARCH_SPEC #define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC +#undef DARWIN_HEAP_T_LIB +#define DARWIN_HEAP_T_LIB " %{m64:-lheapt_w}" + #undef SUBTARGET_EXTRA_SPECS #define SUBTARGET_EXTRA_SPECS \ DARWIN_EXTRA_SPECS \ diff --git a/gcc/config/i386/darwin64-biarch.h b/gcc/config/i386/darwin64-biarch.h index 85436791a6c..620800749a8 100644 --- a/gcc/config/i386/darwin64-biarch.h +++ b/gcc/config/i386/darwin64-biarch.h @@ -28,6 +28,9 @@ along with GCC; see the file COPYING3. If not see #undef DARWIN_SUBARCH_SPEC #define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC +#undef DARWIN_HEAP_T_LIB +#define DARWIN_HEAP_T_LIB "%{!m32:-lheapt_w}" + #undef SUBTARGET_EXTRA_SPECS #define SUBTARGET_EXTRA_SPECS \ DARWIN_EXTRA_SPECS \ diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h index b264284100f..e8b194982b4 100644 --- a/gcc/config/rs6000/darwin.h +++ b/gcc/config/rs6000/darwin.h @@ -113,6 +113,9 @@ -lSystem \ }" +#undef DARWIN_HEAP_T_LIB +#define DARWIN_HEAP_T_LIB " " + /* We want -fPIC by default, unless we're using -static to compile for the kernel or some such. The "-faltivec" option should have been called "-maltivec" all along. */ diff --git a/libgcc/config.host b/libgcc/config.host index 017fbc7a06d..3e7d00f67aa 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -715,12 +715,15 @@ hppa*-*-netbsd*) i[34567]86-*-darwin*) tmake_file="$tmake_file i386/t-crtpc t-crtfm i386/t-msabi" tm_file="$tm_file i386/darwin-lib.h" - extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o" + extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o" + extra_parts="$extra_parts crtfastmath.o libheapt_w.a" + tmake_file="${tmake_file} i386/t-heap-trampoline" ;; x86_64-*-darwin*) tmake_file="$tmake_file i386/t-crtpc t-crtfm i386/t-msabi" tm_file="$tm_file i386/darwin-lib.h" - extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o" + extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o" + extra_parts="$extra_parts crtfastmath.o libheapt_w.a" tmake_file="${tmake_file} i386/t-heap-trampoline" ;; i[34567]86-*-elfiamcu) diff --git a/libgcc/config/aarch64/heap-trampoline.c b/libgcc/config/aarch64/heap-trampoline.c index 2041fe6aa39..b463399c1e9 100644 --- a/libgcc/config/aarch64/heap-trampoline.c +++ b/libgcc/config/aarch64/heap-trampoline.c @@ -15,6 +15,12 @@ #include #endif +/* HEAP_T_ATTR is provided to allow targets to build the exported functions + as weak definitions. */ +#ifndef HEAP_T_ATTR +# define HEAP_T_ATTR +#endif + void *allocate_trampoline_page (void); int get_trampolines_per_page (void); struct tramp_ctrl_data *allocate_tramp_ctrl (struct tramp_ctrl_data *parent); @@ -107,6 +113,7 @@ allocate_tramp_ctrl (struct tramp_ctrl_data *parent) return p; } +HEAP_T_ATTR void __gcc_nested_func_ptr_created (void *chain, void *func, void **dst) { @@ -154,6 +161,7 @@ __gcc_nested_func_ptr_created (void *chain, void *func, void **dst) *dst = &trampoline->insns; } +HEAP_T_ATTR void __gcc_nested_func_ptr_deleted (void) { diff --git a/libgcc/config/i386/heap-trampoline.c b/libgcc/config/i386/heap-trampoline.c index 726cf55277a..4e069c458a7 100644 --- a/libgcc/config/i386/heap-trampoline.c +++ b/libgcc/config/i386/heap-trampoline.c @@ -15,6 +15,12 @@ #include #endif +/* HEAP_T_ATTR is provided to allow targets to build the exported functions + as weak definitions. */ +#ifndef HEAP_T_ATTR +# define HEAP_T_ATTR +#endif + void *allocate_trampoline_page (void); int get_trampolines_per_page (void); struct tramp_ctrl_data *allocate_tramp_ctrl (struct tramp_ctrl_data *parent); @@ -107,6 +113,7 @@ allocate_tramp_ctrl (struct tramp_ctrl_data *parent) return p; } +HEAP_T_ATTR void __gcc_nested_func_ptr_created (void *chain, void *func, void **dst) { @@ -154,6 +161,7 @@ __gcc_nested_func_ptr_created (void *chain, void *func, void **dst) *dst = &trampoline->insns; } +HEAP_T_ATTR void __gcc_nested_func_ptr_deleted (void) { diff --git a/libgcc/config/t-darwin b/libgcc/config/t-darwin index a3bb70c6a0a..0f65b54a230 100644 --- a/libgcc/config/t-darwin +++ b/libgcc/config/t-darwin @@ -51,5 +51,18 @@ LIB2ADDEH = $(srcdir)/unwind-dw2.c \ # Do not build a shared unwind lib by default. LIBEHSOBJS= +# Make heap trampoline helpers weak definitions so that we can merge them from +# multiple DSOs. +heap-trampoline.o: HOST_LIBGCC2_CFLAGS += \ + -DHEAP_T_ATTR='__attribute__((__weak__,__visibility__("default")))' +heap-trampoline_s.o: HOST_LIBGCC2_CFLAGS += \ + -DHEAP_T_ATTR='__attribute__((__weak__,__visibility__("default")))' + +# Make a heap trampoline support CRT so that it can be linked optionally, use +# the shared version so that we can link with DSOs. +libheapt_w.a: heap-trampoline_s.o + $(AR_CREATE_FOR_TARGET) $@ $< + $(RANLIB_FOR_TARGET) $@ + # Symbols for all the sub-ports. SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/libgcc-libsystem.ver