[PATCH] RISC-V: Clear EF_RISCV_RVC/EF_RISCV_TSO when RVC/TSO is disabled using .attribute arch
Yu-Cheng Liang
yclwlcy@gmail.com
Tue Nov 12 02:07:50 GMT 2024
Thanks for the clarification. However, I want to know if it could
cause confusion for users when they build binutils with RVC/TSO added
to the default architecture attributes, as disabling RVC/TSO using
-march and .attribute arch results in different EF_RISCV_RVC/TSO
values (-march sets EF_RISCV_RVC/TSO to 0, while .attribute arch sets
it to 1).
Yu-Cheng
On Tue, Nov 12, 2024 at 9:37 AM Nelson Chu <nelson@rivosinc.com> wrote:
>
> 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.
>
> Nelson
>
> On Mon, Nov 11, 2024 at 5:17 PM Jan Beulich <jbeulich@suse.com> wrote:
>>
>> 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