[lld] r259779 - [ELF][MIPS] Replace needsMipsLocalGot function by canBePreempted

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 5 10:13:46 PST 2016


On Thu, Feb 4, 2016 at 3:51 AM, Simon Atanasyan via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: atanasyan
> Date: Thu Feb  4 05:51:45 2016
> New Revision: 259779
>
> URL: http://llvm.org/viewvc/llvm-project?rev=259779&view=rev
> Log:
> [ELF][MIPS] Replace needsMipsLocalGot function by canBePreempted
>
> Symbol does not need an entry i the 'global' part of GOT if it cannot be
> preempted. So canBePreempted fully satisfies us at least for now.
>
> Modified:
>     lld/trunk/ELF/InputSection.cpp
>     lld/trunk/ELF/Target.cpp
>     lld/trunk/ELF/Target.h
>     lld/trunk/ELF/Writer.cpp
>
> Modified: lld/trunk/ELF/InputSection.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=259779&r1=259778&r2=259779&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/InputSection.cpp (original)
> +++ lld/trunk/ELF/InputSection.cpp Thu Feb  4 05:51:45 2016
> @@ -209,7 +209,7 @@ void InputSectionBase<ELFT>::relocate(ui
>      if (Target->needsPlt(Type, *Body)) {
>        SymVA = Body->getPltVA<ELFT>();
>      } else if (Target->needsGot(Type, *Body)) {
> -      if (Config->EMachine == EM_MIPS && needsMipsLocalGot(Type, Body))
> +      if (Config->EMachine == EM_MIPS && !canBePreempted(Body, true))
>          // Under some conditions relocations against non-local symbols
> require
>          // entries in the local part of MIPS GOT. In that case we need an
> entry
>          // initialized by full address of the symbol.
>
> Modified: lld/trunk/ELF/Target.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=259779&r1=259778&r2=259779&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/Target.cpp (original)
> +++ lld/trunk/ELF/Target.cpp Thu Feb  4 05:51:45 2016
> @@ -1562,20 +1562,6 @@ template <class ELFT> typename ELFFile<E
>    return 0;
>  }
>
> -bool needsMipsLocalGot(uint32_t Type, SymbolBody *Body) {
> -  // The R_MIPS_GOT16 relocation requires creation of entry in the local
> part
> -  // of GOT if its target is a local symbol or non-local symbol with
> 'local'
> -  // visibility.
> -  if (Type != R_MIPS_GOT16)
> -    return false;
> -  if (!Body)
> -    return true;
> -  uint8_t V = Body->getVisibility();
> -  if (V != STV_DEFAULT && V != STV_PROTECTED)
> -    return true;
> -  return !Config->Shared;
> -}
> -
>  template bool isGnuIFunc<ELF32LE>(const SymbolBody &S);
>  template bool isGnuIFunc<ELF32BE>(const SymbolBody &S);
>  template bool isGnuIFunc<ELF64LE>(const SymbolBody &S);
>
> Modified: lld/trunk/ELF/Target.h
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=259779&r1=259778&r2=259779&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/Target.h (original)
> +++ lld/trunk/ELF/Target.h Thu Feb  4 05:51:45 2016
> @@ -98,9 +98,6 @@ uint64_t getPPC64TocBase();
>  template <class ELFT>
>  typename llvm::object::ELFFile<ELFT>::uintX_t getMipsGpAddr();
>
> -// Returns true if the relocation requires entry in the local part of GOT.
> -bool needsMipsLocalGot(uint32_t Type, SymbolBody *Body);
> -
>  template <class ELFT> bool isGnuIFunc(const SymbolBody &S);
>
>  extern std::unique_ptr<TargetInfo> Target;
>
> Modified: lld/trunk/ELF/Writer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=259779&r1=259778&r2=259779&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/Writer.cpp (original)
> +++ lld/trunk/ELF/Writer.cpp Thu Feb  4 05:51:45 2016
> @@ -291,10 +291,12 @@ void Writer<ELFT>::scanRelocs(
>      }
>
>      // MIPS has a special rule to create GOTs for local symbols.
> -    if (Config->EMachine == EM_MIPS && needsMipsLocalGot(Type, Body)) {
> -      // FIXME (simon): Do not add so many redundant entries.
> -      Out<ELFT>::Got->addMipsLocalEntry();
> -      continue;
> +    if (Config->EMachine == EM_MIPS && !canBePreempted(Body, true)) {
> +      if (Type == R_MIPS_GOT16 || Type == R_MIPS_CALL16) {
>

You can decrease the nesting level by one here.

if (Config->EMachine == EM_MIPS && !canBePreempted(Body, true) &&
    (Type == R_MIPS_GOT16 || Type == R_MIPS_CALL16)) {

+        // FIXME (simon): Do not add so many redundant entries.
> +        Out<ELFT>::Got->addMipsLocalEntry();
> +        continue;
> +      }
>      }
>
>      // If a symbol in a DSO is referenced directly instead of through GOT,
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160205/7a521cd0/attachment.html>


More information about the llvm-commits mailing list