diff options
| author | Simon Atanasyan <simon@atanasyan.com> | 2016-02-04 11:51:45 +0000 |
|---|---|---|
| committer | Simon Atanasyan <simon@atanasyan.com> | 2016-02-04 11:51:45 +0000 |
| commit | 4b03451cac039db35e7cb76168ccd1c8c26fb006 (patch) | |
| tree | ca263c5f06548ae19dca519bf3f958ad634473a3 | |
| parent | 170356ba325cd48d894014475a2a75190c333e0b (diff) | |
| download | bcm5719-llvm-4b03451cac039db35e7cb76168ccd1c8c26fb006.tar.gz bcm5719-llvm-4b03451cac039db35e7cb76168ccd1c8c26fb006.zip | |
[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.
llvm-svn: 259779
| -rw-r--r-- | lld/ELF/InputSection.cpp | 2 | ||||
| -rw-r--r-- | lld/ELF/Target.cpp | 14 | ||||
| -rw-r--r-- | lld/ELF/Target.h | 3 | ||||
| -rw-r--r-- | lld/ELF/Writer.cpp | 10 |
4 files changed, 7 insertions, 22 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 67432dd30b6..61170c43209 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -209,7 +209,7 @@ void InputSectionBase<ELFT>::relocate(uint8_t *Buf, uint8_t *BufEnd, 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. diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 7f90bd3471a..7782c0fefcc 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -1562,20 +1562,6 @@ template <class ELFT> typename ELFFile<ELFT>::uintX_t getMipsGpAddr() { 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); diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h index 2b1e14d84e3..2f9cd3abfce 100644 --- a/lld/ELF/Target.h +++ b/lld/ELF/Target.h @@ -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; diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 58299b130c3..e4fb84f72af 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -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) { + // 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, |

