[lld] r272934 - [ELF] - Handle every global as unversioned export in versioned script.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 16 11:47:04 PDT 2016
Author: grimar
Date: Thu Jun 16 13:47:04 2016
New Revision: 272934
URL: http://llvm.org/viewvc/llvm-project?rev=272934&view=rev
Log:
[ELF] - Handle every global as unversioned export in versioned script.
Patch updates the version script parser to parse versioned files.
In a simple way, just adding them to VersionScriptGlobals list.
Differential revision: http://reviews.llvm.org/D21439
Modified:
lld/trunk/ELF/SymbolListFile.cpp
lld/trunk/test/ELF/version-script.s
Modified: lld/trunk/ELF/SymbolListFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolListFile.cpp?rev=272934&r1=272933&r2=272934&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolListFile.cpp (original)
+++ lld/trunk/ELF/SymbolListFile.cpp Thu Jun 16 13:47:04 2016
@@ -75,9 +75,12 @@ public:
VersionScriptParser(StringRef S) : ScriptParserBase(S) {}
void run();
+
+private:
+ void parseVersion();
};
-void VersionScriptParser::run() {
+void VersionScriptParser::parseVersion() {
expect("{");
if (peek() == "global:") {
next();
@@ -93,8 +96,25 @@ void VersionScriptParser::run() {
expect(";");
expect("}");
expect(";");
- if (!atEOF())
- setError("expected EOF");
+}
+
+void VersionScriptParser::run() {
+ StringRef Msg = "anonymous version definition is used in "
+ "combination with other version definitions";
+ if (peek() == "{") {
+ parseVersion();
+ if (!atEOF())
+ setError(Msg);
+ return;
+ }
+
+ while (!atEOF() && !Error) {
+ if (next() == "{") {
+ setError(Msg);
+ return;
+ }
+ parseVersion();
+ }
}
void elf::parseVersionScript(MemoryBufferRef MB) {
Modified: lld/trunk/test/ELF/version-script.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/version-script.s?rev=272934&r1=272933&r2=272934&view=diff
==============================================================================
--- lld/trunk/test/ELF/version-script.s (original)
+++ lld/trunk/test/ELF/version-script.s Thu Jun 16 13:47:04 2016
@@ -19,6 +19,37 @@
# 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
+
+# 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)
More information about the llvm-commits
mailing list