[PATCH] D21640: [ELF] - Fix incorrect logic in VersionScriptParser::parseVersion()

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 23 03:41:56 PDT 2016


grimar created this revision.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar.

Previously the next sample script would generate 2 entries in 
Config->SymbolVersions with the same version name.

```
VERSION {
 global: c; d;
};
```

That happened because parseVersionSymbols() was called at first and
since there is no local tag, it was called again.
Patch fixes the issue, testcase update to demonstrate.



http://reviews.llvm.org/D21640

Files:
  ELF/SymbolListFile.cpp
  test/ELF/verdef-dependency.s

Index: test/ELF/verdef-dependency.s
===================================================================
--- test/ELF/verdef-dependency.s
+++ test/ELF/verdef-dependency.s
@@ -7,8 +7,8 @@
 # RUN:          global: b;                \
 # RUN:          local: *; }LIBSAMPLE_1.0; \
 # RUN:       LIBSAMPLE_3.0{               \
-# RUN:          global: c;                \
-# RUN:          local: *; }LIBSAMPLE_2.0;" > %t.script
+# RUN:          global: c; d;             \
+# RUN:       }LIBSAMPLE_2.0;" > %t.script
 # RUN: ld.lld --version-script %t.script -shared -soname shared %t.o -o %t.so
 # RUN: llvm-readobj -V -dyn-symbols %t.so | FileCheck --check-prefix=DSO %s
 
Index: ELF/SymbolListFile.cpp
===================================================================
--- ELF/SymbolListFile.cpp
+++ ELF/SymbolListFile.cpp
@@ -84,14 +84,13 @@
 
 void VersionScriptParser::parseVersion(StringRef Version) {
   expect("{");
-  if (peek() == "global:") {
-    next();
+  if (peek() != "local:") {
+    if (peek() == "global:")
+      next();
     parseVersionSymbols(Version);
   }
   if (peek() == "local:")
     parseLocal();
-  else
-    parseVersionSymbols(Version);
 
   expect("}");
   if (!Version.empty() && peek() != ";")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21640.61659.patch
Type: text/x-patch
Size: 1225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160623/48192da1/attachment.bin>


More information about the llvm-commits mailing list