From patchwork Tue May 21 09:56:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuriy Kolerov X-Patchwork-Id: 90565 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 4402C3858C98 for ; Tue, 21 May 2024 09:59:52 +0000 (GMT) X-Original-To: newlib@sourceware.org Delivered-To: newlib@sourceware.org Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 393FB384AB4B for ; Tue, 21 May 2024 09:58:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 393FB384AB4B 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 393FB384AB4B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716285499; cv=none; b=NQXFRVqIAFAyCvlLHy8Ss9/LcyuxR+XHEkohywd7NSUa0/bac8ZabQjBJguQlNM/EbbqPasiCmXDBGVi5LdYpw5cUP6/Dz6ZtzzBXO2pq3e6iDluyTtYGP2FdS/Bvwn7hFlbCo7/ukCdDedzxp9+IAiX+aRWmfihUXY7ecibx8Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716285499; c=relaxed/simple; bh=kf9zj7i+284oZ5s8j7MhtYAeQKiec0Thy9Xa4KjQii4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=TXvPlYvxgMeKo1317glTEOAvcSBaprtQUiCGmUwgRxu8kz2cJ7FQVEacsmNNN6ExNWUckjtiSx8m5RZ7RdxHkoZ4yStvNDBW2D3Xk8uQ/einX3IR+wvk/tKDxj79JGTtNupMz/qLAemBVMPx1j2OLkfmXWv6Qto+f1PICI9o1uk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-41fd5dc0439so30816745e9.0 for ; Tue, 21 May 2024 02:58:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716285496; x=1716890296; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=waQIoK3N9Tt1MAFHP3fGID6Jgi5AdtA79sQfaoEhFn8=; b=d4xwbsE37m7Q7xxqBz3bxaTO+Sqlf9BUt5oW2mDMrn8cQBu+AlRO5e69EAiUeakcXE E2Ia8daeJDZcCB4OAfLtN2Q/P6A8SzoGplI1T8770LIcbz9aZBruW8Xta5vB2QEU/q5L rcxxjDLLk50qa/8qsWVSD7X2ZIkvy2qyvHfuc0etXkmBjFxZg8KG/qXVe6FxlKlMP/m9 hmYnnPuLMqZXJd1mFtmbVnvCZuhqLaMSA6UxD35L/b+L9Ry2iNw3p3MuIAYnuPJfTpqR kgjQgsfLr+e7qN88YU9AQaAuGi1fSCzVYLpoZ7HWmapNSVyZn0lyp4f11Qb3DGLYzAxq k35g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716285496; x=1716890296; h=content-transfer-encoding:mime-version: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=waQIoK3N9Tt1MAFHP3fGID6Jgi5AdtA79sQfaoEhFn8=; b=rZSpwF4qAXwg5tn6uZBoLhAKdcVgyOQ0uQa41vLLRPgisbpCORO/qMJjwKdqGOc2x6 tZZLSKBlffCA+k+iuA6VdIhxz2xKZk3hRZo6r+URti8xz/wTRemmTBWjLIc/nHZkX50V rvh6zUxx2F/k+nVwbVOOLh4c0W00iYOfDeIJx6ngn7ctg+xMclnsPk+6qlRaeu6JLm21 NxAbexejG6z9GDAsNlP+Yyv1K0aLt8x1HWArC9iHRN/0soQfrxK4XCp/9kQW9rYejFEN UVmrfWoCE0VytQRcPFjNCHPhvBCVijcv56rOpUeRv9bZUEQZmbcD54qfWK+Y1XUAGT2U GG1w== X-Gm-Message-State: AOJu0YzFTlK/d39tIJPwle5QJ4SOCIlk4r3sVeWFIxtCPS8L1LKMMuQv pitBnjns53HpQzC9VJt3H2fjnZF6InjXd3e2uB4eIAD6XoMDZuFmInneQdjy3to= X-Google-Smtp-Source: AGHT+IEr30Ffl30BBT7qHFAzI7Q+2tYhZ/TYYmp4VEvpne2mWHoidbaglTZPvbj76IkVdw75BPKKjg== X-Received: by 2002:a05:600c:5487:b0:41c:ab7:fa0f with SMTP id 5b1f17b1804b1-41feac59ec9mr221363015e9.34.1716285496509; Tue, 21 May 2024 02:58:16 -0700 (PDT) Received: from localhost.localdomain ([2a00:a041:e626:f00:a285:867a:5e98:7729]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-41f87b2653bsm490773635e9.4.2024.05.21.02.58.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 02:58:16 -0700 (PDT) From: kolerov93@gmail.com To: newlib@sourceware.org Cc: shahab@synopsys.com, claziss@gmail.com Subject: [PATCH 07/15] arc: libgloss: Use atexit to setup fini routines Date: Tue, 21 May 2024 10:56:50 +0100 Message-Id: <20240521095658.10311-8-kolerov93@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240521095658.10311-1-kolerov93@gmail.com> References: <20240521095658.10311-1-kolerov93@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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: newlib@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: newlib-bounces+patchwork=sourceware.org@sourceware.org From: Claudiu Zissulescu Use atexit funtion to setup fini routines to be called on exit instead of filling in __atexit structures manually. Signed-off-by: Claudiu Zissulescu --- libgloss/arc/crt0.S | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/libgloss/arc/crt0.S b/libgloss/arc/crt0.S index 235f81028..1999e602b 100644 --- a/libgloss/arc/crt0.S +++ b/libgloss/arc/crt0.S @@ -178,27 +178,12 @@ __start: #endif /* !__ARC601__ */ -; Some targets use the .init and .fini sections to create constructors and -; destructors, and for these targets we need to call the _init function and -; arrange for _fini to be called at program exit. - mov_s r13, r0 - mov_s r14, r1 - ; calling atexit drags in malloc, so instead poke the function - ; address directly into the reent structure - ld r1, [gp, @_impure_ptr@sda] - mov_s r1, @__atexit0 - mov_s r2, @__atexit - st_s r1, [r2, 0] ; __atexit = &__atexit0 - mov_s r0, 1 - st_s r0, [r1, 4] ; __atexit0._ind = 1 - mov_s r0, @_fini - st_s r0, [r1, 8] ; __atexit0._fns[0] = _fini -; branch to _init -#if defined (__ARCEM__) || defined (__ARCHS__) + ;; Call constructors jl @_init -#else - bl @_init -#endif /* __ARCEM__ || __ARCHS__ */ + +;;; Setup fini routines to be called from exit + mov_s r0, @_fini + jl @atexit #ifdef PROFILE_SUPPORT /* Defined in gcrt0.S. */ mov r0,@__start