[lld] r326813 - Improve duplicated version handling.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 6 09:05:12 PST 2018
Author: rafael
Date: Tue Mar 6 09:05:12 2018
New Revision: 326813
URL: http://llvm.org/viewvc/llvm-project?rev=326813&view=rev
Log:
Improve duplicated version handling.
It looks like the problem that caused us to originally warn instead of
error was that of a symbol being assigned to the same version twice.
Now we don't warn if a symbol is assigned to the same version twice,
but error if it is assigned to multiple.
This fixes pr28342.
Modified:
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/test/ELF/version-script.s
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=326813&r1=326812&r2=326813&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Tue Mar 6 09:05:12 2018
@@ -697,8 +697,9 @@ void SymbolTable::assignExactVersion(Sym
if (Sym->getName().contains('@'))
continue;
- if (Sym->VersionId != Config->DefaultSymbolVersion)
- warn("duplicate symbol '" + Ver.Name + "' in version script");
+ if (Sym->VersionId != Config->DefaultSymbolVersion &&
+ Sym->VersionId != VersionId)
+ error("duplicate symbol '" + Ver.Name + "' in version script");
Sym->VersionId = VersionId;
}
}
Modified: lld/trunk/test/ELF/version-script.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/version-script.s?rev=326813&r1=326812&r2=326813&view=diff
==============================================================================
--- lld/trunk/test/ELF/version-script.s (original)
+++ lld/trunk/test/ELF/version-script.s Tue Mar 6 09:05:12 2018
@@ -34,9 +34,9 @@
# RUN: echo "VERSION_1.0 { global: foo1; local: *; };" > %t6.script
# RUN: echo "VERSION_2.0 { global: foo1; local: *; };" >> %t6.script
-# RUN: ld.lld --version-script %t6.script -shared %t.o %t2.so -o %t6.so 2>&1 | \
-# RUN: FileCheck -check-prefix=WARN2 %s
-# WARN2: duplicate symbol 'foo1' in version script
+# RUN: not ld.lld --version-script %t6.script -shared %t.o %t2.so -o %t6.so 2>&1 | \
+# RUN: FileCheck -check-prefix=ERR3 %s
+# ERR3: duplicate symbol 'foo1' in version script
# RUN: echo "{ foo1; foo2; };" > %t.list
# RUN: ld.lld --version-script %t.script --dynamic-list %t.list %t.o %t2.so -o %t2
@@ -213,6 +213,9 @@
# ALL-NEXT: }
# ALL-NEXT: ]
+# RUN: echo "VERSION_1.0 { global: foo1; foo1; local: *; };" > %t8.script
+# RUN: ld.lld --version-script %t8.script -shared %t.o -o %t8.so --fatal-warnings
+
.globl foo1
foo1:
call bar at PLT
More information about the llvm-commits
mailing list