libgloss: mips: Support Lite Exit in crt0

Message ID 8e3fc031-e6a3-40b6-a9b7-209b64fcf1af@gmail.com
State New
Headers
Series libgloss: mips: Support Lite Exit in crt0 |

Commit Message

Spencer Alves Dec. 19, 2025, 7:49 p.m. UTC
  From: Spencer Alves <impiaaa@gmail.com>

Based on the equivalent code in ARM
---
 libgloss/mips/hal/crt0.S | 11 +++++++++++
 1 file changed, 11 insertions(+)
  

Comments

Corinna Vinschen Dec. 22, 2025, 11:57 a.m. UTC | #1
On Dec 19 11:49, Spencer Alves wrote:
> 
> From: Spencer Alves <impiaaa@gmail.com>
> 
> Based on the equivalent code in ARM
> ---
>  libgloss/mips/hal/crt0.S | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/libgloss/mips/hal/crt0.S b/libgloss/mips/hal/crt0.S
> index ac6e614df..8ca028402 100644
> --- a/libgloss/mips/hal/crt0.S
> +++ b/libgloss/mips/hal/crt0.S
> @@ -225,10 +225,21 @@ init:
>  	beq	t9,zero,1f
>  	jalr	t9
>  1:
> +#ifdef _LITE_EXIT
> +	# Make reference to atexit weak to avoid unconditionally pulling in
> +	# support code.  Refer to comments in __atexit.c for more details.
> +	.weak	atexit
> +	LA	t9, atexit
> +	beq	t9,zero,.Lweak_atexit
> +	.weak	_fini
> +#endif
>  	/* Register exit handlers */
>  	LA	a0, _fini
>  	jal	atexit
>  
> +#ifdef _LITE_EXIT
> +.Lweak_atexit:
> +#endif
>  	/* run global constructors */
>  	jal	_init
>  
> -- 
> 2.51.0

Pushed.

Thanks,
Corinna
  

Patch

diff --git a/libgloss/mips/hal/crt0.S b/libgloss/mips/hal/crt0.S
index ac6e614df..8ca028402 100644
--- a/libgloss/mips/hal/crt0.S
+++ b/libgloss/mips/hal/crt0.S
@@ -225,10 +225,21 @@  init:
 	beq	t9,zero,1f
 	jalr	t9
 1:
+#ifdef _LITE_EXIT
+	# Make reference to atexit weak to avoid unconditionally pulling in
+	# support code.  Refer to comments in __atexit.c for more details.
+	.weak	atexit
+	LA	t9, atexit
+	beq	t9,zero,.Lweak_atexit
+	.weak	_fini
+#endif
 	/* Register exit handlers */
 	LA	a0, _fini
 	jal	atexit
 
+#ifdef _LITE_EXIT
+.Lweak_atexit:
+#endif
 	/* run global constructors */
 	jal	_init