[PATCH 1/2] RISC-V: Stop generating mapping symbol $x, replace with $x<isa>.

Jan Beulich jbeulich@suse.com
Fri Feb 21 08:27:11 GMT 2025


On 21.02.2025 07:33, Nelson Chu wrote:
> --- a/gas/config/tc-riscv.c
> +++ b/gas/config/tc-riscv.c
> @@ -539,7 +539,12 @@ make_mapping_symbol (enum riscv_seg_mstate state,
>  	  name = buff;
>  	}
>        else
> -	name = "$x";
> +	{
> +	  /* The $x without isa shouldn't be generated since it will put more
> +	     burden on the linker when linking objects with different isa.  */
> +	  name = "$x";
> +	  as_warn (_("The mapping symbol $x shouldn't be generated"));
> +	}

What's the user to do about this, if it appears? Isn't this an internal
error?

Also, nit: diagnostics normally don't start with a capital letter.

> @@ -585,11 +590,20 @@ make_mapping_symbol (enum riscv_seg_mstate state,
>  
>    if (odd_data_padding)
>      {
> -      /* If the removed mapping symbol is $x+arch, then add it back to
> -	 the next $x.  */
> -      const char *str = removed != NULL
> -			&& strncmp (S_GET_NAME (removed), "$xrv", 4) == 0
> -			? S_GET_NAME (removed) + 2 : NULL;
> +      /* Search and find the previous $x+isa which in the same frag.  */
> +      const char *str = NULL;
> +      symbolS *p = symbol_previous (symbol);
> +      for (; p != NULL; p = symbol_previous (p))
> +	{
> +	  if (symbol_get_frag (p) == frag
> +	      && S_GET_NAME (p)
> +	      && strncmp (S_GET_NAME (p), "$xrv", 4) == 0
> +	      && S_GET_VALUE (p) <= S_GET_VALUE (symbol))
> +	    {
> +	      str = S_GET_NAME (p) + 2;
> +	      break;
> +	    }
> +	}
>        make_mapping_symbol (MAP_INSN, frag->fr_fix + 1, frag, str,
>  			   false/* odd_data_padding */);

Are there any guarantees that str will not end up as NULL here? I.e. that
such a "previous $x+isa" will be found?

Jan


More information about the Binutils mailing list