[PATCH] RISC-V: Clear EF_RISCV_RVC/EF_RISCV_TSO when RVC/TSO is disabled using .attribute arch

Jan Beulich jbeulich@suse.com
Mon Nov 11 09:16:13 GMT 2024


On 11.11.2024 09:49, Yu-Cheng Liang wrote:
> If we enable RVC/TSO using -march and disable RVC/TSO using .attribute
> arch, EF_RISCV_RVC/EF_RISCV_TSO won't be cleared in the current
> implementation.

Right, but isn't that what is wanted? Don't the flags have the meaning
"used anywhere in the object" rather than "used throughout the object"?

Jan

> --- a/gas/config/tc-riscv.c
> +++ b/gas/config/tc-riscv.c
> @@ -5666,7 +5666,13 @@ s_riscv_attribute (int ignored ATTRIBUTE_UNUSED)
>        old_xlen = xlen;
>        attr = elf_known_obj_attributes_proc (stdoutput);
>        if (!start_assemble)
> -       riscv_set_arch (attr[Tag_RISCV_arch].s);
> +       {
> +         riscv_set_arch (attr[Tag_RISCV_arch].s);
> +         if (!riscv_opts.rvc)
> +           elf_flags &= ~(EF_RISCV_RVC);
> +         if (!riscv_subset_supports (&riscv_rps_as, "ztso"))
> +           elf_flags &= ~(EF_RISCV_TSO);
> +       }
>        else
>          as_fatal (_("architecture elf attributes must set before "
>                      "any instructions"));
> --
> 2.45.2



More information about the Binutils mailing list