Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -381,6 +381,10 @@ // Initializes Config members by the command line options. void LinkerDriver::readConfigs(opt::InputArgList &Args) { + for (auto *Arg : Args.filtered(OPT_rpath_link_eq)) + Config->SearchPaths.push_back(Arg->getValue()); + for (auto *Arg : Args.filtered(OPT_rpath_link)) + Config->SearchPaths.push_back(Arg->getValue()); for (auto *Arg : Args.filtered(OPT_L)) Config->SearchPaths.push_back(Arg->getValue()); Index: ELF/Options.td =================================================================== --- ELF/Options.td +++ ELF/Options.td @@ -145,6 +145,10 @@ def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">; +def rpath_link: S<"rpath-link">, HelpText<"Add DIR to link time shared library search path">; + +def rpath_link_eq: J<"rpath-link=">, HelpText<"Add DIR to link time shared library search path">; + def script: S<"script">, HelpText<"Read linker script">; def shared: F<"shared">, HelpText<"Build a shared object">; @@ -274,8 +278,6 @@ def no_mmap_output_file: F<"no-mmap-output-file">; def no_warn_common: F<"no-warn-common">; def no_warn_mismatch: F<"no-warn-mismatch">; -def rpath_link: S<"rpath-link">; -def rpath_link_eq: J<"rpath-link=">; def sort_common: F<"sort-common">; def warn_execstack: F<"warn-execstack">; def warn_shared_textrel: F<"warn-shared-textrel">; Index: test/ELF/rpath-link.s =================================================================== --- test/ELF/rpath-link.s +++ test/ELF/rpath-link.s @@ -0,0 +1,7 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/shared.s -o %t1.o +# RUN: mkdir -p %T/libs +# RUN: ld.lld -shared %t1.o -o %T/libs/libz.so +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t2.o +# RUN: ld.lld -o %t --rpath-link=%T/libs -lz %t2.o 2>&1 +# RUN: ld.lld -o %t --rpath-link %T/libs -lz %t2.o 2>&1