From patchwork Wed Jan 17 08:55:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 188724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp778160dye; Wed, 17 Jan 2024 00:56:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGkHJ6sOu+LVAXph5dTPH5llL8pEpjoAJcYl3hfv+76snlHlaIqIaiOO8jNWIh5cwCgwEKp X-Received: by 2002:a05:6214:5098:b0:681:30e7:be9a with SMTP id kk24-20020a056214509800b0068130e7be9amr11173104qvb.31.1705481784778; Wed, 17 Jan 2024 00:56:24 -0800 (PST) Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o5-20020a0c8c45000000b0067f032d7c53si6962500qvb.112.2024.01.17.00.56.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 00:56:24 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20230601 header.b=Rwp6+iap; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (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 786703858C30 for ; Wed, 17 Jan 2024 08:56:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id 7E0343858CDB for ; Wed, 17 Jan 2024 08:55:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7E0343858CDB 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 7E0343858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705481737; cv=none; b=TG8iKen85WJ8V2GH8WluqKULYtS5jHM+xLaaNqI3P255Kb7n4QtJZptygEeIEZ9EdxJTP0uORXtTKSUX9mcE4OjKBg7C+PbsCTaCFiPzCe+j9PabhUqi8SsT6q4aoZV/eexh423CAukx0JLZB1eWqdcw/8jCoiJ0TUcm39ivpCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705481737; c=relaxed/simple; bh=v1V7PMjdbWxZ6YWJjMe9b66oJcPWEPPRVA1Q025s7Bg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=xOaJNUkRvKdzydQPsq45D006a863SgbiPmqmNpuAWnsg78z08RIxH1Ft3zSdUXoHYdSKXZdiGF/2/SMU26ed0KiDhm1ughWuAIsHXDMuuy1R5rtmirRfzz36G5gIb1nfk9ClyQDM5VRq/zbjYS+dZJHXsRCuaW8pzoJ9EHM4xS8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40e76626170so31206215e9.2 for ; Wed, 17 Jan 2024 00:55:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705481733; x=1706086533; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=0o2/fzFSj7M8vFOD99/XeZpTbkKXqLoCLxx+CLTWwRk=; b=Rwp6+iap4/HIvya4qHgrSnYzB/DSZ/JHDIojwmdAJFoXRhPR4YqlbUaaE4Ye6N1w2Z F1U7KuF/7JEsqnVSW7l8mxmIX8nlP5bOY4Q3TIanxXV2a71X9C4H31EV4NoSCZiQJ0q2 x1/OG6fwibw7PtaO7RKJFGIQTyQvcIsyMZhtXdjzQR3oUVkWnKoefU8sy3jXAGN4Pr8j fVvsXWBWK6PoAoEeSy8lESGCRXtnT0C9HR1Yx7M5f95o4RjXoqu1e5rkV8sQZ2e8JsP4 XMBX6X4r4inEy663qbeJyKkyaCJDj/mGzvRV63M1MzRhnhLdWDmEgWciHo64oP/89MDK mywg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705481733; x=1706086533; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0o2/fzFSj7M8vFOD99/XeZpTbkKXqLoCLxx+CLTWwRk=; b=k6MFO66fQjLlqoxlkGTlUOXWidKnJ/CzHg+c7KiGr5bZs6bUl9zuhtleVFktac5Hq3 EWrPPH0028YeCBKIjKqvvmDJyTgtCHOcvtietmgdLqairdrPSNiGIKIRC1f4VlsOzjJv ISpVu+o4+WDTe7QI4AZC23sc/GKmpkRAvBrq/1jhFr6gx/QHmwxIvSfmK6BAU4cXgN6n w1Hu5hxQosh/xGfELTu0Cw3b2c58K4RPMjwkCosTtLZhDApStstg810qlGNUdtEbfU9C ME48bxmVNnQTTuSRT+HtXkTfvnJhzJWCTeSh+TrgcB0QzBgiDAFC7OcbRNjP/+WJ0Qtn 8qUQ== X-Gm-Message-State: AOJu0YzKx1B2gG0nZEkzbnKbVXDP7exIQdFPu+fa1Kf1poxhbC4cZzna L+zA2E8+sLNNzcfX9okzJBLvfwPkrzg= X-Received: by 2002:a7b:cc1a:0:b0:40d:484e:935 with SMTP id f26-20020a7bcc1a000000b0040d484e0935mr4741071wmh.12.1705481732902; Wed, 17 Jan 2024 00:55:32 -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 o31-20020a05600c511f00b0040e703ad630sm12941274wms.22.2024.01.17.00.55.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Jan 2024 00:55:32 -0800 (PST) From: Iain Sandoe X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Cc: jakub@redhat.com Subject: [PATCH v2] Fix __builtin_nested_func_ptr_{created, deleted} symbol versions [PR113402] Date: Wed, 17 Jan 2024 08:55:31 +0000 Message-Id: <20240117085531.21315-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.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: 1788327267791431799 X-GMAIL-MSGID: 1788327267791431799 Tested on x86_64, aarch64 Darwin21 (which default to heap-based trampolines) and on x86_64 Darwin19 and Linux (which default to executable stack trampolines). OK for trunk? Iain --- 8< --- The symbols for the functions supporting heap-based trampolines were exported at an incorrect symbol version, the following patch fixes that. As requested in the PR, this also renames __builtin_nested_func_ptr* to __gcc_nested_func_ptr*. PR libgcc/113402 gcc/ChangeLog: * builtins.def (BUILT_IN_NESTED_PTR_CREATED): Rename __builtin_nested_func_ptr_created to __gcc_nested_func_ptr_created. (BUILT_IN_NESTED_PTR_DELETED): Rename __builtin_nested_func_ptr_deleted to __gcc_nested_func_ptr_deleted. * doc/invoke.texi: Likewise. * tree.cc (build_common_builtin_nodes): Likewise. libgcc/ChangeLog: * config/aarch64/heap-trampoline.c: Rename __builtin_nested_func_ptr_created to __gcc_nested_func_ptr_created and __builtin_nested_func_ptr_deleted to __gcc_nested_func_ptr_deleted. * config/i386/heap-trampoline.c: Likewise. * libgcc2.h: Likewise. * libgcc-std.ver.in (GCC_7.0.0): Likewise and then move __gcc_nested_func_ptr_created and __gcc_nested_func_ptr_deleted from this symbol version to ... (GCC_14.0.0): ... this one. Signed-off-by: Iain Sandoe Co-authored-by: Jakub Jelinek --- gcc/builtins.def | 4 ++-- gcc/doc/invoke.texi | 4 ++-- gcc/tree.cc | 8 ++++---- libgcc/config/aarch64/heap-trampoline.c | 8 ++++---- libgcc/config/i386/heap-trampoline.c | 8 ++++---- libgcc/libgcc-std.ver.in | 5 ++--- libgcc/libgcc2.h | 4 ++-- 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/gcc/builtins.def b/gcc/builtins.def index 4d97ca0eec9..e8a88ee8bf7 100644 --- a/gcc/builtins.def +++ b/gcc/builtins.def @@ -1084,8 +1084,8 @@ DEF_BUILTIN_STUB (BUILT_IN_ADJUST_TRAMPOLINE, "__builtin_adjust_trampoline") DEF_BUILTIN_STUB (BUILT_IN_INIT_DESCRIPTOR, "__builtin_init_descriptor") DEF_BUILTIN_STUB (BUILT_IN_ADJUST_DESCRIPTOR, "__builtin_adjust_descriptor") DEF_BUILTIN_STUB (BUILT_IN_NONLOCAL_GOTO, "__builtin_nonlocal_goto") -DEF_BUILTIN_STUB (BUILT_IN_NESTED_PTR_CREATED, "__builtin_nested_func_ptr_created") -DEF_BUILTIN_STUB (BUILT_IN_NESTED_PTR_DELETED, "__builtin_nested_func_ptr_deleted") +DEF_BUILTIN_STUB (BUILT_IN_NESTED_PTR_CREATED, "__gcc_nested_func_ptr_created") +DEF_BUILTIN_STUB (BUILT_IN_NESTED_PTR_DELETED, "__gcc_nested_func_ptr_deleted") /* Implementing __builtin_setjmp. */ DEF_BUILTIN_STUB (BUILT_IN_SETJMP_SETUP, "__builtin_setjmp_setup") diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 16e31a3c6db..9727f1de71d 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -19450,8 +19450,8 @@ for nested functions. By default, trampolines are generated on stack. However, certain platforms (such as the Apple M1) do not permit an executable stack. Compiling with @option{-ftrampoline-impl=heap} generate calls to -@code{__builtin_nested_func_ptr_created} and -@code{__builtin_nested_func_ptr_deleted} in order to allocate and +@code{__gcc_nested_func_ptr_created} and +@code{__gcc_nested_func_ptr_deleted} in order to allocate and deallocate trampoline space on the executable heap. These functions are implemented in libgcc, and will only be provided on specific targets: x86_64 Darwin, x86_64 and aarch64 Linux. @emph{PLEASE NOTE}: Heap diff --git a/gcc/tree.cc b/gcc/tree.cc index 8aee3ef18d8..6fa99ad7fe4 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -9934,15 +9934,15 @@ build_common_builtin_nodes (void) ptr_type_node, // void *func ptr_ptr_type_node, // void **dst NULL_TREE); - local_define_builtin ("__builtin_nested_func_ptr_created", ftype, + local_define_builtin ("__gcc_nested_func_ptr_created", ftype, BUILT_IN_NESTED_PTR_CREATED, - "__builtin_nested_func_ptr_created", ECF_NOTHROW); + "__gcc_nested_func_ptr_created", ECF_NOTHROW); ftype = build_function_type_list (void_type_node, NULL_TREE); - local_define_builtin ("__builtin_nested_func_ptr_deleted", ftype, + local_define_builtin ("__gcc_nested_func_ptr_deleted", ftype, BUILT_IN_NESTED_PTR_DELETED, - "__builtin_nested_func_ptr_deleted", ECF_NOTHROW); + "__gcc_nested_func_ptr_deleted", ECF_NOTHROW); ftype = build_function_type_list (void_type_node, ptr_type_node, ptr_type_node, NULL_TREE); diff --git a/libgcc/config/aarch64/heap-trampoline.c b/libgcc/config/aarch64/heap-trampoline.c index f22233987ca..2041fe6aa39 100644 --- a/libgcc/config/aarch64/heap-trampoline.c +++ b/libgcc/config/aarch64/heap-trampoline.c @@ -20,8 +20,8 @@ int get_trampolines_per_page (void); struct tramp_ctrl_data *allocate_tramp_ctrl (struct tramp_ctrl_data *parent); void *allocate_trampoline_page (void); -void __builtin_nested_func_ptr_created (void *chain, void *func, void **dst); -void __builtin_nested_func_ptr_deleted (void); +void __gcc_nested_func_ptr_created (void *chain, void *func, void **dst); +void __gcc_nested_func_ptr_deleted (void); #if defined(__gnu_linux__) static const uint32_t aarch64_trampoline_insns[] = { @@ -108,7 +108,7 @@ allocate_tramp_ctrl (struct tramp_ctrl_data *parent) } void -__builtin_nested_func_ptr_created (void *chain, void *func, void **dst) +__gcc_nested_func_ptr_created (void *chain, void *func, void **dst) { if (tramp_ctrl_curr == NULL) { @@ -155,7 +155,7 @@ __builtin_nested_func_ptr_created (void *chain, void *func, void **dst) } void -__builtin_nested_func_ptr_deleted (void) +__gcc_nested_func_ptr_deleted (void) { if (tramp_ctrl_curr == NULL) abort (); diff --git a/libgcc/config/i386/heap-trampoline.c b/libgcc/config/i386/heap-trampoline.c index 4b9f4365868..726cf55277a 100644 --- a/libgcc/config/i386/heap-trampoline.c +++ b/libgcc/config/i386/heap-trampoline.c @@ -20,8 +20,8 @@ int get_trampolines_per_page (void); struct tramp_ctrl_data *allocate_tramp_ctrl (struct tramp_ctrl_data *parent); void *allocate_trampoline_page (void); -void __builtin_nested_func_ptr_created (void *chain, void *func, void **dst); -void __builtin_nested_func_ptr_deleted (void); +void __gcc_nested_func_ptr_created (void *chain, void *func, void **dst); +void __gcc_nested_func_ptr_deleted (void); static const uint8_t trampoline_insns[] = { /* movabs $,%r11 */ @@ -108,7 +108,7 @@ allocate_tramp_ctrl (struct tramp_ctrl_data *parent) } void -__builtin_nested_func_ptr_created (void *chain, void *func, void **dst) +__gcc_nested_func_ptr_created (void *chain, void *func, void **dst) { if (tramp_ctrl_curr == NULL) { @@ -155,7 +155,7 @@ __builtin_nested_func_ptr_created (void *chain, void *func, void **dst) } void -__builtin_nested_func_ptr_deleted (void) +__gcc_nested_func_ptr_deleted (void) { if (tramp_ctrl_curr == NULL) abort (); diff --git a/libgcc/libgcc-std.ver.in b/libgcc/libgcc-std.ver.in index a81c5a1142c..ac8f661a08e 100644 --- a/libgcc/libgcc-std.ver.in +++ b/libgcc/libgcc-std.ver.in @@ -1943,9 +1943,6 @@ GCC_4.8.0 { GCC_7.0.0 { __PFX__divmoddi4 __PFX__divmodti4 - - __builtin_nested_func_ptr_created - __builtin_nested_func_ptr_deleted } %inherit GCC_14.0.0 GCC_7.0.0 @@ -1960,4 +1957,6 @@ GCC_14.0.0 { __PFX__strub_enter __PFX__strub_update __PFX__strub_leave + __gcc_nested_func_ptr_created + __gcc_nested_func_ptr_deleted } diff --git a/libgcc/libgcc2.h b/libgcc/libgcc2.h index 5050456eada..0b67fab637e 100644 --- a/libgcc/libgcc2.h +++ b/libgcc/libgcc2.h @@ -29,8 +29,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #pragma GCC visibility push(default) #endif -extern void __builtin_nested_func_ptr_created (void *, void *, void **); -extern void __builtin_nested_func_ptr_deleted (void); +extern void __gcc_nested_func_ptr_created (void *, void *, void **); +extern void __gcc_nested_func_ptr_deleted (void); extern int __gcc_bcmp (const unsigned char *, const unsigned char *, size_t); extern void __clear_cache (void *, void *);