[PATCH] D21439: [ELF] - Handle every global as unversioned export in versioned script.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 16 10:59:15 PDT 2016
grimar updated this revision to Diff 60995.
grimar added a comment.
- Reimplemented using recursive descendant parser.
- Improved testcase.
http://reviews.llvm.org/D21439
Files:
ELF/SymbolListFile.cpp
test/ELF/version-script.s
Index: test/ELF/version-script.s
===================================================================
--- test/ELF/version-script.s
+++ test/ELF/version-script.s
@@ -17,6 +17,38 @@
# RUN: ld.lld --version-script %t.script --dynamic-list %t.list %t.o %t2.so -o %t
# RUN: llvm-readobj -dyn-symbols %t | FileCheck --check-prefix=EXE %s
+# RUN: echo "VERSION_1.0{ \
+# RUN: global: foo1; \
+# RUN: local: *; }; \
+# RUN: VERSION_2.0{ \
+# RUN: global: foo3; \
+# RUN: local: *; }; " > %t4.script
+# RUN: ld.lld --version-script %t4.script -shared %t.o %t2.so -o %t4.so
+# RUN: llvm-readobj -dyn-symbols %t4.so | FileCheck --check-prefix=DSO %s
+
+# RUN: echo "VERSION_1.0{ \
+# RUN: global: foo1; \
+# RUN: local: *; }; \
+# RUN: { \
+# RUN: global: foo3; \
+# RUN: local: *; }; " > %t5.script
+# RUN: not ld.lld --version-script %t5.script -shared %t.o %t2.so -o %t5.so 2>&1 | \
+# RUN: FileCheck -check-prefix=ERR %s
+# ERR: anonymous version definition is used in combination with other version definitions
+
+# RUN: echo "{ \
+# RUN: global: foo1; \
+# RUN: local: *; }; \
+# RUN: VERSION_2.0 { \
+# RUN: global: foo3; \
+# RUN: local: *; }; " > %t5.script
+# RUN: not ld.lld --version-script %t5.script -shared %t.o %t2.so -o %t5.so 2>&1 | \
+# RUN: FileCheck -check-prefix=ERR %s
+# ERR: anonymous version definition is used in combination with other version definitions
+
+# RUN: ld.lld --version-script %t.script --dynamic-list %t.list %t.o %t2.so -o %t2
+# RUN: llvm-readobj %t2 > /dev/null
+
# DSO: DynamicSymbols [
# DSO-NEXT: Symbol {
# DSO-NEXT: Name: @ (0)
Index: ELF/SymbolListFile.cpp
===================================================================
--- ELF/SymbolListFile.cpp
+++ ELF/SymbolListFile.cpp
@@ -75,9 +75,12 @@
VersionScriptParser(StringRef S) : ScriptParserBase(S) {}
void run();
+
+private:
+ void parseVersion();
};
-void VersionScriptParser::run() {
+void VersionScriptParser::parseVersion() {
expect("{");
if (peek() == "global:") {
next();
@@ -93,8 +96,24 @@
expect(";");
expect("}");
expect(";");
- if (!atEOF())
- setError("expected EOF");
+}
+
+void VersionScriptParser::run() {
+ StringRef Err = "anonymous version definition is used in "
+ "combination with other version definitions";
+ if (peek() == "{") {
+ parseVersion();
+ if (!atEOF())
+ setError(Err);
+ return;
+ }
+
+ while (!atEOF() && !Error) {
+ if (next() == "{")
+ setError(Err);
+ else
+ parseVersion();
+ }
}
void elf::parseVersionScript(MemoryBufferRef MB) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21439.60995.patch
Type: text/x-patch
Size: 2757 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160616/fae6c48c/attachment.bin>
More information about the llvm-commits
mailing list