This is PR35223.
r317406 stopped merging SHF_MERGE sections when -r is given.
Previously we used Alignment, Flags and section Name together to
generate a complex key for merging sections. For -r case all 3 were used,
but for regular case we merged sections by name only for a long time
and r317406 changed behavior to merge sections by name for all outputs,
that allowed to simplify code and sped up linker a bit.
But above broke -relocatable output in sence that tools like dwarfdump (both gnu
and llvm one) expects to see single .debug_str section in output.
After the r317406 we started producing unique output section for each input
and tools are upset.
I suggest to allow relocatable output to merge SHF_MERGE strings sections.
In case when input sections has different sh_entsize, I think we can just drop
the SHF_MERGE flag and merge them. That looks consistent with what ld.bfd
do and should not be an issue, because I believe normally string sections
always have sh_entsize = 1. llvm-mc even ignores any values explicitly set for .debug_str
sh_entsize and renders 1 to output, though gas allows different values.