Skip to content

Commit b6211d9

Browse files
committed
[ELF][MIPS] Reorganize isMipsPIC routine. NFC
llvm-svn: 331555
1 parent 86a1219 commit b6211d9

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lld/ELF/Arch/Mips.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -658,18 +658,21 @@ template <class ELFT> bool MIPS<ELFT>::usesOnlyLowPageBits(RelType Type) const {
658658

659659
// Return true if the symbol is a PIC function.
660660
template <class ELFT> bool elf::isMipsPIC(const Defined *Sym) {
661-
typedef typename ELFT::Ehdr Elf_Ehdr;
662-
if (!Sym->Section || !Sym->isFunc())
661+
if (!Sym->isFunc())
663662
return false;
664663

665-
auto *Sec = cast<InputSectionBase>(Sym->Section);
666-
ObjFile<ELFT> *File = Sec->template getFile<ELFT>();
664+
if (Sym->StOther & STO_MIPS_PIC)
665+
return true;
666+
667+
if (!Sym->Section)
668+
return false;
669+
670+
ObjFile<ELFT> *File =
671+
cast<InputSectionBase>(Sym->Section)->template getFile<ELFT>();
667672
if (!File)
668673
return false;
669674

670-
const Elf_Ehdr *Hdr = File->getObj().getHeader();
671-
return (Sym->StOther & STO_MIPS_MIPS16) == STO_MIPS_PIC ||
672-
(Hdr->e_flags & EF_MIPS_PIC);
675+
return File->getObj().getHeader()->e_flags & EF_MIPS_PIC;
673676
}
674677

675678
template <class ELFT> TargetInfo *elf::getMipsTargetInfo() {

0 commit comments

Comments
 (0)