[PATCH v3 1/6] mips: Restrict the use of addiupc for microMIPSr6

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Wed Sep 17 20:10:44 GMT 2025



On 03/09/25 10:53, Jovan Dmitrovic wrote:
> For microMIPSr6, even though the ADDIUPC instruction is supported,
> it requires for the address to be 4-byte aligned, which might not
> be the case in all scenarios.

The looks ok, although it is not clear to me if this is actually tested
since it seems that mipsisa64r6el does not support -mmicromips. Should
we add a mipsisa64r5el-linux-gnu target to build-many-glibcs.py?

As a side note, it seems that mips16 is broken with --enable-profile
or a long time and since 2.34 (035c012e32c11e84d64905efaf55e74f704d3668)
without it:

$ mips64-glibc-linux-gnu-gcc -mabi=32 -mips16 ../sysdeps/mips/start.S
[...]
libc/build/mips-linux-gnu-mips16/csu/start.o
../sysdeps/mips/start.S: Assembler messages:
../sysdeps/mips/start.S:147: Error: invalid operands `sw $0,16($sp)'
[...]

Should we remove mips16 support?

> ---
>  sysdeps/mips/dl-machine.h | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h
> index 560bf1396c..0187541f3e 100644
> --- a/sysdeps/mips/dl-machine.h
> +++ b/sysdeps/mips/dl-machine.h
> @@ -131,12 +131,11 @@ elf_machine_load_address (void)
>         "	" STRINGXP (PTR_LA) " %0, 0f\n"
>  # if !defined __mips_isa_rev || __mips_isa_rev < 6
>         "	bltzal $0, 0f\n"
> -       "	nop\n"
> -       "0:	" STRINGXP (PTR_SUBU) " %0, $31, %0\n"
>  # else
> -       "0:	addiupc $31, 0\n"
> -       "	" STRINGXP (PTR_SUBU) " %0, $31, %0\n"
> +       "	bal 0f\n"
>  # endif
> +       "	nop\n"
> +       "0:	" STRINGXP (PTR_SUBU) " %0, $31, %0\n"
>         "	.set reorder\n"
>         :	"=r" (addr)
>         :	/* No inputs */
> @@ -237,7 +236,9 @@ do {									\
>        and not just plain _start.  */
>  
>  #ifndef __mips16
> -# if !defined __mips_isa_rev || __mips_isa_rev < 6
> +/* Although microMIPSr6 has an ADDIUPC instruction, it must be 4-byte aligned
> +   for the address calculation to be valid.  */
> +# if !defined __mips_isa_rev || __mips_isa_rev < 6 || defined __mips_micromips
>  #  define LCOFF STRINGXP(.Lcof2)
>  #  define LOAD_31 STRINGXP(bltzal $8) "," STRINGXP(.Lcof2)
>  # else



More information about the Libc-alpha mailing list