[PATCH] D33680: [ELF] - Resolve references properly when using .symver directive
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 1 11:43:22 PDT 2017
George Rimar via Phabricator <reviews at reviews.llvm.org> writes:
> Index: test/ELF/version-script-symver.s
> ===================================================================
> --- test/ELF/version-script-symver.s
> +++ test/ELF/version-script-symver.s
> @@ -0,0 +1,11 @@
> +# REQUIRES: x86
> +
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
> +# RUN: echo "VERSION { global: *; };" > %t.map
> +# RUN: ld.lld %t.o --version-script %t.map -o %t
You don't need the version script, no?
> Index: test/ELF/version-script-symver-err.s
> ===================================================================
> --- test/ELF/version-script-symver-err.s
> +++ test/ELF/version-script-symver-err.s
> @@ -0,0 +1,16 @@
> +# REQUIRES: x86
> +
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
> +# RUN: echo "VERSION { global: *; };" > %t.map
> +# RUN: not ld.lld %t.o --version-script %t.map -o %t 2>&1 | FileCheck %s
Same here, the version script should not be necessary.
> Index: ELF/Symbols.cpp
> ===================================================================
> --- ELF/Symbols.cpp
> +++ ELF/Symbols.cpp
> @@ -13,6 +13,7 @@
> #include "InputSection.h"
> #include "OutputSections.h"
> #include "Strings.h"
> +#include "SymbolTable.h"
> #include "SyntheticSections.h"
> #include "Target.h"
> #include "Writer.h"
> @@ -220,6 +221,21 @@
> return nullptr;
> }
>
> +static void resolve(StringRef Name, Symbol *Sym) {
> + switch (Config->EKind) {
> + case ELF32LEKind:
> + return Symtab<ELF32LE>::X->resolve(Name, Sym);
> + case ELF32BEKind:
> + return Symtab<ELF32BE>::X->resolve(Name, Sym);
> + case ELF64LEKind:
> + return Symtab<ELF64LE>::X->resolve(Name, Sym);
> + case ELF64BEKind:
> + return Symtab<ELF64BE>::X->resolve(Name, Sym);
> + default:
> + llvm_unreachable("unknown Config->EKind");
> + }
> +}
Instead of this.
> // If a symbol name contains '@', the characters after that is
> // a symbol version name. This function parses that.
> void SymbolBody::parseSymbolVersion() {
> @@ -241,9 +257,13 @@
> // '@@' in a symbol name means the default version.
> // It is usually the most recent one.
> bool IsDefault = (Verstr[0] == '@');
> - if (IsDefault)
> + if (IsDefault) {
> Verstr = Verstr.substr(1);
>
> + // name@@ver should also be used to resolve references to name.
> + resolve(Name, this->symbol());
> + }
Have parseSymbolVersion return true if the symbol is default. You can
then use that in the caller, which is templated.
Cheers,
Rafael
More information about the llvm-commits
mailing list