[PATCH] D33680: [ELF] - Resolve references properly when using .symver directive

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 27 18:08:02 PDT 2017


George Rimar via Phabricator <reviews at reviews.llvm.org> writes:

>  // This function processes version scripts by updating VersionId
>  // member of symbols.
>  template <class ELFT> void SymbolTable<ELFT>::scanVersionScript() {
>    // Symbol themselves might know their versions because symbols
>    // can contain versions in the form of <name>@<version>.
> -  // Let them parse their names.
> -  if (!Config->VersionDefinitions.empty())
> -    for (Symbol *Sym : SymVector)
> -      Sym->body()->parseSymbolVersion();
> +  // Let them parse and update their names to exclude version suffix.
> +  for (Symbol *Sym : SymVector) {
> +    SymbolBody *Body = Sym->body();
> +    bool IsDefault = isDefaultVersion(Body);
> +    Body->parseSymbolVersion();
> +
> +    // <name>@@<version> means the symbol is the default version. If that's the
> +    // case, the symbol is not used only to resolve <name> of version <version>
> +    // but also unversioned symbols with name <name>.
> +    if (IsDefault && find(Body->getName())) {
> +      auto *D = cast<DefinedRegular>(Body);
> +      addRegular(D->getName(), D->StOther, D->Type, D->Value, D->Size,
> +                 D->symbol()->Binding, D->Section, D->File);
> +    }
> +  }

I think I agree with Rui on this part. It would be consistent to:

* Always addRegular
or
* Only addRegular if we have an undefined reference.

The current situation when we add a symbol only when another with the
same name exists is a bit odd.

Given that checking for undefined matches what bfd does, I would suggest
going with that.

Cheers,
Rafael


More information about the llvm-commits mailing list