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: 59660 X-Patchwork-Delegate: rearnsha@gcc.gnu.org Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EE8A1386076B for ; Mon, 31 Oct 2022 15:46:55 +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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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. */