<div dir="ltr"><div>Yes, "used anywhere in the object" is correct, so we should enable flags as long as they are ever enabled.  I think the comment and code "elf_flags |= value" in the riscv_set_rvc/tso should be clear enough to understand.</div><div><br></div><div>Nelson</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 11, 2024 at 5:17 PM Jan Beulich <<a href="mailto:jbeulich@suse.com">jbeulich@suse.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 11.11.2024 09:49, Yu-Cheng Liang wrote:<br>
> If we enable RVC/TSO using -march and disable RVC/TSO using .attribute<br>
> arch, EF_RISCV_RVC/EF_RISCV_TSO won't be cleared in the current<br>
> implementation.<br>
<br>
Right, but isn't that what is wanted? Don't the flags have the meaning<br>
"used anywhere in the object" rather than "used throughout the object"?<br>
<br>
Jan<br>
<br>
> --- a/gas/config/tc-riscv.c<br>
> +++ b/gas/config/tc-riscv.c<br>
> @@ -5666,7 +5666,13 @@ s_riscv_attribute (int ignored ATTRIBUTE_UNUSED)<br>
>        old_xlen = xlen;<br>
>        attr = elf_known_obj_attributes_proc (stdoutput);<br>
>        if (!start_assemble)<br>
> -       riscv_set_arch (attr[Tag_RISCV_arch].s);<br>
> +       {<br>
> +         riscv_set_arch (attr[Tag_RISCV_arch].s);<br>
> +         if (!riscv_opts.rvc)<br>
> +           elf_flags &= ~(EF_RISCV_RVC);<br>
> +         if (!riscv_subset_supports (&riscv_rps_as, "ztso"))<br>
> +           elf_flags &= ~(EF_RISCV_TSO);<br>
> +       }<br>
>        else<br>
>          as_fatal (_("architecture elf attributes must set before "<br>
>                      "any instructions"));<br>
> --<br>
> 2.45.2<br>
<br>
</blockquote></div></div>