From patchwork Mon Oct 31 15:44:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Engel X-Patchwork-Id: 13294 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2386308wru; Mon, 31 Oct 2022 08:47:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM59HYjm423Va3nbHZzY/qK+Rq+ncKGLpve1D+5ybyhEJJ2SUQ7XECVnhAECF6S9njFnccAV X-Received: by 2002:a05:6402:414d:b0:451:73f0:e113 with SMTP id x13-20020a056402414d00b0045173f0e113mr14378867eda.207.1667231263882; Mon, 31 Oct 2022 08:47:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667231263; cv=none; d=google.com; s=arc-20160816; b=J3XXYx1807rG1wnCdoBhz6qry33NBsNHZ8wSHv4BIurShtgaWldSFzqrQnAGtERhoe Y+5zTMZRfCDIF9jyvSw+trN4TM1eUub8EcWty60nIS1EVQhJH7C8ciPHeAWd6VEs1Ab1 nSOpCQy9W3fmoiLDpnM3azND4KnYNM4nFI+Ym8WM3X6pIEa3TSddKNFZ7aNFThjj1lax 7ctr0mmz/EY+T4HrMFTLYjKu/AoJ6X65Ywi2nLXL1Yzkx/6zUWNCDsS35VuKt4Apxh6o 7Oo0xpa/qH0XUonOe1qrwxhzxwHLpLJGV4uuupCW5g9KGOX8/ECm+rcaAyxg1A4Q3pTv 80Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :feedback-id:dkim-signature:dkim-signature:dmarc-filter:delivered-to; bh=6EmkKw0mTIVn397/NlTflDaQBN1NMN7l1yXLeXHod0E=; b=ksg+hx819CqVZx1o6cVhPX51Ekqwd0h4iZRdt+cDmbuLcjfHkvMJ5ZyfZxthF/YRa7 yMuVqKvJ4Ck8+cWt+dJD9MZ25ygadEAN2uJIXmzwq1w3pzUOM4zzp1p7yKhG1Blb2AW6 IGC3G8aW6abWHkEVDSvjyB60CjjRstUH/+chDAhiCVrmglh9DPQQO0v1VZkWyZ5UWMRS lrM1glJZUip9WmZG7tx0oJW9az9mjBBbFcC37P1CJ7ldVb6ih3d8Vaid0Wr+AWF2cJ0O PTbFangyjHpqUtaV7wawGBuEbrgDNFXgd7157qP7gSZRPQ/9blMM1wNI7E5LRxioqnmg pvaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@danielengel.com header.s=fm1 header.b=wRHXFyPs; dkim=fail header.i=@messagingengine.com header.s=fm3 header.b=tLPIn8+5; 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" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r11-20020aa7c14b000000b00458cbb6b6easi7585458edp.167.2022.10.31.08.47.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 08:47:43 -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=fail header.i=@danielengel.com header.s=fm1 header.b=wRHXFyPs; dkim=fail header.i=@messagingengine.com header.s=fm3 header.b=tLPIn8+5; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3CC7C384B12B for ; Mon, 31 Oct 2022 15:47:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by sourceware.org (Postfix) with ESMTPS id 555343853554 for ; Mon, 31 Oct 2022 15:46:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 555343853554 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=danielengel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=danielengel.com Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 3EA8532002E8; Mon, 31 Oct 2022 11:46:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 31 Oct 2022 11:46:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=danielengel.com; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1667231167; x= 1667317567; bh=6EmkKw0mTIVn397/NlTflDaQBN1NMN7l1yXLeXHod0E=; b=w RHXFyPsleXpouj1wroR4/8Qp5SBruRhQ/C+T9aUCX/OB3D+NM5Jbz6JeZrvy2Az9 2vp3Rl0KpXcPBVsukNVViHwCddwBs2Ee7/Epi4mEBTDAyv13CRe/61P+rip7baX7 NBzWi6BHZ4DnbMi0VuMLoFhKZw+ueM1IPVk7Bty4dyzU9NsrFFmPyxw8qTfZKq// 2aKjRFafu/7LyK9w5NyIue2OG5xjJ4cR/j6yBfq8TGQnaS9qVukgiJhuQybWtbGk /2s6Mjd4DQZVahn+bhmJSFGk9l6lD/EO4YryDONbtSYsGukmofHDUopFYf6Ny1bQ AKI8El8QyIjI2Pu7801aA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1667231167; x=1667317567; bh=6EmkKw0mTIVn3 97/NlTflDaQBN1NMN7l1yXLeXHod0E=; b=tLPIn8+5rW6eoO3K8z48R4jMyvyII JW/7MEy+LKeKk7MqLWidfY9VkJR7x0qDBzihnufH39OWRghnJKw9dqcLvs5+vvgv KFSIhUmYt4w9jlmXx3jfAV1v6VGjA1ZcVp2vym9R/O16C9UzcQrpeNXAx8EtLxOh A2iypecYKimf5JXykVXMLFPT3IvCISL1PIXvgTeGkMaDSUbeFrRQpHoo29/k24+c IK7Ai/NKTLmb6KPVY3i9N6RYf//w01EmOP32OlUjTglZ1Oyzo47nwy58EEmeY5sM 8EHIqKiivQP2PqaRs0qEyLxb4InFI28lwn949UCb2OVMktkaWdWt8r4zA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrudefgdejlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeffrghnihgv lhcugfhnghgvlhcuoehgnhhusegurghnihgvlhgvnhhgvghlrdgtohhmqeenucggtffrrg htthgvrhhnpeeuieekgfegkeekleffkefhleevgfekkeekheeffeevkeehvdduvdfgvdeg heeuhfenucffohhmrghinheplhhisgdufhhunhgtshdrshgsnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepghhnuhesuggrnhhivghlvghnghgv lhdrtghomh X-ME-Proxy: Feedback-ID: i791144d6:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 31 Oct 2022 11:46:07 -0400 (EDT) Received: from ubuntu.lorien.danielengel.com (ubuntu.lorien.danielengel.com [10.0.0.96]) by sendmail.lorien.danielengel.com (8.15.2/8.15.2) with ESMTP id 29VFjxed087232; Mon, 31 Oct 2022 08:45:59 -0700 (PDT) (envelope-from gnu@danielengel.com) From: Daniel Engel To: Richard Earnshaw , gcc-patches@gcc.gnu.org Subject: [PATCH v7 01/34] Add and restructure function declaration macros Date: Mon, 31 Oct 2022 08:44:56 -0700 Message-Id: <20221031154529.3627576-2-gnu@danielengel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221031154529.3627576-1-gnu@danielengel.com> References: <20221031154529.3627576-1-gnu@danielengel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Engel , Christophe Lyon Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748218689864827991?= X-GMAIL-MSGID: =?utf-8?q?1748218689864827991?= Most of these changes support subsequent patches in this series. Particularly, the FUNC_START macro becomes part of a new macro chain: * FUNC_ENTRY Common global symbol directives * FUNC_START_SECTION FUNC_ENTRY to start a new
* FUNC_START FUNC_START_SECTION <".text"> The effective definition of FUNC_START is unchanged from the previous version of lib1funcs. See code comments for detailed usage. The new names FUNC_ENTRY and FUNC_START_SECTION were chosen specifically to complement the existing FUNC_START name. Alternate name patterns are possible (such as {FUNC_SYMBOL, FUNC_START_SECTION, FUNC_START_TEXT}), but any change to FUNC_START would require refactoring much of libgcc. Additionally, a parallel chain of new macros supports weak functions: * WEAK_ENTRY * WEAK_START_SECTION * WEAK_START * WEAK_ALIAS Moving the CFI_* macros earlier in the file scope will increase their scope for use in additional functions. gcc/libgcc/ChangeLog: 2022-10-09 Daniel Engel * config/arm/lib1funcs.S: (LLSYM): New macro prefix ".L" for strippable local symbols. (CFI_START_FUNCTION, CFI_END_FUNCTION): Moved earlier in the file. (FUNC_ENTRY): New macro for symbols with no ".section" directive. (WEAK_ENTRY): New macro FUNC_ENTRY + ".weak". (FUNC_START_SECTION): New macro FUNC_ENTRY with
argument. (WEAK_START_SECTION): New macro FUNC_START_SECTION + ".weak". (FUNC_START): Redefined in terms of FUNC_START_SECTION <".text">. (WEAK_START): New macro FUNC_START + ".weak". (WEAK_ALIAS): New macro FUNC_ALIAS + ".weak". (FUNC_END): Moved after FUNC_START macro group. (THUMB_FUNC_START): Moved near the other *FUNC* macros. (THUMB_SYNTAX, ARM_SYM_START, SYM_END): Deleted unused macros. --- libgcc/config/arm/lib1funcs.S | 109 +++++++++++++++++++++------------- 1 file changed, 69 insertions(+), 40 deletions(-) diff --git a/libgcc/config/arm/lib1funcs.S b/libgcc/config/arm/lib1funcs.S index 8c39c9f20a2..a4fa62b3832 100644 --- a/libgcc/config/arm/lib1funcs.S +++ b/libgcc/config/arm/lib1funcs.S @@ -69,11 +69,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define TYPE(x) .type SYM(x),function #define SIZE(x) .size SYM(x), . - SYM(x) #define LSYM(x) .x +#define LLSYM(x) .L##x #else #define __PLT__ #define TYPE(x) #define SIZE(x) #define LSYM(x) x +#define LLSYM(x) x #endif /* Function end macros. Variants for interworking. */ @@ -182,6 +184,16 @@ LSYM(Lend_fde): #endif .endm +.macro CFI_START_FUNCTION + .cfi_startproc + .cfi_remember_state +.endm + +.macro CFI_END_FUNCTION + .cfi_restore_state + .cfi_endproc +.endm + /* Don't pass dirn, it's there just to get token pasting right. */ .macro RETLDM regs=, cond=, unwind=, dirn=ia @@ -324,10 +336,6 @@ LSYM(Lend_fde): .endm #endif -.macro FUNC_END name - SIZE (__\name) -.endm - .macro DIV_FUNC_END name signed cfi_start __\name, LSYM(Lend_div0) LSYM(Ldiv0): @@ -340,48 +348,76 @@ LSYM(Ldiv0): FUNC_END \name .endm -.macro THUMB_FUNC_START name - .globl SYM (\name) - TYPE (\name) - .thumb_func -SYM (\name): -.endm - /* Function start macros. Variants for ARM and Thumb. */ #ifdef __thumb__ #define THUMB_FUNC .thumb_func #define THUMB_CODE .force_thumb -# if defined(__thumb2__) -#define THUMB_SYNTAX -# else -#define THUMB_SYNTAX -# endif #else #define THUMB_FUNC #define THUMB_CODE -#define THUMB_SYNTAX #endif +.macro THUMB_FUNC_START name + .globl SYM (\name) + TYPE (\name) + .thumb_func +SYM (\name): +.endm + +/* Strong global symbol, ".text" section. + The default macro for function declarations. */ .macro FUNC_START name - .text + FUNC_START_SECTION \name .text +.endm + +/* Weak global symbol, ".text" section. + Use WEAK_* macros to declare a function/object that may be discarded in by + the linker when another library or object exports the same name. + Typically, functions declared with WEAK_* macros implement a subset of + functionality provided by the overriding definition, and are discarded + when the full functionality is required. */ +.macro WEAK_START name + .weak SYM(__\name) + FUNC_START_SECTION \name .text +.endm + +/* Strong global symbol, alternate section. + Use the *_START_SECTION macros for declarations that the linker should + place in a non-defailt section (e.g. ".rodata", ".text.subsection"). */ +.macro FUNC_START_SECTION name section + .section \section,"x" + .align 0 + FUNC_ENTRY \name +.endm + +/* Weak global symbol, alternate section. */ +.macro WEAK_START_SECTION name section + .weak SYM(__\name) + FUNC_START_SECTION \name \section +.endm + +/* Strong global symbol. + Use *_ENTRY macros internal to a function/object body to declare a second + or subsequent entry point without changing the assembler state. + Because there is no alignment specification, these macros should never + replace the *_START_* macros as the first declaration in any object. */ +.macro FUNC_ENTRY name .globl SYM (__\name) TYPE (__\name) - .align 0 THUMB_CODE THUMB_FUNC - THUMB_SYNTAX SYM (__\name): .endm -.macro ARM_SYM_START name - TYPE (\name) - .align 0 -SYM (\name): +/* Weak global symbol. */ +.macro WEAK_ENTRY name + .weak SYM(__\name) + FUNC_ENTRY \name .endm -.macro SYM_END name - SIZE (\name) +.macro FUNC_END name + SIZE (__\name) .endm /* Special function that will always be coded in ARM assembly, even if @@ -447,6 +483,11 @@ SYM (__\name): #endif .endm +.macro WEAK_ALIAS new old + .weak SYM(__\new) + FUNC_ALIAS \new \old +.endm + #ifndef NOT_ISA_TARGET_32BIT .macro ARM_FUNC_ALIAS new old .globl SYM (__\new) @@ -1459,10 +1500,8 @@ LSYM(Lover12): #ifdef L_dvmd_tls #ifdef __ARM_EABI__ - WEAK aeabi_idiv0 - WEAK aeabi_ldiv0 - FUNC_START aeabi_idiv0 - FUNC_START aeabi_ldiv0 + WEAK_START aeabi_idiv0 + WEAK_START aeabi_ldiv0 RET FUNC_END aeabi_ldiv0 FUNC_END aeabi_idiv0 @@ -2170,16 +2209,6 @@ LSYM(Lchange_\register): #endif /* Arch supports thumb. */ -.macro CFI_START_FUNCTION - .cfi_startproc - .cfi_remember_state -.endm - -.macro CFI_END_FUNCTION - .cfi_restore_state - .cfi_endproc -.endm - #ifndef __symbian__ /* The condition here must match the one in gcc/config/arm/elf.h and libgcc/config/arm/t-elf. */