[lld] --export-dynamic overrides --dynamic-list.
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Tue, 11 Apr 2017 22:37:54 +0000 (22:37 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Tue, 11 Apr 2017 22:37:54 +0000 (22:37 +0000)
Fixes PR32573.

--export-dynamic exports everything, even in the presence of a --dynamic-list,
or --export-dynamic-symbol.

llvm-svn: 300002

lld/ELF/Driver.cpp
lld/test/ELF/dynamic-list.s

index 9f66360..8e7ada6 100644 (file)
@@ -713,6 +713,9 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
       Config->DefaultSymbolVersion = VER_NDX_LOCAL;
   }
 
+  if (getArg(Args, OPT_export_dynamic, OPT_no_export_dynamic, false))
+    Config->DefaultSymbolVersion = VER_NDX_GLOBAL;
+
   if (auto *Arg = Args.getLastArg(OPT_version_script))
     if (Optional<MemoryBufferRef> Buffer = readFile(Arg->getValue()))
       readVersionScript(*Buffer);
index 80e480b..7cd5873 100644 (file)
 # CHECK2-NEXT:   }
 # CHECK2-NEXT: ]
 
+
+## --export-dynamic overrides --dynamic-list, i.e. --export-dynamic with an
+## incomplete dynamic-list still exports everything.
+# RUN: echo "{ foo2; };" > %t.list
+# RUN: ld.lld --dynamic-list %t.list --export-dynamic %t %t2.so -o %t.exe
+# RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck -check-prefix=CHECK3 %s
+
+## The same with --export-dynamic-symbol.
+# RUN: ld.lld --export-dynamic-symbol=foo2 --export-dynamic %t %t2.so -o %t.exe
+# RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck -check-prefix=CHECK3 %s
+
+# CHECK3:      DynamicSymbols [
+# CHECK3-NEXT:   Symbol {
+# CHECK3-NEXT:     Name: @
+# CHECK3-NEXT:     Value: 0x0
+# CHECK3-NEXT:     Size: 0
+# CHECK3-NEXT:     Binding: Local
+# CHECK3-NEXT:     Type: None
+# CHECK3-NEXT:     Other: 0
+# CHECK3-NEXT:     Section: Undefined
+# CHECK3-NEXT:   }
+# CHECK3-NEXT:   Symbol {
+# CHECK3-NEXT:     Name: _start@
+# CHECK3-NEXT:     Value: 0x201003
+# CHECK3-NEXT:     Size: 0
+# CHECK3-NEXT:     Binding: Global (0x1)
+# CHECK3-NEXT:     Type: None (0x0)
+# CHECK3-NEXT:     Other: 0
+# CHECK3-NEXT:     Section: .text (0x4)
+# CHECK3-NEXT:   }
+# CHECK3-NEXT:   Symbol {
+# CHECK3-NEXT:     Name: foo1@
+# CHECK3-NEXT:     Value: 0x201000
+# CHECK3-NEXT:     Size: 0
+# CHECK3-NEXT:     Binding: Global (0x1)
+# CHECK3-NEXT:     Type: None (0x0)
+# CHECK3-NEXT:     Other: 0
+# CHECK3-NEXT:     Section: .text (0x4)
+# CHECK3-NEXT:   }
+# CHECK3-NEXT:   Symbol {
+# CHECK3-NEXT:     Name: foo2@
+# CHECK3-NEXT:     Value: 0x201001
+# CHECK3-NEXT:     Size: 0
+# CHECK3-NEXT:     Binding: Global (0x1)
+# CHECK3-NEXT:     Type: None (0x0)
+# CHECK3-NEXT:     Other: 0
+# CHECK3-NEXT:     Section: .text (0x4)
+# CHECK3-NEXT:   }
+# CHECK3-NEXT:   Symbol {
+# CHECK3-NEXT:     Name: foo31@
+# CHECK3-NEXT:     Value: 0x201002
+# CHECK3-NEXT:     Size: 0
+# CHECK3-NEXT:     Binding: Global (0x1)
+# CHECK3-NEXT:     Type: None (0x0)
+# CHECK3-NEXT:     Other: 0
+# CHECK3-NEXT:     Section: .text (0x4)
+# CHECK3-NEXT:   }
+# CHECK3-NEXT: ]
+
 .globl foo1
 foo1:
   ret