[PATCH v2 4/8] mips: Fix issues with removing no-reorder directives

Maciej W. Rozycki macro@orcam.me.uk
Thu Jun 19 04:56:24 GMT 2025


On Wed, 18 Jun 2025, Jovan Dmitrovic wrote:

> 1. Added -O2 to the Makefile to ensure that assembly sources have
>    their delay slots filled.
> 
> 2. Also move the no-reorder directive into the PIC section of the
>    setjmp code.

 These have to be separate changes each.

> diff --git a/sysdeps/mips/Makefile b/sysdeps/mips/Makefile
> index d189973aa0..17ddc2a97c 100644
> --- a/sysdeps/mips/Makefile
> +++ b/sysdeps/mips/Makefile
> @@ -18,9 +18,11 @@ CPPFLAGS-crtn.S += $(pic-ccflag)
>  endif
>  
>  ASFLAGS-.os += $(pic-ccflag)
> +
>  # libc.a and libc_p.a must be compiled with -fPIE/-fpie for static PIE.
>  ASFLAGS-.o += $(pie-default)
>  ASFLAGS-.op += $(pie-default)
> +ASFLAGS += -O2

 Why is it needed given that glibc is always built with optimisation 
enabled?

> diff --git a/sysdeps/mips/bsd-setjmp.S b/sysdeps/mips/bsd-setjmp.S
> index b8f5ef6ca7..4d638216d2 100644
> --- a/sysdeps/mips/bsd-setjmp.S
> +++ b/sysdeps/mips/bsd-setjmp.S
> @@ -28,8 +28,8 @@
>  	.option pic2
>  #endif
>  ENTRY (setjmp)
> -	.set	noreorder
>  #ifdef __PIC__
> +	.set	noreorder
>  	.cpload t9
>  	.set	reorder
>  	la	t9, C_SYMBOL_NAME (__sigsetjmp)

 This is a bug fix and has to go in separately: in the !__PIC__ case the 
delay slot of the final J instruction won't be filled and depending on 
function alignment a random instruction may land there, wreaking havoc.  
This has to be clearly documented with the change.

  Maciej


More information about the Libc-alpha mailing list