Do you maybe have old or modified GNU ld sources?
In ld/emultempl/riscvelf.em, in the function riscv_elf_before_allocation, we have
if (!bfd_link_relocatable (&link_info))
{
/* We always need at least some relaxation to handle code alignment. */
if (RELAXATION_DISABLED_BY_USER)
TARGET_ENABLE_RELAXATION;
else
ENABLE_RELAXATION;
}
so relaxation is only enabled if this is not a relocatable (-r) link. Maybe relaxation is being enabled someplace else? Or maybe this code is broken in your copy? Or maybe /usr/bin/ld is a shell script that is invoking the regular linker with extra options?
Or alternatively, maybe relaxation is being run when it shouldn't be. Try looking at the function that prints the error message, which is bfd/reloc.c in the function bfd_generic_relax_section. Run the linker under gdb, putting a breakpoint there, and try to figure out why you reached the code when you should not.
Jim