From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id C8DBD3858D35 for ; Tue, 8 Mar 2022 18:59:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C8DBD3858D35 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 314CF1516; Tue, 8 Mar 2022 10:59:46 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 738A43FA45; Tue, 8 Mar 2022 10:59:45 -0800 (PST) From: Richard Sandiford To: xuchenghua@loongson.cn Mail-Followup-To: xuchenghua@loongson.cn, gcc-patches@gcc.gnu.org, chenglulu@loongson.cn, joseph@codesourcery.com, richard.sandiford@arm.com Cc: gcc-patches@gcc.gnu.org, chenglulu@loongson.cn, joseph@codesourcery.com Subject: Re: [PATCH v8 08/12] LoongArch Port: libgcc References: <20220304071809.3082015-1-xuchenghua@loongson.cn> <20220304071809.3082015-9-xuchenghua@loongson.cn> Date: Tue, 08 Mar 2022 18:59:44 +0000 In-Reply-To: <20220304071809.3082015-9-xuchenghua@loongson.cn> (xuchenghua@loongson.cn's message of "Fri, 4 Mar 2022 15:18:05 +0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , X-List-Received-Date: Tue, 08 Mar 2022 18:59:48 -0000 xuchenghua@loongson.cn writes: > diff --git a/libgcc/config/loongarch/crti.S b/libgcc/config/loongarch/crti.S > new file mode 100644 > index 00000000000..27b7eab3626 > --- /dev/null > +++ b/libgcc/config/loongarch/crti.S > @@ -0,0 +1,43 @@ > +/* Copyright (C) 2021-2022 Free Software Foundation, Inc. > + > +This file is part of GCC. > + > +GCC is free software; you can redistribute it and/or modify it under > +the terms of the GNU General Public License as published by the Free > +Software Foundation; either version 3, or (at your option) any later > +version. > + > +GCC is distributed in the hope that it will be useful, but WITHOUT ANY > +WARRANTY; without even the implied warranty of MERCHANTABILITY or > +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License > +for more details. > + > +Under Section 7 of GPL version 3, you are granted additional > +permissions described in the GCC Runtime Library Exception, version > +3.1, as published by the Free Software Foundation. > + > +You should have received a copy of the GNU General Public License and > +a copy of the GCC Runtime Library Exception along with this program; > +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > +. */ > + > +/* 4 slots for argument spill area. 1 for cpreturn, 1 for stack. > + Return spill offset of 8. Aligned to 16 bytes for lp64. */ The comment doesn't apply to the Loongson code. Probably best to delete it. Same for crtn.S. > + > + .section .init,"ax",@progbits > + .globl _init > + .type _init,@function > +_init: > + addi.d $r3,$r3,-16 > + st.d $r1,$r3,8 > + addi.d $r3,$r3,16 > + jirl $r0,$r1,0 > + > + .section .fini,"ax",@progbits > + .globl _fini > + .type _fini,@function > +_fini: > + addi.d $r3,$r3,-16 > + st.d $r1,$r3,8 > + addi.d $r3,$r3,16 > + jirl $r0,$r1,0 Are you sure this is right? It looks like it pushes LR and then immediately pops it and returns, which would have the effect of bypassing the rest of the .init and .fini code. The idea instead is that .init starts with the code in crti.S, then contains any .init code linked in from .o files, then ends with the .init code in crtn.S. Same for .fini. Looks good to me otherwise. Thanks, Richard