[PATCH] D43307: Fix an issue that lld drops symbol versions for -r.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 17:30:23 PST 2018


LGTM

This is probably a good candidate for 6.0

Thanks,
Rafael

Rui Ueyama via Phabricator <reviews at reviews.llvm.org> writes:

> ruiu created this revision.
> ruiu added reviewers: rafael, timshen.
> Herald added subscribers: arichardson, emaste.
>
> When we are emitting a relocatable output, we should keep the original
> symbol name including "@" part. Previously, we drop that part unconditionally
> which resulted in dropping versions from symbols.
>
>
> https://reviews.llvm.org/D43307
>
> Files:
>   lld/ELF/Driver.cpp
>   lld/test/ELF/relocatable-versioned.s
>
>
> Index: lld/test/ELF/relocatable-versioned.s
> ===================================================================
> --- /dev/null
> +++ lld/test/ELF/relocatable-versioned.s
> @@ -0,0 +1,10 @@
> +# REQUIRES: x86
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
> +# RUN: ld.lld -o %t2.o -r %t1.o
> +# RUN: llvm-nm %t2.o | FileCheck %s
> +# CHECK: foo at VERSION
> +
> +.global "foo at VERSION"
> +.text
> +"foo at VERSION":
> +  ret
> Index: lld/ELF/Driver.cpp
> ===================================================================
> --- lld/ELF/Driver.cpp
> +++ lld/ELF/Driver.cpp
> @@ -1104,7 +1104,12 @@
>    Script->declareSymbols();
>  
>    // Apply version scripts.
> -  Symtab->scanVersionScript();
> +  //
> +  // For a relocatable output, version scripts don't make sense, and
> +  // parsing a symbol version string (e.g. dropping "@ver1" from a symbol
> +  // name "foo at ver1") rather do harm, so we don't call this if -r is given.
> +  if (!Config->Relocatable)
> +    Symtab->scanVersionScript();
>  
>    // Create wrapped symbols for -wrap option.
>    for (auto *Arg : Args.filtered(OPT_wrap))
>
>
> Index: lld/test/ELF/relocatable-versioned.s
> ===================================================================
> --- /dev/null
> +++ lld/test/ELF/relocatable-versioned.s
> @@ -0,0 +1,10 @@
> +# REQUIRES: x86
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
> +# RUN: ld.lld -o %t2.o -r %t1.o
> +# RUN: llvm-nm %t2.o | FileCheck %s
> +# CHECK: foo at VERSION
> +
> +.global "foo at VERSION"
> +.text
> +"foo at VERSION":
> +  ret
> Index: lld/ELF/Driver.cpp
> ===================================================================
> --- lld/ELF/Driver.cpp
> +++ lld/ELF/Driver.cpp
> @@ -1104,7 +1104,12 @@
>    Script->declareSymbols();
>  
>    // Apply version scripts.
> -  Symtab->scanVersionScript();
> +  //
> +  // For a relocatable output, version scripts don't make sense, and
> +  // parsing a symbol version string (e.g. dropping "@ver1" from a symbol
> +  // name "foo at ver1") rather do harm, so we don't call this if -r is given.
> +  if (!Config->Relocatable)
> +    Symtab->scanVersionScript();
>  
>    // Create wrapped symbols for -wrap option.
>    for (auto *Arg : Args.filtered(OPT_wrap))


More information about the llvm-commits mailing list