-R option has 2 meanings according to spec:
-R filename --just-symbols=filename ..... For compatibility with other ELF linkers, if the -R option is followed by a directory name, rather than a file name, it is treated as the -rpath option. -rpath dir .... For compatibility with other ELF linkers, if the -R option is followed by a directory name, rather than a file name, it is treated as the -rpath option.
Currently we always treat -R as -rpath what confuses users (see comments for PR35067) and also produces unexpected/broken output.
I am not sure we want to implement logic sharing -R between --just-symbols and -rpath. I would at least try to avoid that, it seems bad
approach to share flags. Since --just-symbols looks not used too often I would suggest users to switch from -R <filename> to explicit --just-symbols.
But that is a bit different story though, what I think we should do right now is stop handling -R <filename> as -rpath and error out in that case instead.
That is what this patch do.