[lld] r289284 - Fix a bogus warning.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 12 12:59:16 PST 2016


A test that is "does not crash/error/warn" is sometimes a bit vague -
could/should you test that the output is as expected in this case?

On Fri, Dec 9, 2016 at 2:51 PM Rafael Espindola via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: rafael
> Date: Fri Dec  9 16:40:49 2016
> New Revision: 289284
>
> URL: http://llvm.org/viewvc/llvm-project?rev=289284&view=rev
> Log:
> Fix a bogus warning.
>
> 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.
>
> Added:
>     lld/trunk/test/ELF/version-script-no-warn.s
> Modified:
>     lld/trunk/ELF/SymbolTable.cpp
>     lld/trunk/ELF/Symbols.h
>
> Modified: lld/trunk/ELF/SymbolTable.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=289284&r1=289283&r2=289284&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/SymbolTable.cpp (original)
> +++ lld/trunk/ELF/SymbolTable.cpp Fri Dec  9 16:40:49 2016
> @@ -192,6 +192,7 @@ std::pair<Symbol *, bool> SymbolTable<EL
>    Symbol *Sym;
>    if (IsNew) {
>      Sym = new (BAlloc) Symbol;
> +    Sym->InVersionScript = false;
>      Sym->Binding = STB_WEAK;
>      Sym->Visibility = STV_DEFAULT;
>      Sym->IsUsedInRegularObj = false;
> @@ -643,9 +644,11 @@ void SymbolTable<ELFT>::assignExactVersi
>        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;
>    }
>  }
>
>
> Modified: lld/trunk/ELF/Symbols.h
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=289284&r1=289283&r2=289284&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/Symbols.h (original)
> +++ lld/trunk/ELF/Symbols.h Fri Dec  9 16:40:49 2016
> @@ -405,6 +405,9 @@ struct Symbol {
>    // 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; }
>
>
> Added: lld/trunk/test/ELF/version-script-no-warn.s
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/version-script-no-warn.s?rev=289284&view=auto
>
> ==============================================================================
> --- lld/trunk/test/ELF/version-script-no-warn.s (added)
> +++ lld/trunk/test/ELF/version-script-no-warn.s Fri Dec  9 16:40:49 2016
> @@ -0,0 +1,12 @@
> +# 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
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161212/f7572d9c/attachment.html>


More information about the llvm-commits mailing list