We first decide that the symbol is global, than that it should have
version foo. Since it was already not the default version, we were
producing a bogus warning.
llvm-svn: 289284
Symbol *Sym;
if (IsNew) {
Sym = new (BAlloc) Symbol;
+ Sym->InVersionScript = false;
Sym->Binding = STB_WEAK;
Sym->Visibility = STV_DEFAULT;
Sym->IsUsedInRegularObj = false;
continue;
}
- if (B->symbol()->VersionId != Config->DefaultSymbolVersion)
+ Symbol *Sym = B->symbol();
+ if (Sym->InVersionScript)
warn("duplicate symbol '" + Ver.Name + "' in version script");
- B->symbol()->VersionId = VersionId;
+ Sym->VersionId = VersionId;
+ Sym->InVersionScript = true;
}
}
// True if this symbol is specified by --trace-symbol option.
unsigned Traced : 1;
+ // This symbol version was found in a version script.
+ unsigned InVersionScript : 1;
+
bool includeInDynsym() const;
bool isWeak() const { return Binding == llvm::ELF::STB_WEAK; }
--- /dev/null
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/shared.s -o %t2.o
+# RUN: ld.lld -shared %t2.o -soname shared -o %t2.so
+
+# RUN: echo "foo { global: bar; local: *; };" > %t.script
+# RUN: ld.lld --fatal-warnings --shared --version-script %t.script %t.o %t2.so
+
+.global bar
+bar:
+ nop