Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -790,9 +790,11 @@ if (Optional Buffer = readFile(Arg->getValue())) readDynamicList(*Buffer); - for (auto *Arg : Args.filtered(OPT_export_dynamic_symbol)) + for (auto *Arg : Args.filtered(OPT_export_dynamic_symbol)) { Config->DynamicList.push_back( {Arg->getValue(), /*IsExternCpp*/ false, /*HasWildcard*/ false}); + Config->Undefined.push_back(Arg->getValue()); + } } for (auto *Arg : Args.filtered(OPT_version_script)) Index: test/ELF/dynamic-list-archive.s =================================================================== --- test/ELF/dynamic-list-archive.s +++ test/ELF/dynamic-list-archive.s @@ -0,0 +1,17 @@ +# REQUIRES: x86 + +# RUN: rm -f %t.a +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/archive2.s -o %t1.o +# RUN: llvm-ar rcs %t.a %t1.o + +# RUN: echo "{ foo; };" > %t.list + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t2.o +# RUN: ld.lld -shared -o %t.so --dynamic-list %t.list %t.a %t2.o + +# RUN: llvm-readelf -dyn-symbols %t.so | FileCheck %s +# CHECK-NOT: foo + +.global _start +_start: + nop Index: test/ELF/export-dynamic-symbol.s =================================================================== --- test/ELF/export-dynamic-symbol.s +++ test/ELF/export-dynamic-symbol.s @@ -0,0 +1,15 @@ +# REQUIRES: x86 + +# RUN: rm -f %t.a +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/archive2.s -o %t1.o +# RUN: llvm-ar rcs %t.a %t1.o + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t2.o +# RUN: ld.lld -shared -o %t.so --export-dynamic-symbol foo %t.a %t2.o + +# RUN: llvm-readelf -dyn-symbols %t.so | FileCheck %s +# CHECK: foo + +.global _start +_start: + nop