[PATCH 1/1] RISC-V: Correct as --dump-config output for --target=rv64*

Xiao Zeng zengxiao@eswincomputing.com
Mon Jan 6 08:29:04 GMT 2025


2025-01-06 11:01  Nelson Chu <nelson@rivosinc.com> wrote:
>
>Hi Xiao,
>
>Thanks, could we have a testcase for this change :-)
This should have been my responsibility.

>
>Nelson
>
>On Mon, Jan 6, 2025 at 9:15 AM Xiao Zeng <zengxiao@eswincomputing.com>
>wrote:
>
>> gas/ChangeLog:
>>
>>         * config/tc-riscv.c (riscv_target_format): Correct as
>>         --dump-config output for --target=rv64*.
>>
>> Signed-off-by: Xiao Zeng <zengxiao@eswincomputing.com>
>> ---
>>  gas/config/tc-riscv.c | 12 ++++++++++++
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
>> index a915c8b4995..35d19ac4e5d 100644
>> --- a/gas/config/tc-riscv.c
>> +++ b/gas/config/tc-riscv.c
>> @@ -734,6 +734,18 @@ riscv_check_mapping_symbols (bfd *abfd
>> ATTRIBUTE_UNUSED,
>>  const char *
>>  riscv_target_format (void)
>>  {
>> +  /* When as --dump-config is used, xlen is not initialized, resulting in
>> +     bfd-target being set to elf32-*riscv even with --target=rv64*.  */
>> +  if (xlen == 0)
>> +    {
>> +      if (strcmp (default_arch, "riscv32") == 0)
>> +       xlen = 32;
>> +      else if (strcmp (default_arch, "riscv64") == 0)
>> +       xlen = 64;
>> +      else
>> +       as_bad ("unknown default architecture `%s'", default_arch);
>> +    }
>> +
>>    if (target_big_endian)
>>      return xlen == 64 ? "elf64-bigriscv" : "elf32-bigriscv";
>>    else
>> --
>> 2.17.1
>>
>> 
Hi Nelson,  

I've roughly gone through the test cases in gas/testsuite/gas/riscv/*
and found that they cannot achieve the desired testing.
I have outlined the expected test case in: <https://sourceware.org/pipermail/binutils/2025-January/138366.html>.  

Could you please give me some guidance? Thank you!  

Thanks
Xiao Zeng



More information about the Binutils mailing list