[lld] r267315 - ELF: Forbid undefined symbols with non-default visibility in DSOs.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 24 15:37:36 PDT 2016


Thanks!

On 23 April 2016 at 22:31, Peter Collingbourne via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: pcc
> Date: Sat Apr 23 21:31:04 2016
> New Revision: 267315
>
> URL: http://llvm.org/viewvc/llvm-project?rev=267315&view=rev
> Log:
> ELF: Forbid undefined symbols with non-default visibility in DSOs.
>
> Added:
>     lld/trunk/test/ELF/undef-shared.s
> Modified:
>     lld/trunk/ELF/Writer.cpp
>
> Modified: lld/trunk/ELF/Writer.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=267315&r1=267314&r2=267315&view=diff
> ==============================================================================
> --- lld/trunk/ELF/Writer.cpp (original)
> +++ lld/trunk/ELF/Writer.cpp Sat Apr 23 21:31:04 2016
> @@ -730,8 +730,13 @@ void Writer<ELFT>::scanRelocs(InputSecti
>
>  template <class ELFT>
>  static void reportUndefined(SymbolTable<ELFT> &Symtab, SymbolBody *Sym) {
> -  if ((Config->Relocatable || Config->Shared) && !Config->NoUndefined)
> -    return;
> +  if (!Config->NoUndefined) {
> +    if (Config->Relocatable)
> +      return;
> +    if (Config->Shared)
> +      if (Sym->Backref->Visibility == STV_DEFAULT)
> +        return;
> +  }
>
>    std::string Msg = "undefined symbol: " + Sym->getName().str();
>    if (InputFile *File = Symtab.findFile(Sym))
>
> Added: lld/trunk/test/ELF/undef-shared.s
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/undef-shared.s?rev=267315&view=auto
> ==============================================================================
> --- lld/trunk/test/ELF/undef-shared.s (added)
> +++ lld/trunk/test/ELF/undef-shared.s Sat Apr 23 21:31:04 2016
> @@ -0,0 +1,14 @@
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
> +# RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck %s
> +
> +# CHECK: undefined symbol: hidden in {{.*}}
> +.global hidden
> +.hidden hidden
> +
> +# CHECK: undefined symbol: internal in {{.*}}
> +.global internal
> +.internal internal
> +
> +# CHECK: undefined symbol: protected in {{.*}}
> +.global protected
> +.protected protected
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list