Deliberate deduplication of -rpath arguments in ld.bfd and ld.gold?

Stephan Bergmann sbergman@redhat.com
Wed Jul 6 09:06:49 GMT 2022


Over in the comments at <https://reviews.llvm.org/D129142> "[LLD][ELF] 
Drop duplicates from rpath" we wonder what the rationale might be that 
both ld.bfd and ld.gold apparently deliberately drop duplicated -rpath 
arguments with identical paths (as in

> $ cat test.c
> void f(void) {}
> $ gcc -c test.c
> $ ld.bfd -rpath=/path -rpath=/path -shared test.o
> $ readelf -d a.out | grep RUNPATH
>  0x000000000000001d (RUNPATH)            Library runpath: [/path]

for example).

For the relevant code in ld.bfd see `/* First see whether OPTARG is 
already in the path.  */` ever since 
<https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=252b5132c753830d5fd56823373aed85f2a0db63> 
"19990502 sourceware import") and for the relevant code in ld.gold see 
`// Eliminate duplicates.` since 
<https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=41f542e70b89b9ea2875c438b0c9a60ac46092dd> 
"Add support for -rpath."



More information about the Binutils mailing list