diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 78a60147613d..7430e0d1099d 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -1188,7 +1188,8 @@ static void readConfigs(opt::InputArgList &args) { // -Bsymbolic-functions (if STT_FUNC), --dynamic-list. for (auto *arg : args.filtered(OPT_export_dynamic_symbol)) config->dynamicList.push_back( - {arg->getValue(), /*isExternCpp=*/false, /*hasWildcard=*/true}); + {arg->getValue(), /*isExternCpp=*/false, + /*hasWildcard=*/hasWildcard(arg->getValue())}); for (auto *arg : args.filtered(OPT_version_script)) if (Optional path = searchScript(arg->getValue())) { diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index d23a46d250e4..fea6b7a274e7 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -1474,7 +1474,7 @@ void ScriptParser::readVersionDeclaration(StringRef verStr) { expect(";"); } -static bool hasWildcard(StringRef s) { +bool elf::hasWildcard(StringRef s) { return s.find_first_of("?*[") != StringRef::npos; } diff --git a/lld/ELF/ScriptParser.h b/lld/ELF/ScriptParser.h index c953fb302b9a..eed1958647f8 100644 --- a/lld/ELF/ScriptParser.h +++ b/lld/ELF/ScriptParser.h @@ -27,6 +27,8 @@ void readDynamicList(MemoryBufferRef mb); // Parses the defsym expression. void readDefsym(StringRef name, MemoryBufferRef mb); +bool hasWildcard(StringRef s); + } // namespace elf } // namespace lld diff --git a/lld/test/ELF/export-dynamic-symbol.s b/lld/test/ELF/export-dynamic-symbol.s index 886a4cd59595..efd46112435e 100644 --- a/lld/test/ELF/export-dynamic-symbol.s +++ b/lld/test/ELF/export-dynamic-symbol.s @@ -41,8 +41,12 @@ # RUN: llvm-objdump -d %t.preempt3 | FileCheck --check-prefix=PLT %s ## The option value is a glob. -# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol 'f*' %t.o -o %t.preempt4 -# RUN: llvm-objdump -d %t.preempt4 | FileCheck --check-prefix=PLT %s +# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol 'f*' %t.o -o - | \ +# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT %s +# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol '[f]o[o]' %t.o -o - | \ +# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT %s +# RUN: ld.lld -shared -Bsymbolic --export-dynamic-symbol 'f?o' %t.o -o - | \ +# RUN: llvm-objdump -d - | FileCheck --check-prefix=PLT %s # PLT: # NOPLT-NOT: