Index: lld/trunk/ELF/Config.h =================================================================== --- lld/trunk/ELF/Config.h +++ lld/trunk/ELF/Config.h @@ -76,6 +76,7 @@ llvm::StringRef Sysroot; std::string RPath; std::vector VersionDefinitions; + std::vector AuxiliaryList; std::vector DynamicList; std::vector SearchPaths; std::vector Undefined; Index: lld/trunk/ELF/Driver.cpp =================================================================== --- lld/trunk/ELF/Driver.cpp +++ lld/trunk/ELF/Driver.cpp @@ -490,6 +490,11 @@ Config->OFormatBinary = isOutputFormatBinary(Args); + for (auto *Arg : Args.filtered(OPT_auxiliary)) + Config->AuxiliaryList.push_back(Arg->getValue()); + if (!Config->Shared && !Config->AuxiliaryList.empty()) + error("-f may not be used without -shared"); + for (auto *Arg : Args.filtered(OPT_undefined)) Config->Undefined.push_back(Arg->getValue()); Index: lld/trunk/ELF/Options.td =================================================================== --- lld/trunk/ELF/Options.td +++ lld/trunk/ELF/Options.td @@ -7,6 +7,8 @@ class S: Separate<["--", "-"], name>; class JS: JoinedOrSeparate<["--", "-"], name>; +def auxiliary: S<"auxiliary">, HelpText<"Set DT_AUXILIARY field to the specified name">; + def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">; def Bsymbolic_functions: F<"Bsymbolic-functions">, @@ -188,6 +190,7 @@ HelpText<"Linker option extensions">; // Aliases +def alias_auxiliary: Separate<["-"], "f">, Alias; def alias_Bdynamic_call_shared: F<"call_shared">, Alias; def alias_Bdynamic_dy: F<"dy">, Alias; def alias_Bstatic_dn: F<"dn">, Alias; Index: lld/trunk/ELF/OutputSections.cpp =================================================================== --- lld/trunk/ELF/OutputSections.cpp +++ lld/trunk/ELF/OutputSections.cpp @@ -650,6 +650,8 @@ // Add strings. We know that these are the last strings to be added to // DynStrTab and doing this here allows this function to set DT_STRSZ. + for (StringRef S : Config->AuxiliaryList) + Add({DT_AUXILIARY, Out::DynStrTab->addString(S)}); if (!Config->RPath.empty()) Add({Config->EnableNewDtags ? DT_RUNPATH : DT_RPATH, Out::DynStrTab->addString(Config->RPath)}); Index: lld/trunk/test/ELF/auxiliary.s =================================================================== --- lld/trunk/test/ELF/auxiliary.s +++ lld/trunk/test/ELF/auxiliary.s @@ -0,0 +1,12 @@ +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld %t.o -shared -f aaa --auxiliary bbb -o %t +# RUN: llvm-readobj --dynamic-table %t | FileCheck %s + +# CHECK: DynamicSection [ +# CHECK-NEXT: Tag Type Name/Value +# CHECK-NEXT: 0x000000007FFFFFFD AUXILIARY Auxiliary library: [aaa] +# CHECK-NEXT: 0x000000007FFFFFFD AUXILIARY Auxiliary library: [bbb] + +# RUN: not ld.lld %t.o -f aaa --auxiliary bbb -o %t 2>&1 \ +# RUN: | FileCheck -check-prefix=ERR %s +# ERR: -f may not be used without -shared