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

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 14 10:24:59 PDT 2017


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

>  Defined::Defined(Kind K, StringRefZ Name, bool IsLocal, uint8_t StOther,
> Index: ELF/SymbolTable.cpp
> ===================================================================
> --- ELF/SymbolTable.cpp
> +++ ELF/SymbolTable.cpp
> @@ -715,15 +715,33 @@
>        B->symbol()->VersionId = VersionId;
>  }
>  
> +static bool isDefaultVersion(SymbolBody *Body) {
> +  if (!Body->isInCurrentDSO())
> +    return false;
> +  return Body->getName().find("@@") != StringRef::npos;
> +}
> +
>  // 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();
> +  // Below we resolve references to symbols that have default version. We use
> +  // additional temp vector because addRegular() call may change SymVector.
> +  std::vector<DefinedRegular *> DefaultV;
> +  for (Symbol *Sym : SymVector) {
> +    if (isDefaultVersion(Sym->body()))
> +      DefaultV.push_back(cast<DefinedRegular>(Sym->body()));
> +    Sym->body()->parseSymbolVersion();

I preferred the version where parseSymbolVersion returned null. Doing two
scans over the name doesn't seem like a good idea.

Rui, would you be OK with this patch but with parseSymbolVersion
returning a bool instead of having a isDefaultVersion? We can always try
to improve it afterwards.

Cheers,
Rafael


More information about the llvm-commits mailing list